# rahulreddy006/full-stack-e-commerce architecture

> Architecture diagram of the GitHub repository rahulreddy006/full-stack-e-commerce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rahulreddy006/full-stack-e-commerce
- Repository: https://github.com/rahulreddy006/full-stack-e-commerce

## Overview

1. **Overall shape**
   - This repository is a three-part MERN ecommerce system: a customer-facing React app in `frontend`, an admin React app in `admin`, and an Express/MongoDB API in `backend`.
   - The two UIs are separate deployable clients, each with its own Vite build and Vercel config, while the backend is a standalone Node service.

2. **Customer storefront (`frontend`)**
   - The storefront is organized as a typical single-page app with `pages`, reusable `components`, and a shared `context/ShopContext.jsx`.
   - Key user flows are implemented through pages like `Home`, `Collection`, `Product`, `Cart`, `PlaceOrder`, `Orders`, `Login`, `Contact`, and `About`.
   - UI components such as `Navbar`, `Hero`, `LatestCollection`, `BestSeller`, `RelatedProducts`, `CartTotal`, and `SearchBox` suggest the app is product-browse and checkout oriented.

3. **Storefront state and data access**
   - `ShopContext` is the main client-side state boundary for cart/session-related behavior.
   - The frontend likely talks to the backend through API calls from pages/components, with context coordinating shared state such as cart contents, auth state, and product data.
   - The presence of `Orders` and `PlaceOrder` indicates the frontend handles the full purchase journey: browse → cart → checkout → order history.

4. **Admin panel (`admin`)**
   - The admin app is a separate React SPA focused on operational workflows rather than shopping.
   - Its route-level UI is centered on `Login`, `Add`, `List`, and `Orders`, with shared chrome in `Navbar` and `Sidebar`.
   - This app is the control plane for product catalog management and order review, distinct from the customer storefront.

5. **Backend API (`backend`)**
   - The backend is an Express application organized into `routes`, `controllers`, `models`, `middleware`, and `config`.
   - It exposes resource-oriented endpoints for products, cart, orders, and users through route files like `productRoute.js`, `cartRoute.js`, `orderRoute.js`, and `userRoute.js`.
   - Controllers contain the business logic, keeping route definitions thin and making the API layer easier to diagram as route → controller → model/external service.

6. **Domain data model**
   - MongoDB entities are defined in `models/productModel.js`, `orderModel.js`, and `userModel.js`.
   - These models are the persistence boundary for catalog items, customer accounts, and purchase records.
   - Orders are a central aggregate: they connect user identity, cart contents, payment state, and fulfillment history.

7. **Authentication and authorization**
   - `middleware/auth.js` and `middleware/adminAuth.js` split access control into customer-authenticated and admin-only paths.
   - JWT is the primary auth mechanism per the README, with passwords handled via `bcrypt.js`.
   - This creates an important boundary: storefront users can browse and purchase, while admin routes are protected for catalog/order management.

8. **File upload and product media**
   - `middleware/multer.js` handles multipart image uploads on the backend.
   - Uploaded images are integrated with Cloudinary via `config/cloudinary.js`, making product media an externalized asset pipeline rather than local filesystem storage.
   - In architecture diagrams, this is best shown as admin product creation/editing flowing through backend upload middleware to Cloudinary, then persisting the resulting image URLs in MongoDB.

9. **Payments and order lifecycle**
   - The README identifies Razorpay as the payment provider, so checkout involves an external payment gateway before order finalization.
   - The likely flow is: cart/checkout data from the storefront → backend order/payment endpoints → Razorpay transaction → order persisted in MongoDB.
   - Order management is surfaced back to both customer and admin UIs through order routes and order-related pages.

10. **Shared infrastructure and deployment**
   - Each app has its own `vite.config.js` and `vercel.json`, indicating separate frontend deployments and routing setup.
   - The backend is intended for a Node hosting platform such as Render, while frontend/admin are Vercel-compatible static SPA deployments.
   - This separation matters architecturally: the clients are independent builds, but both depend on the same API and data store.

11. **Primary runtime/data flow**
   - Customer flow: React storefront → backend API → MongoDB, with Cloudinary for product images and Razorpay for payments.
   - Admin flow: React admin app → authenticated backend API → MongoDB/Cloudinary.
   - Both UIs are thin presentation layers over shared backend resources, which makes the backend the main system-of-record boundary.

12. **Architecture summary for diagramming**
   - Draw three top-level boxes: storefront UI, admin UI, and backend API.
   - Inside the backend, show controllers, routes, middleware, and models as layered responsibilities.
   - External services to show explicitly are MongoDB, Cloudinary, and Razorpay; Vercel/hosting is deployment infrastructure rather than business logic.

Main entry points: [`frontend/src/App.jsx`](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/App.jsx) (Storefront), [`admin/src/App.jsx`](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/admin/src/App.jsx) (Admin), [`backend/controllers/productController.js`](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/controllers/productController.js) (Controllers), [`backend/routes/productRoute.js`](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/routes/productRoute.js) (Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_frontend_app["Storefront<br/>React SPA<br/>[App.jsx]"]
  node_shop_context["Shop state<br/>client context<br/>[ShopContext.jsx]"]
  node_home_page["Home<br/>storefront page<br/>[Home.jsx]"]
  node_collection_page["Collection<br/>storefront page<br/>[Collection.jsx]"]
  node_product_page["Product<br/>storefront page<br/>[Product.jsx]"]
  node_cart_page["Cart<br/>storefront page<br/>[Cart.jsx]"]
  node_checkout_page["Place order<br/>storefront page<br/>[PlaceOrder.jsx]"]
  node_orders_page["Orders<br/>storefront page<br/>[Orders.jsx]"]
end

subgraph group_admin["Admin"]
  node_admin_app["Admin<br/>React SPA<br/>[App.jsx]"]
  node_admin_login["Login<br/>admin page<br/>[Login.jsx]"]
  node_admin_catalog["Catalog<br/>admin page<br/>[Add.jsx]"]
  node_admin_orders["Orders<br/>admin page<br/>[Orders.jsx]"]
end

subgraph group_backend["Backend"]
  node_api_server["API<br/>Express server<br/>[server.js]"]
  node_routes["Routes<br/>route layer<br/>[productRoute.js]"]
  node_controllers["Controllers<br/>business logic"]
  node_middleware["Middleware<br/>auth/upload<br/>[auth.js]"]
  node_models[("Models<br/>[productModel.js]")]
end

subgraph group_external["External"]
  node_mongo[("MongoDB<br/>database<br/>[mongodb.js]")]
  node_cloudinary(("Cloudinary<br/>media service<br/>[cloudinary.js]"))
  node_razorpay(("Razorpay<br/>payment gateway"))
end

node_frontend_app -->|"shares state"| node_shop_context
node_frontend_app -->|"routes to"| node_home_page
node_frontend_app -->|"routes to"| node_collection_page
node_frontend_app -->|"routes to"| node_product_page
node_frontend_app -->|"routes to"| node_cart_page
node_frontend_app -->|"routes to"| node_checkout_page
node_frontend_app -->|"routes to"| node_orders_page
node_shop_context -->|"API calls"| node_api_server
node_admin_app -->|"routes to"| node_admin_login
node_admin_app -->|"routes to"| node_admin_catalog
node_admin_app -->|"routes to"| node_admin_orders
node_admin_app -->|"API calls"| node_api_server
node_api_server -->|"exposes"| node_routes
node_routes -->|"delegates"| node_controllers
node_controllers -->|"reads/writes"| node_models
node_routes -->|"protects"| node_middleware
node_models -->|"persists to"| node_mongo
node_controllers -->|"uploads media"| node_cloudinary
node_controllers -->|"charges payment"| node_razorpay
node_middleware -->|"verifies user"| node_models

click node_frontend_app "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/App.jsx"
click node_shop_context "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/context/ShopContext.jsx"
click node_home_page "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/Home.jsx"
click node_collection_page "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/Collection.jsx"
click node_product_page "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/Product.jsx"
click node_cart_page "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/Cart.jsx"
click node_checkout_page "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/PlaceOrder.jsx"
click node_orders_page "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/Orders.jsx"
click node_admin_app "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/admin/src/App.jsx"
click node_admin_login "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/admin/src/components/Login.jsx"
click node_admin_catalog "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/admin/src/pages/Add.jsx"
click node_admin_orders "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/admin/src/pages/Orders.jsx"
click node_api_server "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/server.js"
click node_routes "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/routes/productRoute.js"
click node_controllers "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/controllers/productController.js"
click node_middleware "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/middleware/auth.js"
click node_models "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/models/productModel.js"
click node_mongo "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/config/mongodb.js"
click node_cloudinary "https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/config/cloudinary.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_app,node_shop_context,node_home_page,node_collection_page,node_product_page,node_cart_page,node_checkout_page,node_orders_page toneBlue
class node_admin_app,node_admin_login,node_admin_catalog,node_admin_orders toneAmber
class node_api_server,node_routes,node_controllers,node_middleware,node_models toneMint
class node_mongo,node_cloudinary,node_razorpay toneRose
```

## Components

### Storefront

Customer-facing React app for browsing, cart, checkout, and order history.

- [Storefront](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/App.jsx): React SPA · Customer-facing application shell and routing. · `frontend/src/App.jsx`
- [Shop state](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/context/ShopContext.jsx): client context · Shared storefront state for cart, session, and API coordination. · `frontend/src/context/ShopContext.jsx`
- [Home](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/Home.jsx): storefront page · Landing page and featured product discovery. · `frontend/src/pages/Home.jsx`
- [Collection](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/Collection.jsx): storefront page · Catalog browsing and filtering. · `frontend/src/pages/Collection.jsx`
- [Product](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/Product.jsx): storefront page · Single product detail and related items. · `frontend/src/pages/Product.jsx`
- [Cart](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/Cart.jsx): storefront page · Cart review and totals. · `frontend/src/pages/Cart.jsx`
- [Place order](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/PlaceOrder.jsx): storefront page · Checkout and order submission. · `frontend/src/pages/PlaceOrder.jsx`
- [Orders](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/frontend/src/pages/Orders.jsx): storefront page · Customer order history and tracking. · `frontend/src/pages/Orders.jsx`

### Admin

Operational React app for catalog and order management.

- [Admin](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/admin/src/App.jsx): React SPA · Admin application shell and routing. · `admin/src/App.jsx`
- [Login](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/admin/src/components/Login.jsx): admin page · Admin authentication entry point. · `admin/src/components/Login.jsx`
- [Catalog](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/admin/src/pages/Add.jsx): admin page · Product creation, listing, and editing workflows. · `admin/src/pages/Add.jsx`
- [Orders](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/admin/src/pages/Orders.jsx): admin page · Order review and operational handling. · `admin/src/pages/Orders.jsx`

### Backend

Express API, business logic, auth, and persistence boundary.

- [API](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/server.js): Express server · Backend entrypoint and application composition. · `backend/server.js`
- [Routes](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/routes/productRoute.js): route layer · Resource endpoints for products, carts, orders, and users. · `backend/routes/productRoute.js`
- [Controllers](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/controllers/productController.js): business logic · Request handling and domain workflows. · `backend/controllers/productController.js`
- [Middleware](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/middleware/auth.js): auth/upload · Access control and multipart upload handling. · `backend/middleware/auth.js`
- [Models](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/models/productModel.js): Mongo models · Persistence schemas for products, orders, and users. · `backend/models/productModel.js`

### External

Managed services used by the backend.

- [MongoDB](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/config/mongodb.js): database · Primary data store for catalog, users, and orders. · `backend/config/mongodb.js`
- [Cloudinary](https://github.com/rahulreddy006/full-stack-e-commerce/blob/main/backend/config/cloudinary.js): media service · External image storage for product media. · `backend/config/cloudinary.js`
- **Razorpay**: payment gateway · Checkout payment provider used for order payment.

## Connections

- Storefront → Shop state: shares state · Storefront pages and components coordinate through shared client state.
- Storefront → Home: routes to · Customer-facing navigation starts from the home page.
- Storefront → Collection: routes to · Catalog browsing page.
- Storefront → Product: routes to · Product detail page.
- Storefront → Cart: routes to · Cart page.
- Storefront → Place order: routes to · Checkout flow page.
- Storefront → Orders: routes to · Customer order history page.
- Shop state → API: API calls · Client state boundary coordinating backend requests.
- Admin → Login: routes to · Admin login screen.
- Admin → Catalog: routes to · Catalog management screen.
- Admin → Orders: routes to · Order management screen.
- Admin → API: API calls · Admin UI talks to the shared backend API.
- API → Routes: exposes · Server mounts the resource route layer.
- Routes → Controllers: delegates · Routes stay thin and forward work to controllers.
- Controllers → Models: reads/writes · Controllers persist and query domain records.
- Routes → Middleware: protects · Auth and upload middleware guard selected endpoints.
- Models → MongoDB: persists to · MongoDB stores the main domain data.
- Controllers → Cloudinary: uploads media · Product image handling is externalized to Cloudinary.
- Controllers → Razorpay: charges payment · Checkout finalization integrates with the payment gateway.
- Middleware → Models: verifies user · Auth middleware depends on user records for access control.
