This is a comprehensive e-commerce platform built with Node.js and Express, designed to handle user authentication, product management, order processing, and administrative functions. The application provides a robust backend API for managing sellers, products, orders, and users, with integrated email notifications and tracking services.
- Secure user registration and authentication using JWT tokens
- Password hashing with bcrypt for enhanced security
- Role-based access control for different user types (users, sellers, admins)
- Comprehensive product catalog with detailed information
- Seller-specific product management
- Product search and filtering capabilities
- Complete order lifecycle management from creation to fulfillment
- Order tracking with real-time status updates
- Integration with tracking services for shipment monitoring
- Admin dashboard for overseeing platform operations
- User and seller account management
- Order and product moderation tools
- Automated email notifications for order updates
- User communication system using Nodemailer
- Customizable email templates for various events
- Interactive API documentation powered by Swagger UI
- Comprehensive endpoint descriptions and examples
- Easy-to-use interface for testing API calls
- Backend Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: JSON Web Tokens (JWT)
- Security: bcrypt for password hashing
- Email Service: Nodemailer
- Validation: Express Validator
- API Documentation: Swagger
- Development: Nodemon for hot reloading
- Clone the repository to your local machine
- Navigate to the project directory
- Install dependencies:
npm install - Create a
.envfile in the root directory and configure the following environment variables:- Database connection string
- JWT secret key
- Email service credentials
- Other necessary configuration settings
- Start the development server:
npm run dev - For production deployment:
npm start
Once the server is running, you can access:
- The main API at
http://localhost:3000(or your configured port) - Swagger API documentation at
http://localhost:3000/api-docs
POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/logout- User logout
GET /api/products- Retrieve all productsPOST /api/products- Create a new product (seller/admin only)GET /api/products/:id- Get product detailsPUT /api/products/:id- Update product (seller/admin only)DELETE /api/products/:id- Delete product (seller/admin only)
GET /api/orders- Get user's ordersPOST /api/orders- Create a new orderGET /api/orders/:id- Get order detailsPATCH /api/orders/:id- Update order status (admin/seller only)
GET /api/admin/users- List all usersGET /api/admin/orders- List all ordersGET /api/admin/products- List all products
├── app.js # Main application file
├── server.js # Server startup file
├── config.js # Application configuration
├── swagger.js # Swagger documentation setup
├── config/
│ └── database.js # Database connection configuration
├── controllers/ # Route controllers
│ ├── authController.js
│ ├── adminController.js
│ ├── orderController.js
│ └── productController.js
├── middleware/ # Custom middleware
│ ├── authMiddleware.js
│ ├── validationMiddleware.js
│ └── ...
├── models/ # MongoDB models
│ ├── User.js
│ ├── Seller.js
│ ├── Product.js
│ └── Order.js
├── routes/ # API route definitions
│ ├── authRoutes.js
│ ├── adminRoutes.js
│ ├── orderRoutes.js
│ └── productRoutes.js
└── services/ # Business logic services
├── emailService.js
├── productService.js
└── trackingServices.js
The application uses environment variables for configuration. Create a .env file with the following variables:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/demo
JWT_SECRET=your_jwt_secret_key
EMAIL_HOST=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_email_password
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
Critical: for create/update/delete operations on
users(and other RLS-blocked tables) in the backend, useSUPABASE_SERVICE_ROLE_KEY.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the ISC License.