How elma-123/forever-ecommerce-website works
1. System Purpose and Deployable Entry Points
This is a three-part MERN e-commerce system: a customer storefront, a separate administrator dashboard, and an Express REST API. The customer and admin applications are independent React/Vite SPAs; the backend owns authentication, catalog, carts, orders, payment initiation/verification, persistence, and image upload.
• frontend/src/main.jsx
• admin/src/main.jsx
• backend/server.js
2. Customer Storefront
The storefront is the user-facing shopping workflow: browse collections and products, manage a cart, authenticate, place orders, view prior orders, and return from payment verification. App.jsx composes route-level pages, while ShopContext is the client state boundary for shared catalog, cart, auth, and backend interaction state.
• frontend/src/App.jsx
• frontend/src/context/ShopContext.jsx
• frontend/src/pages/PlaceOrder.jsx
3. Admin Dashboard
The admin SPA provides authenticated operational workflows for creating products, reviewing the catalog, and processing/viewing orders. It is intentionally separate from the customer application and talks to the same backend API, carrying its own login/navigation shell and admin-oriented pages.
• admin/src/App.jsx
• admin/src/components/Login.jsx
• admin/src/pages/Add.jsx
• admin/src/pages/List.jsx
• admin/src/pages/Orders.jsx
4. API Composition and Request Boundary
server.js is the Node/Express runtime entry point. It mounts domain route modules that dispatch HTTP requests into controllers. Controllers are the application-service boundary: they validate/process API input, apply auth context, invoke Mongoose models, and return frontend/admin-consumable responses. The API domains are users, products, carts, and orders.
• backend/server.js
• backend/routes/userRoute.js
• backend/routes/productRoute.js
• backend/routes/cartRoute.js
• backend/routes/orderRoute.js
• backend/controllers/orderController.js
5. Identity and Authorization
User authentication is JWT-based. The normal auth middleware protects user-specific cart and order operations; a distinct admin middleware gates privileged product/order management actions. User records hold identity/authorization data and support the boundary between customer and administrator workflows.
• backend/middleware/auth.js
• backend/middleware/adminAuth.js
• backend/controllers/userController.js
• backend/models/userModel.js
6. Commerce Data and Checkout Flow
Products, user carts, and orders are persisted in MongoDB through Mongoose models. A typical flow is: storefront fetches products, context records cart actions through cart APIs, checkout submits an order, then the order controller executes Cash on Delivery or Stripe payment handling. The verification page completes the client-facing online-payment return flow; orders remain accessible to users and admins.
• backend/models/productModel.js
• backend/models/orderModel.js
• backend/controllers/cartController.js
• backend/controllers/orderController.js
• frontend/src/pages/Verify.jsx
7. External Infrastructure and Assets
MongoDB Atlas is the primary database, connected through the backend configuration layer. Cloudinary stores product imagery, with Multer handling incoming multipart uploads at the API boundary. Stripe is the external payment processor. Runtime secrets and service URLs are environment-driven; Vercel configuration exists for both SPAs and backend deployment configuration is also present.
• backend/config/mongodb.js
• backend/config/cloudinary.js
• backend/middleware/multer.js
• frontend/vercel.json
• admin/vercel.json
• backend/vercel.json
Main entry points: orderController.js Controllers · server.js Express server · orderRoute.js Domain routes · App.jsx Admin shell
Components 20
Customer Storefront
- Storefront SPA
frontend/src/main.jsx - Shopping routes
frontend/src/App.jsx - Shop context · Shared catalog, cart, auth, and API state.
frontend/src/context/ShopContext.jsx - Checkout
frontend/src/pages/PlaceOrder.jsx - Payment verification
frontend/src/pages/Verify.jsx
Admin Dashboard
- Admin SPA
admin/src/main.jsx - Admin shell
admin/src/App.jsx - Admin login
admin/src/components/Login.jsx - Product management · Creates and reviews catalog products.
admin/src/pages/Add.jsx - Order operations
admin/src/pages/Orders.jsx
Express API
- Express server · Mounts user, product, cart, and order routes.
backend/server.js - Domain routes
backend/routes/orderRoute.js - Controllers · Processes requests, auth context, models, and responses.
backend/controllers/orderController.js - JWT auth
backend/middleware/auth.js - Admin authorization
backend/middleware/adminAuth.js - Image uploads
backend/middleware/multer.js
Data & Integrations
- Commerce models · User, product, cart, and order persistence.
backend/models/orderModel.js - MongoDB Atlas
backend/config/mongodb.js - Cloudinary
backend/config/cloudinary.js - Stripe
Connections 24
- Storefront SPA → Shopping routes
- Shopping routes → Shop context: uses
- Shop context → Express server: catalog, cart, auth APIs
- Shopping routes → Checkout: checkout
- Checkout → Express server: submits order
- Payment verification → Express server: verifies payment
- Admin SPA → Admin shell
- Admin shell → Admin login: authenticates
- Admin shell → Product management: manages products
- Admin shell → Order operations: processes orders
- Product management → Express server: product APIs
- Order operations → Express server: order APIs
- Express server → Domain routes: mounts
- Domain routes → JWT auth: user operations
- Domain routes → Admin authorization: privileged operations
- Domain routes → Image uploads: product uploads
- JWT auth → Controllers: authorized request
- Admin authorization → Controllers: authorized request
- Image uploads → Controllers: multipart input
- Domain routes → Controllers: dispatches
- Controllers → Commerce models: reads and writes
- Commerce models → MongoDB Atlas: persists to
- Controllers → Cloudinary: stores images
- Controllers → Stripe: initiates and verifies payments