How sagspot/simple-ecommerce-api works
Main Components
a. Client Layer:
• External clients (mobile/web applications) that consume the API
• As the topmost layer
b. API Gateway Layer:
• Express.js server (index.js)
• Middleware components (auth.js, validation.js)
• Major endpoints groupings (users, products, orders)
c. Business Logic Layer:
• Controllers (userController.js, productController.js, orderController.js)
• Models (userModel.js, productModel.js, orderModel.js)
d. Database Layer:
• MongoDB database
Specific Implementation Details
Client Applications
• ↓
[API Gateway (Express.js)]
• [Middleware Layer]
• Authentication (auth.js)
• Validation (validation.js)
• [Routes Layer]
• /users
• /products
• /orders
• [Controllers Layer]
• UserController
• ProductController
• OrderController
• [Models Layer]
• UserModel
• ProductModel
• OrderModel
[MongoDB Database]
Additional Elements
a. Authentication Flow:
• JWT token flow
• Bcrypt password hashing
b. Technology Stack Annotations:
• Express.js
• Mongoose
• JWT
• Joi validation
• Morgan logging
Important Notes
• Notes about validation middleware using Joi
• Authentication flow with JWT
• Where Morgan logging occurs
• Routes that require authentication