This is the backend application for an E-Commerce website. It provides RESTful API endpoints for managing products, categories, and tags. The application is built using Node.js, Express.js, and Sequelize as the ORM for MySQL.
Clone the repository:
git clone https://github.com/your-username/e-commerce-backend.git
-
Navigate to the project directory:
Copy code cd e-commerce-backend
-
Install dependencies:
Copy code npm install
- Set up the database configuration:
- Create a .env file in the root directory.
- Add your MySQL database credentials:
env Copy code DB_NAME=your_database_name DB_USER=your_database_user DB_PASSWORD=your_database_password
-
Start the application:
Copy code npm start The server will be running at http://localhost:3001.
-
Create a MySQL database.
-
Update the .env file with your database details.
-
Run the Sequelize migrations to create tables:
Copy code npm run migrate Seed the database with sample data: ```bash Copy code npm run seed
Categories:
- GET /api/categories
- GET /api/categories/:id
- POST /api/categories
- PUT /api/categories/:id
- DELETE /api/categories/:id
Products:
- GET /api/products
- GET /api/products/:id
- POST /api/products
- PUT /api/products/:id
- DELETE /api/products/:id
Tags:
- GET /api/tags
- GET /api/tags/:id
- POST /api/tags
- PUT /api/tags/:id
- DELETE /api/tags/:id
Category:
- id (INTEGER, PRIMARY KEY)
- category_name (STRING)
Product:
- id (INTEGER, PRIMARY KEY)
- product_name (STRING)
- price (DECIMAL)
- stock (INTEGER)
- category_id (INTEGER, FOREIGN KEY)
Tag:
- id (INTEGER, PRIMARY KEY)
- tag_name (STRING)
ProductTag:
- id (INTEGER, PRIMARY KEY)
- product_id (INTEGER, FOREIGN KEY)
- tag_id (INTEGER, FOREIGN KEY)
Contributions are welcome! Please follow the Contribution Guidelines.
This project is licensed under the MIT License.