How bappaditya721135/mern-ecommerce-backend works
This is a MERN e-commerce backend exposing product, account/cart, and order APIs. Clients enter through the Express application, which mounts domain routers; handlers perform the domain operations through Mongoose models and return JSON responses. Account flows include authentication, role checks, cookies, and password-reset email; product flows include catalog, reviews, and cart operations; order flows include customer and admin operations. The source index and excerpts support these principal links, but the README is empty and some modules were not sampled, so uncertain wiring is omitted.
Main entry points: index.js Express application · errorHandlerClass.js Application errors · userController.js Account and cart · productController.js Catalog and reviews
Components 20
API application
- Express application
index.js - User routes
routes/userRouter.js - Product routes
routes/productRouter.js - Order routes
routes/orderRouter.js
Accounts and access
- Account and cart
controller/userController.js - Authentication
middleware/isAuthenticated.js - Role authorization
middleware/isAuthorize.js - User records
models/userModel.js - Auth cookies
utils/sendCookie.js - Email delivery
utils/sendEmail.js
Commerce domains
- Catalog and reviews
controller/productController.js - Product filtering
utils/productApiFeatures.js - Product records
models/productModel.js - Order operations
controller/orderController.js - Order records
models/orderModel.js
Persistence and utilities
- Database connection
db/database.js - Application errors
utils/errorHandlerClass.js - Error handling
middleware/error.js
Other components
- API client
- MongoDB
Connections 31
- API client → Express application: sends requests
- Express application → Database connection: connects database
index.js - Express application → User routes: mounts routes
index.js - Express application → Product routes: mounts routes
index.js - Express application → Order routes: mounts routes
index.js - Express application → Error handling: registers errors
index.js - Database connection → MongoDB: connects to
db/database.js - User routes → Account and cart: dispatches
routes/userRouter.js - Product routes → Catalog and reviews: dispatches
routes/productRouter.js - Order routes → Order operations: dispatches
routes/orderRouter.js - User routes → Authentication: guards routes
routes/userRouter.js - Product routes → Authentication: guards routes
routes/productRouter.js - Order routes → Authentication: guards routes
routes/orderRouter.js - User routes → Role authorization: checks admin
routes/userRouter.js - Product routes → Role authorization: checks admin
routes/productRouter.js - Order routes → Role authorization: checks admin
routes/orderRouter.js - Account and cart → User records: reads and writes
controller/userController.js - Account and cart → Auth cookies: issues cookies
controller/userController.js - Account and cart → Email delivery: sends reset email
controller/userController.js - Authentication → User records: loads user
middleware/isAuthenticated.js - Authentication → Application errors: creates errors
middleware/isAuthenticated.js - Role authorization → Application errors: creates errors
middleware/isAuthorize.js - Catalog and reviews → Product records: reads and writes
controller/productController.js - Catalog and reviews → User records: loads cart owner
controller/productController.js - Catalog and reviews → Product filtering: filters catalog
controller/productController.js - Order operations → Order records: reads and writes
controller/orderController.js - Order operations → Product records: updates stock
controller/orderController.js - Catalog and reviews → Application errors: creates errors
controller/productController.js - Order operations → Application errors: creates errors
controller/orderController.js - Account and cart → Application errors: creates errors
controller/userController.js - Error handling → Application errors: formats errors
middleware/error.js