# hirdeshpal888527/smartcommerce architecture

> Architecture diagram of the GitHub repository hirdeshpal888527/smartcommerce, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hirdeshpal888527/smartcommerce
- Repository: https://github.com/hirdeshpal888527/smartcommerce

## Overview

SmartCommerce is a MERN marketplace with buyer, seller, and admin portals. Buyers browse/search products, manage a cart or wishlist, check out, and track orders; sellers manage products and view analytics and orders, while admins manage users, products, and orders. The documented backend layers requests through Express routes, controllers, services, and MongoDB models, with search, caching, uploads, and mock payments as supporting capabilities. Some feature pages and integrations are unsampled, so those relationships are shown only where the README or source index supports them.

Main entry points: [`server/src/models/Product.js`](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/models/Product.js) (Product model), [`client/src/routes/AppRoutes.jsx`](https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/routes/AppRoutes.jsx) (App routing), [`server/src/app.js`](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/app.js) (Express app), [`server/src/routes/productRoutes.js`](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/routes/productRoutes.js) (Product routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_buyer["Buyer experience"]
  node_routes["App routing<br/>[AppRoutes.jsx]"]
  node_authstate["Auth state<br/>[authStore.jsx]"]
  node_authapi["Auth API<br/>[authApi.js]"]
  node_orderdetail["Order details"]
  node_orderstate["Order state<br/>[orderStore.js]"]
  node_buyerfeatures["Buyer commerce"]
end

subgraph group_portals["Seller and admin"]
  node_sellerlayout["Seller portal layout<br/>[SellerLayout.jsx]"]
  node_sellerfeatures["Seller management"]
  node_sellerstate["Seller state<br/>[sellerStore.js]"]
  node_adminfeatures["Admin management"]
end

subgraph group_backend["Backend request layers"]
  node_http["Axios API layer<br/>[axios.js]"]
  node_express["Express app<br/>[app.js]"]
  node_productroutes["Product routes<br/>[productRoutes.js]"]
  node_adminroutes["Admin routes<br/>[adminRoutes.js]"]
  node_productcontroller["Product controller"]
  node_admincontroller["Admin controller<br/>[adminController.js]"]
  node_orderservice["Order service<br/>[orderServices.js]"]
  node_productservice["Product service<br/>[productServices.js]"]
  node_adminservice["Admin service<br/>[adminServices.js]"]
  node_authmiddleware["JWT authentication<br/>[authMiddleware.js]"]
  node_rolemiddleware["Role authorization<br/>[roleMiddleware.js]"]
  node_async["Async error wrapper<br/>[asyncHandler.js]"]
end

subgraph group_data["Commerce data"]
  node_dbconfig["Mongo connection<br/>[db.js]"]
  node_productmodel[("Product model<br/>[Product.js]")]
  node_ordermodel[("Order model<br/>[Order.js]")]
  node_usermodel[("User model<br/>[User.js]")]
  node_cartmodel[("Cart model<br/>[Cart.js]")]
end

subgraph group_integrations["External services"]
  node_meiliservice["Meilisearch service<br/>[meiliServices.js]"]
  node_meiliconfig["Meilisearch config<br/>[meilisearch.js]"]
  node_redis["Redis caching<br/>[redis.js]"]
  node_cloudinary["Cloudinary uploads<br/>[cloudinary.js]"]
end

node_buyer(("Buyer"))
node_seller(("Seller"))
node_admin(("Admin"))

node_buyer -->|"navigates"| node_routes
node_routes -->|"routes to"| node_buyerfeatures
node_routes -->|"routes to"| node_sellerlayout
node_routes -->|"routes to"| node_adminfeatures
node_authstate -->|"calls"| node_authapi
node_orderdetail -->|"uses"| node_orderstate
node_seller -->|"uses"| node_sellerlayout
node_sellerlayout -->|"hosts"| node_sellerfeatures
node_sellerfeatures -->|"uses"| node_sellerstate
node_admin -->|"uses"| node_adminfeatures
node_buyerfeatures -.->|"requests"| node_http
node_sellerfeatures -.->|"requests"| node_http
node_adminfeatures -.->|"requests"| node_http
node_http -->|"sends HTTP"| node_express
node_express -->|"mounts"| node_productroutes
node_express -->|"mounts"| node_adminroutes
node_productroutes -->|"protects"| node_authmiddleware
node_productroutes -->|"authorizes"| node_rolemiddleware
node_productroutes -->|"dispatches"| node_productcontroller
node_adminroutes -->|"protects"| node_authmiddleware
node_adminroutes -->|"authorizes"| node_rolemiddleware
node_adminroutes -->|"dispatches"| node_admincontroller
node_productcontroller -->|"calls"| node_productservice
node_productcontroller -->|"reads"| node_productmodel
node_admincontroller -->|"calls"| node_adminservice
node_admincontroller -->|"wraps handlers"| node_async
node_productcontroller -->|"wraps handlers"| node_async
node_adminservice -->|"queries"| node_usermodel
node_adminservice -->|"queries"| node_productmodel
node_adminservice -->|"queries"| node_ordermodel
node_orderservice -->|"reads and writes"| node_ordermodel
node_orderservice -->|"reads and clears"| node_cartmodel
node_orderservice -->|"validates stock"| node_productmodel
node_productservice -->|"queries"| node_productmodel
node_productservice -->|"searches"| node_meiliservice
node_meiliservice -->|"uses"| node_meiliconfig
node_meiliservice -->|"indexes"| node_productmodel
node_productservice -.->|"caches"| node_redis
node_express -.->|"uploads images"| node_cloudinary
node_dbconfig -.->|"backs"| node_productmodel
node_dbconfig -.->|"backs"| node_ordermodel
node_dbconfig -.->|"backs"| node_usermodel

click node_routes "https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/routes/AppRoutes.jsx"
click node_authstate "https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/store/authStore.jsx"
click node_authapi "https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/api/authApi.js"
click node_orderdetail "https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/pages/customer/OrderDetailsPage.jsx"
click node_orderstate "https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/store/orderStore.js"
click node_buyerfeatures "https://github.com/hirdeshpal888527/smartcommerce/tree/main/client/src/pages/customer"
click node_sellerlayout "https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/layouts/SellerLayout.jsx"
click node_sellerfeatures "https://github.com/hirdeshpal888527/smartcommerce/tree/main/client/src/pages/seller"
click node_sellerstate "https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/store/sellerStore.js"
click node_adminfeatures "https://github.com/hirdeshpal888527/smartcommerce/tree/main/client/src/pages/admin"
click node_http "https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/api/axios.js"
click node_express "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/app.js"
click node_productroutes "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/routes/productRoutes.js"
click node_adminroutes "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/routes/adminRoutes.js"
click node_productcontroller "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/controllers/productController.js"
click node_admincontroller "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/controllers/adminController.js"
click node_orderservice "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/services/orderServices.js"
click node_productservice "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/services/productServices.js"
click node_adminservice "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/services/adminServices.js"
click node_authmiddleware "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/middlewares/authMiddleware.js"
click node_rolemiddleware "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/middlewares/roleMiddleware.js"
click node_async "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/utils/asyncHandler.js"
click node_dbconfig "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/config/db.js"
click node_productmodel "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/models/Product.js"
click node_ordermodel "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/models/Order.js"
click node_usermodel "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/models/User.js"
click node_cartmodel "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/models/Cart.js"
click node_meiliservice "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/services/meiliServices.js"
click node_meiliconfig "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/config/meilisearch.js"
click node_redis "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/config/redis.js"
click node_cloudinary "https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/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_routes,node_authstate,node_authapi,node_orderdetail,node_orderstate,node_buyerfeatures toneBlue
class node_sellerlayout,node_sellerfeatures,node_sellerstate,node_adminfeatures toneAmber
class node_http,node_express,node_productroutes,node_adminroutes,node_productcontroller,node_admincontroller,node_orderservice,node_productservice,node_adminservice,node_authmiddleware,node_rolemiddleware,node_async toneMint
class node_dbconfig,node_productmodel,node_ordermodel,node_usermodel,node_cartmodel toneRose
class node_meiliservice,node_meiliconfig,node_redis,node_cloudinary,node_buyer,node_seller,node_admin toneIndigo
```

## Components

### Buyer experience

- [App routing](https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/routes/AppRoutes.jsx): `client/src/routes/AppRoutes.jsx`
- [Auth state](https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/store/authStore.jsx): `client/src/store/authStore.jsx`
- [Auth API](https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/api/authApi.js): `client/src/api/authApi.js`
- [Order details](https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/pages/customer/OrderDetailsPage.jsx): `client/src/pages/customer/OrderDetailsPage.jsx`
- [Order state](https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/store/orderStore.js): `client/src/store/orderStore.js`
- [Buyer commerce](https://github.com/hirdeshpal888527/smartcommerce/tree/main/client/src/pages/customer): `client/src/pages/customer`

### Seller and admin

- [Seller portal layout](https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/layouts/SellerLayout.jsx): `client/src/layouts/SellerLayout.jsx`
- [Seller management](https://github.com/hirdeshpal888527/smartcommerce/tree/main/client/src/pages/seller): `client/src/pages/seller`
- [Seller state](https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/store/sellerStore.js): `client/src/store/sellerStore.js`
- [Admin management](https://github.com/hirdeshpal888527/smartcommerce/tree/main/client/src/pages/admin): `client/src/pages/admin`

### Backend request layers

- [Axios API layer](https://github.com/hirdeshpal888527/smartcommerce/blob/main/client/src/api/axios.js): `client/src/api/axios.js`
- [Express app](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/app.js): `server/src/app.js`
- [Product routes](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/routes/productRoutes.js): `server/src/routes/productRoutes.js`
- [Admin routes](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/routes/adminRoutes.js): `server/src/routes/adminRoutes.js`
- [Product controller](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/controllers/productController.js): `server/src/controllers/productController.js`
- [Admin controller](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/controllers/adminController.js): `server/src/controllers/adminController.js`
- [Order service](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/services/orderServices.js): `server/src/services/orderServices.js`
- [Product service](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/services/productServices.js): `server/src/services/productServices.js`
- [Admin service](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/services/adminServices.js): `server/src/services/adminServices.js`
- [JWT authentication](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/middlewares/authMiddleware.js): `server/src/middlewares/authMiddleware.js`
- [Role authorization](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/middlewares/roleMiddleware.js): `server/src/middlewares/roleMiddleware.js`
- [Async error wrapper](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/utils/asyncHandler.js): `server/src/utils/asyncHandler.js`

### Commerce data

- [Mongo connection](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/config/db.js): `server/src/config/db.js`
- [Product model](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/models/Product.js): `server/src/models/Product.js`
- [Order model](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/models/Order.js): `server/src/models/Order.js`
- [User model](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/models/User.js): `server/src/models/User.js`
- [Cart model](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/models/Cart.js): `server/src/models/Cart.js`

### External services

- [Meilisearch service](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/services/meiliServices.js): `server/src/services/meiliServices.js`
- [Meilisearch config](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/config/meilisearch.js): `server/src/config/meilisearch.js`
- [Redis caching](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/config/redis.js): `server/src/config/redis.js`
- [Cloudinary uploads](https://github.com/hirdeshpal888527/smartcommerce/blob/main/server/src/config/cloudinary.js): `server/src/config/cloudinary.js`

### Other components

- **Buyer**
- **Seller**
- **Admin**

## Connections

- Buyer → App routing: navigates (evidence: `client/src/routes/AppRoutes.jsx`)
- App routing → Buyer commerce: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- App routing → Seller portal layout: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- App routing → Admin management: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Auth state → Auth API: calls (evidence: `client/src/store/authStore.jsx`)
- Order details → Order state: uses (evidence: `client/src/pages/customer/OrderDetailsPage.jsx`)
- Seller → Seller portal layout: uses
- Seller portal layout → Seller management: hosts (evidence: `client/src/routes/AppRoutes.jsx`)
- Seller management → Seller state: uses (evidence: `client/src/pages/seller/Dashboard.jsx`)
- Admin → Admin management: uses
- Buyer commerce → Axios API layer: requests (evidence: `README.md`)
- Seller management → Axios API layer: requests (evidence: `README.md`)
- Admin management → Axios API layer: requests (evidence: `README.md`)
- Axios API layer → Express app: sends HTTP (evidence: `README.md`)
- Express app → Product routes: mounts (evidence: `server/src/app.js`)
- Express app → Admin routes: mounts (evidence: `server/src/app.js`)
- Product routes → JWT authentication: protects (evidence: `server/src/routes/productRoutes.js`)
- Product routes → Role authorization: authorizes (evidence: `server/src/routes/productRoutes.js`)
- Product routes → Product controller: dispatches (evidence: `server/src/routes/productRoutes.js`)
- Admin routes → JWT authentication: protects (evidence: `server/src/routes/adminRoutes.js`)
- Admin routes → Role authorization: authorizes (evidence: `server/src/routes/adminRoutes.js`)
- Admin routes → Admin controller: dispatches (evidence: `server/src/routes/adminRoutes.js`)
- Product controller → Product service: calls (evidence: `server/src/controllers/productController.js`)
- Product controller → Product model: reads (evidence: `server/src/controllers/productController.js`)
- Admin controller → Admin service: calls (evidence: `server/src/controllers/adminController.js`)
- Admin controller → Async error wrapper: wraps handlers (evidence: `server/src/controllers/adminController.js`)
- Product controller → Async error wrapper: wraps handlers (evidence: `server/src/controllers/productController.js`)
- Admin service → User model: queries (evidence: `server/src/services/adminServices.js`)
- Admin service → Product model: queries (evidence: `server/src/services/adminServices.js`)
- Admin service → Order model: queries (evidence: `server/src/services/adminServices.js`)
- Order service → Order model: reads and writes (evidence: `server/src/services/orderServices.js`)
- Order service → Cart model: reads and clears (evidence: `server/src/services/orderServices.js`)
- Order service → Product model: validates stock (evidence: `server/src/services/orderServices.js`)
- Product service → Product model: queries (evidence: `server/src/services/productServices.js`)
- Product service → Meilisearch service: searches (evidence: `server/src/services/productServices.js`)
- Meilisearch service → Meilisearch config: uses (evidence: `server/src/services/meiliServices.js`)
- Meilisearch service → Product model: indexes (evidence: `server/src/services/meiliServices.js`)
- Product service → Redis caching: caches (evidence: `server/src/services/productServices.js`)
- Express app → Cloudinary uploads: uploads images (evidence: `README.md`)
- Mongo connection → Product model: backs (evidence: `README.md`)
- Mongo connection → Order model: backs (evidence: `README.md`)
- Mongo connection → User model: backs (evidence: `README.md`)
