A back end for an e-commerce website built with Express.js, Sequelize, MySQL, and tested with Insomnia.
This project is a back end solution for managing an e-commerce website. It's built using Express.js for handling HTTP requests, Sequelize as the ORM tool for interacting with a MySQL database, and utilizes RESTful API routes for CRUD operations on product categories, individual products, and associated tags.
The application features well-defined models for categories, products, tags, and their associations, creating an organized database schema. It includes a seed script to easily populate the database with test data for testing and development purposes.
- Seamless management of product categories, products, and tags.
- Efficient API routes for creating, updating, and deleting data.
- Robust database schema and models with associations between categories, products, and tags.
- Secure storage of sensitive data, such as MySQL credentials, using environment variables with the
dotenvpackage. - Convenient seed script (
npm run seed) for populating the database with test data, facilitating testing and development.
Follow these steps to set up and use the E-Commerce-Management on your local machine:
- Clone the repository:
git clone https://github.com/bahossdev/E-Commerce-Management.git - Install the required libraries:
npm install - To connect to your MySQL database, create a
.envfile in the root directory of the project, including the following:DB_NAME = database_name DB_USER = your username DB_PASSWORD = your password
- Create a MySQL database using the provided schema.sql file.
- Seed the database with test data:
npm run seed - Run the app using:
npm start
Now, you're ready to efficiently manage your e-commerce platform.
-
Ensure the application is running by executing
npm start. -
Use Insomnia Core or a similar tool to test API routes.
-
Open API different routes for categories, products, or tags to view data in a formatted JSON. Here are some examples:
- GET All Categories:
GET http://localhost:3001/api/categories
- GET Single Product:
GET http://localhost:3001/api/products/1
- POST Create Category:
POST http://localhost:3001/api/categories Content-Type: json { "category_name": "Electronics" }
- PUT Update Product:
PUT http://localhost:3001/api/products/1 Content-Type: json { "product_name": "Updated Product", "price": 49.99 }
- DELETE Remove Tag from Product:
DELETE http://localhost:3001/api/products/1/tags/2
- GET All Categories:
-
Test API POST, PUT, and DELETE routes for all other routes (categories, products, and tags) to create, update, and delete data in the database.
NOTE: In case of any errors or if you'd like to cancel a task press ctrl+c (^C).
To create this application, I referenced documentation for MySQL, Express.js, npm, Insomnia [add more]. Additionally, I drew insights from class activities and consulted resources on MDN, W3Schools, Stack Overflow, and similar educational platforms. The starter code can be found at this link.
Please refer to the LICENSE in the repo.
Link to Walkthrough Video demonstrating the functionality of the E-Commerce-Management:
If you have any questions or need further assistance, feel free to reach out @bahoss.dev@gmail.com.

