Welcome to the repository for the backend of an ecommerce watch store built using the MERN (MongoDB, Express.js, React.js, Node.js) stack. This project serves as the backend infrastructure for an online store selling watches.
This project implements the backend functionalities required for an ecommerce platform, including user authentication, product management, and file uploads. It provides a RESTful API for the frontend to interact with and manage data.
- MongoDB: NoSQL database for storing product, user, and order data.
- Express.js: Node.js framework used to build the RESTful API endpoints.
- Node.js: JavaScript runtime environment for server-side code execution.
- JWT (JSON Web Tokens): Used for user authentication and session management.
- Multer and Cloudinary: Libraries for handling file uploads and cloud storage.
- Mongoose: MongoDB object modeling for Node.js applications.
├── config/
│ ├── dbConnect.js
│ ├── jswebtoken.js
│ └── refreshToken.js
├── controllers/
│ ├── brandCtrl.js
│ ├── categoryCtrl.js
│ ├── emailCtrl.js
│ ├── enquiryCtrl.js
│ ├── productCtrl.js
│ ├── uploadCtrl.js
│ └── userCtrl.js
├── middlewares/
│ ├── authMW.js
│ ├── errorHandling.js
│ └── fileUpload.js
├── models/
│ ├── brandModel.js
│ ├── cartModel.js
│ ├── categoryModel.js
│ ├── enquiryModel.js
│ ├── orderModel.js
│ ├── productModel.js
│ └── userModel.js
├── routes/
│ ├── authRoute.js
│ ├── brandRoute.js
│ ├── categoryRoute.js
│ ├── enquiryRoute.js
│ ├── productRoute.js
│ └── uploadRoute.js
├── utils/
│ ├── cloudinary.js
│ └── validation.js
├── index.js
├── package-lock.json
└── package.json
- User Authentication: Provides endpoints for user registration, login, and authentication using JWT.
- Product Management: Allows CRUD operations for products, including creation, retrieval, update, and deletion.
- File Uploads: Supports file uploads for product images using Multer and integrates with Cloudinary for cloud storage.
- Error Handling: Implements centralized error handling and validation for API endpoints.
- Modular Architecture: Organized into controllers, models, routes, and middlewares for scalability and maintainability.
-
Clone the repository:
git clone https://github.com/namdavid2904/Watch-Store.git
-
Navigate to the project directory:
cd Watch-Store
-
Install dependencies:
npm install
-
Set up environment variables:
Create a
.env
file in the root directory and add the following:PORT = #### MONGODB_URL = #### SECRET_KEY = #### MAIL_ID = #### MAIL_PW = #### CLOUD_NAME = #### API_KEY = ####
Replace
PORT
,MONGODB_URL
,SECRET_KEY
,MAIL_ID
,MAIL_PW
,CLOUD_NAME
, andAPI_KEY
with your own values. -
Start the server:
npm start
The backend server will start running on the specified port (default: 3000).
For detailed API documentation and usage, refer to the Postman collection provided in the docs/
directory.
This project is licensed under the MIT License - see the LICENSE file for details.