This project is a Node.js application built with Express.js and MongoDB, designed to provide a backend for an e-commerce platform. It includes models for managing products, categories, brands, carts, orders, users, reviews, and coupons. Additionally, it features utility classes for error handling and implementing common MongoDB query functionalities.
The project consists of several modules organized into folders:
Contains MongoDB schema definitions and models for various entities such as products, categories, brands, carts, orders, users, reviews, and coupons.
Includes utility classes for error handling (ErrorHandler) and implementing common MongoDB query features (ApiFeatures).
Designed validator functions to validate incoming data and ensure data integrity. Implemented validation middleware to validate request data before processing.
Developed controller functions to handle incoming requests and interact with the database. Implemented middleware functions for request validation, authentication, and error handling.
Represents a product with attributes like title, description, price, quantity, and associated entities like category, brand, and reviews.
Defines product categories with attributes such as name and image.
Represents brands with attributes like name and image.
Represents user carts with details about the products, quantities, prices, and total prices.
Represents user orders with details like cart items, payment method, and delivery status.
Represents users with attributes like username, email, password, addresses, and wishlist.
Represents product reviews with attributes like title, rating, user, and product association.
Represents discount coupons with attributes like name, expiration date, and discount percentage.
Defines subcategories associated with parent categories.
Provides a custom error class for handling errors with status codes.
Offers utility methods for pagination, sorting, filtering, field selection, and searching in MongoDB queries.
- Clone the repository from GitHub.
- Install dependencies using npm install.
- Set up environment variables like MongoDB URI, JWT secret key, and expiration time.
- Run the application using npm start.
1. Authentication and Authorization
2. Product Management
3. Order Management
4. Cart Management
5. Reviews and Ratings
6. Coupon and Discount Management
7. Category and Subcategory Management
8. Pagination, Sorting, and Filtering
9. Error Handling and Utilities
10. User Profile and Wishlist
1. User Authentication
2. Product Management
3. Order Management
4. Cart Management
5. Reviews and Ratings
6. Coupon and Discount Management
7. Category and Subcategory Management
8. Other Features
- GET /api/categories: Get all categories.
- POST /api/categories: Create a new category.
- GET /api/categories/:id: Get a specific category by ID.
- PUT /api/categories/:id: Update a specific category by ID.
- DELETE /api/categories/:id: Delete a specific category by ID.
- GET /api/categories/:categoryId/subcategories: Get all subcategories of a specific category.
- GET /api/categories/:categoryId/products: Get all products of a specific category.
- GET /api/subcategories: Get all subcategories.
- POST /api/subcategories: Create a new subcategory.
- GET /api/subcategories/:id: Get a specific subcategory by ID.
- PUT /api/subcategories/:id: Update a specific subcategory by ID.
- DELETE /api/subcategories/:id: Delete a specific subcategory by ID.
- GET /api/brands: Get all brands.
- POST /api/brands: Create a new brand.
- GET /api/brands/:id: Get a specific brand by ID.
- PUT /api/brands/:id: Update a specific brand by ID.
- DELETE /api/brands/:id: Delete a specific brand by ID.
- GET /api/products: Get all products.
- POST /api/products: Create a new product.
- GET /api/products/:id: Get a specific product by ID.
- PUT /api/products/:id: Update a specific product by ID.
- DELETE /api/products/:id: Delete a specific product by ID.
- GET /api/products/search: Search for products.
- GET /api/products/:productId/reviews: Get all reviews for a specific product.
- POST /api/products/:productId/reviews: Create a new review for a specific product.
- GET /api/reviews/:id: Get a specific review by ID.
- PUT /api/reviews/:id: Update a specific review by ID.
- DELETE /api/reviews/:id: Delete a specific review by ID.
- GET /api/users/me: Get the authenticated user's details.
- PUT /api/users/updateUser: Update the authenticated user's details.
- PUT /api/users/changePassword: Change the authenticated user's password.
- GET /api/users: Get all users (admin only).
- POST /api/users: Create a new user (admin only).
- GET /api/users/:id: Get a specific user by ID (admin only).
- PUT /api/users/:id: Update a specific user by ID.
- DELETE /api/users/:id: Delete a specific user by ID (admin only).
- POST /api/auth/signup: Register a new user.
- POST /api/auth/login: Login with credentials.
- DELETE /api/auth/logout: Logout the authenticated user.
- GET /api/addToCarts: Get logged-in user's cart.
- POST /api/addToCarts: Add a product to the cart.
- DELETE /api/addToCarts: Clear logged-in user's cart.
- DELETE /api/addToCarts/:id: Delete a specific item from the cart.
- PUT /api/addToCarts/:id: Update a specific item in the cart.
- PUT /api/addToCarts/applycoupon: Apply coupon to the cart.
- POST /api/wishList: Add a product to the wishlist.
- DELETE /api/wishList/:productId: Remove a product from the wishlist.
- GET /api/wishList: Get logged-in user's wishlist.
- POST /api/addresses: Add an address for the logged-in user.
- DELETE /api/addresses/:addressId: Remove an address for the logged-in user.
- GET /api/addresses: Get all addresses of the logged-in user.
- GET /api/coupons: Get all coupons.
- POST /api/coupons: Create a new coupon.
- GET /api/coupons/:id: Get a specific coupon by ID.
- PUT /api/coupons/:id: Update a specific coupon by ID.
- DELETE /api/coupons/:id: Delete a specific coupon by ID.
- POST /api/forgetpassword: Check password for reset.
- GET /api/forgetpassword/:email/:token: Reset password page.
- POST /api/forgetpassword/:email/:token: Update reset password.
Provides a custom error class for handling errors with status codes.
Offers utility methods for pagination, sorting, filtering, field selection, and searching in MongoDB queries.
- Clone the repository from GitHub.
- Install dependencies using npm install.
- Set up environment variables like MongoDB URI, JWT secret key, and expiration time.
- Run the application using npm start.