This is the backend for an e-commerce website. The application uses Express.js and Sequelize to create a RESTful API that interacts with a MySQL database. The API allows the user to perform CRUD operations on products, categories, and tags, as well as view product tags and category products.
To install this application, follow these steps:
- Clone the repository from GitHub
- Download and install MySQL from the official website if you haven't already done so. Follow the instructions provided to set up MySQL on your local machine.
- Download and install Node.js from the official website if you haven't already done so. Follow the instructions provided to install Node.js on your local machine.
- Open your terminal and navigate to the root directory of the application.
- Install the required dependencies by running
npm install
, this will install all the necessary packages and libraries required for the application to run. - Create a .env file in the root directory of the application and provide your database credentials. Example:
DB_USER='your_mysql_username'
DB_PASSWORD='your_mysql_password'
DB_NAME='ecommerce_db'
- Log in to the MySQL server by running the command
mysql -u root -p
and entering your password when prompted. - Create the database schema by running the command
SOURCE db/schema.sql;
..
Please note that steps 8 & 9 should be performed in a separate terminal window or tab from the one running the Node.js application.
To use this application, follow these steps:
- Open a terminal window and navigate to the root directory of the application.
- Run the command
npm run seed
to seed the database with sample data. - Start the application by running
npm run start
. - Use a tool such as Insomnia or Postman to test the various routes of the API.
For a short demonstration of the application, please refer to the video.
The following routes are available in the API:
- GET /api/categories - get all categories
- GET /api/categories/:id - get a single category by ID
- POST /api/categories - create a new category
- PUT /api/categories/:id - update a category by ID
- DELETE /api/categories/:id - delete a category by ID
- GET /api/products - get all products
- GET /api/products/:id - get a single product by ID
- POST /api/products - create a new product
- PUT /api/products/:id - update a product
- DELETE /api/products/:id - delete a product by ID
- GET /api/tags - get all tags
- GET /api/tags/:id - get a single tag by ID
- POST /api/tags - create a new tag
- PUT /api/tags/:id - update a tag
- DELETE /api/tags/:id - delete a tag by ID
This project requires the following dependencies:
This project is licensed under the MIT license. Click here for more information.
To contribute to this project, please read the installation section and ensure you have a solid understanding of the codebase. Contributions are welcome via pull requests.
Currently, there are no automated tests for this application. Testing is performed manually.
If you have any questions, you can reach out to me on GitHub or contact me directly at [email protected].