Giter Club home page Giter Club logo

tuf-task-backend's Introduction

Flashcard Learning Tool Backend

This is the backend API for the Flashcard Learning Tool, built using Node.js, Express, and MySQL. The API provides endpoints for managing flashcards, including creating, reading, updating, and deleting flashcards.

Features

  • Express.js: Handles the routing and middleware.
  • MySQL: Used as the relational database to store flashcards.
  • CORS: Enables cross-origin requests.
  • Body-Parser: Parses incoming JSON requests.

Getting Started

Prerequisites

Ensure you have the following installed on your system:

  • Node.js (v12.x or later)
  • MySQL (v5.7 or later)
  • npm (v6.x or later)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd flashcard-backend
  2. Install dependencies:

    npm install
  3. Create a .env file in the root directory and add the following environment variables:

    PORT=5000
    DB_HOST=your_database_host
    DB_USER=your_database_user
    DB_PASSWORD=your_database_password
    DB_NAME=your_database_name
    DB_PORT=your_database_port
  4. Set up your MySQL database:

    • Create a MySQL database.
    • Create a table named flashcards with the following schema:
      CREATE TABLE flashcards (
          id INT AUTO_INCREMENT PRIMARY KEY,
          question VARCHAR(255) NOT NULL,
          answer TEXT NOT NULL
      );

Running the Application

  1. Start the server:

    npm start

    The server will start on the port specified in the .env file (default: 5000).

  2. API Endpoints:

    • GET /api/flashcards
      • Retrieves all flashcards from the database.
    • POST /api/flashcards
      • Creates a new flashcard.
      • Body:
        {
            "question": "What is Node.js?",
            "answer": "Node.js is a JavaScript runtime built on Chrome's V8 engine."
        }
    • PUT /api/flashcards/:id
      • Updates an existing flashcard by its ID.
      • Body:
        {
            "question": "What is Express.js?",
            "answer": "Express.js is a web application framework for Node.js."
        }
    • DELETE /api/flashcards/:id
      • Deletes a flashcard by its ID.
  3. Test the API:

    • You can use tools like Postman to test the API endpoints.

Deployment

To deploy this application, you can use services like Heroku, AWS, or any other cloud provider that supports Node.js applications.

Contributing

If you would like to contribute to this project, please fork the repository and submit a pull request with your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Replace `<repository-url>` with your actual GitHub repository URL if applicable. This README provides clear instructions on setting up, running, and using the API, along with the necessary environment configuration.

tuf-task-backend's People

Contributors

adityagaur7 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.