Scalable Backend API for E-Commerce with Authentication, Orders, and Payments
Design and generate a fully functional, scalable backend API for an e-commerce platform using a modern technology stack (e.g., Node.js with Express or similar). The API should follow best practices for clean architecture, modular folder structure, and maintainability.
Include the following core modules and features:
- User Authentication & Authorization
- User registration and login
- Secure password hashing
- JWT-based authentication
- Role-based access control (e.g., admin, customer)
- Management of Products
- CRUD processes for goods
- Inventory control and categories
- Image management (upload/store URLs)
- Purchasing Cart
- Add, edit, and remove products from your cart
- User account-linked persistent cart
- Management of Orders
- Make and oversee orders
- Order status monitoring (pending, shipped, delivered, etc.)
- Users’ order history
- Integration of Payments
- Include a simulated or actual payment gateway, such as Razorpay or Stripe.
- Manage transaction data and payment status.
- Error Handling & Middleware
- Centralized management of errors
- Verify and sanitize the request
- Middleware for authentication
- Integrating Databases
- Make use of a database (such as PostgreSQL or MongoDB).
- Describe appropriate linkages and schemas/models.
- Extra Conditions
- Principles of RESTful API design
- Configuration dependent on the environment
- API documentation (Swagger/OpenAPI, for example)
- Logging and fundamental security measures (such as CORS and rate limitation)
Make sure that the code has a clear division of responsibilities and reusable parts, is well-structured, commented, and ready for production.
