# sanjuka2001/sampath-supermart architecture

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

- Interactive diagram: https://gitdiagram.com/sanjuka2001/sampath-supermart
- Repository: https://github.com/sanjuka2001/sampath-supermart

## Overview

This is a grocery-commerce application with a React storefront and seller console backed by an Express API. Shoppers browse products, manage a cart and address, and place COD or Stripe orders; sellers manage listings and review orders. The graph separates client workflows, API routing and domain logic, persistence, and integrations. Edges are limited to relationships shown in excerpts or the source index; several client pages and server subsystems are represented at their known paths because their implementation was not sampled.

Main entry points: [`client/src/App.jsx`](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/App.jsx) (App routing shell), [`server/server.js`](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/server.js) (Express application), [`server/controllers/orderController.js`](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/orderController.js) (Order and payment logic), [`client/src/context/AppContext.jsx`](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/context/AppContext.jsx) (Shared app state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["App routing shell<br/>[App.jsx]"]
  node_context["Shared app state<br/>[AppContext.jsx]"]
  node_catalog_ui["Product browsing<br/>[AllProducts.jsx]"]
  node_product_ui["Product details<br/>[ProductDetails.jsx]"]
  node_cart_ui["Cart and address<br/>[Cart.jsx]"]
  node_orders_ui["Customer orders<br/>[MyOrders.jsx]"]
  node_seller_ui["Seller console<br/>[AddProduct.jsx]"]
  node_user_auth_ui["Customer sign-in<br/>[Login.jsx]"]
  node_seller_auth_ui["Seller sign-in<br/>[SellerLogin.jsx]"]
end

subgraph group_api["API and domain"]
  node_user_routes["User routes<br/>[userRoute.js]"]
  node_product_routes["Product routes<br/>[productRoute.js]"]
  node_cart_routes["Cart routes<br/>[cartRoute.js]"]
  node_address_routes["Address routes<br/>[addressRoute.js]"]
  node_order_routes["Order routes<br/>[orderRoute.js]"]
  node_seller_routes["Seller routes<br/>[sellerRoute.js]"]
  node_product_controller["Catalog logic"]
  node_cart_controller["Cart logic<br/>[cartController.js]"]
  node_address_controller["Address logic"]
  node_order_controller["Order and payment logic<br/>[orderController.js]"]
  node_server["Express application<br/>[server.js]"]
end

subgraph group_identity["Authentication"]
  node_user_controller["User account logic<br/>[userController.js]"]
  node_seller_controller["Seller account logic"]
  node_user_middleware["Customer auth<br/>[authUser.js]"]
  node_seller_middleware["Seller auth<br/>[authSeller.js]"]
end

subgraph group_data["Persistence"]
  node_user_model[("User records<br/>[User.js]")]
  node_product_model[("Product records<br/>[Product.js]")]
  node_order_model[("Order records<br/>[Order.js]")]
  node_address_model[("Address records<br/>[Address.js]")]
  node_db_config["Database connection<br/>[db.js]"]
end

subgraph group_integrations["External services"]
  node_cloudinary["Cloudinary media<br/>[cloudinary.js]"]
  node_stripe["Stripe checkout"]
end

node_shopper(("Shopper"))
node_seller_actor(("Seller"))

node_shopper -->|"uses"| node_app
node_seller_actor -->|"uses"| node_app
node_app -->|"reads state"| node_context
node_app -->|"routes to"| node_catalog_ui
node_app -->|"routes to"| node_product_ui
node_app -->|"routes to"| node_cart_ui
node_app -->|"routes to"| node_orders_ui
node_app -->|"routes to"| node_seller_ui
node_app -->|"renders"| node_user_auth_ui
node_app -->|"routes to"| node_seller_auth_ui
node_context -->|"requests user API"| node_user_routes
node_context -->|"requests catalog API"| node_product_routes
node_context -->|"updates cart"| node_cart_routes
node_server -->|"connects"| node_db_config
node_server -->|"mounts"| node_user_routes
node_server -->|"mounts"| node_seller_routes
node_server -->|"mounts"| node_product_routes
node_server -->|"mounts"| node_cart_routes
node_server -->|"mounts"| node_address_routes
node_server -->|"mounts"| node_order_routes
node_user_routes -->|"dispatches"| node_user_controller
node_user_routes -->|"protects"| node_user_middleware
node_seller_routes -->|"dispatches"| node_seller_controller
node_seller_routes -->|"protects"| node_seller_middleware
node_product_routes -->|"dispatches"| node_product_controller
node_product_routes -->|"protects"| node_seller_middleware
node_cart_routes -->|"dispatches"| node_cart_controller
node_cart_routes -->|"protects"| node_user_middleware
node_address_routes -->|"dispatches"| node_address_controller
node_address_routes -->|"protects"| node_user_middleware
node_order_routes -->|"dispatches"| node_order_controller
node_order_routes -->|"protects"| node_user_middleware
node_order_routes -->|"protects"| node_seller_middleware
node_user_controller -->|"reads and writes"| node_user_model
node_product_controller -->|"reads and writes"| node_product_model
node_product_controller -->|"uploads images"| node_cloudinary
node_cart_controller -->|"updates cart"| node_user_model
node_address_controller -->|"reads and writes"| node_address_model
node_order_controller -->|"prices items"| node_product_model
node_order_controller -->|"creates and queries"| node_order_model
node_order_controller -->|"clears cart"| node_user_model
node_order_controller -->|"creates checkout"| node_stripe
node_server -->|"initializes"| node_cloudinary
node_server -->|"registers webhook"| node_order_controller

click node_app "https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/App.jsx"
click node_context "https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/context/AppContext.jsx"
click node_catalog_ui "https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/pages/AllProducts.jsx"
click node_product_ui "https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/pages/ProductDetails.jsx"
click node_cart_ui "https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/pages/Cart.jsx"
click node_orders_ui "https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/pages/MyOrders.jsx"
click node_seller_ui "https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/pages/seller/AddProduct.jsx"
click node_user_auth_ui "https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/components/Login.jsx"
click node_seller_auth_ui "https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/components/seller/SellerLogin.jsx"
click node_user_routes "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/userRoute.js"
click node_product_routes "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/productRoute.js"
click node_cart_routes "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/cartRoute.js"
click node_address_routes "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/addressRoute.js"
click node_order_routes "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/orderRoute.js"
click node_seller_routes "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/sellerRoute.js"
click node_user_controller "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/userController.js"
click node_seller_controller "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/sellerController.js"
click node_user_middleware "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/middlewares/authUser.js"
click node_seller_middleware "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/middlewares/authSeller.js"
click node_product_controller "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/productController.js"
click node_cart_controller "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/cartController.js"
click node_address_controller "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/addressController.js"
click node_order_controller "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/orderController.js"
click node_user_model "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/models/User.js"
click node_product_model "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/models/Product.js"
click node_order_model "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/models/Order.js"
click node_address_model "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/models/Address.js"
click node_cloudinary "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/configs/cloudinary.js"
click node_server "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/server.js"
click node_db_config "https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/configs/db.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_app,node_context,node_catalog_ui,node_product_ui,node_cart_ui,node_orders_ui,node_seller_ui,node_user_auth_ui,node_seller_auth_ui toneBlue
class node_user_routes,node_product_routes,node_cart_routes,node_address_routes,node_order_routes,node_seller_routes,node_product_controller,node_cart_controller,node_address_controller,node_order_controller,node_server toneAmber
class node_user_controller,node_seller_controller,node_user_middleware,node_seller_middleware toneMint
class node_user_model,node_product_model,node_order_model,node_address_model,node_db_config toneRose
class node_cloudinary,node_stripe,node_shopper,node_seller_actor toneIndigo
```

## Components

### Web application

- [App routing shell](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/App.jsx): `client/src/App.jsx`
- [Shared app state](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/context/AppContext.jsx): `client/src/context/AppContext.jsx`
- [Product browsing](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/pages/AllProducts.jsx): `client/src/pages/AllProducts.jsx`
- [Product details](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/pages/ProductDetails.jsx): `client/src/pages/ProductDetails.jsx`
- [Cart and address](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/pages/Cart.jsx): `client/src/pages/Cart.jsx`
- [Customer orders](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/pages/MyOrders.jsx): `client/src/pages/MyOrders.jsx`
- [Seller console](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/pages/seller/AddProduct.jsx): `client/src/pages/seller/AddProduct.jsx`
- [Customer sign-in](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/components/Login.jsx): `client/src/components/Login.jsx`
- [Seller sign-in](https://github.com/sanjuka2001/sampath-supermart/blob/dev/client/src/components/seller/SellerLogin.jsx): `client/src/components/seller/SellerLogin.jsx`

### API and domain

- [User routes](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/userRoute.js): `server/routes/userRoute.js`
- [Product routes](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/productRoute.js): `server/routes/productRoute.js`
- [Cart routes](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/cartRoute.js): `server/routes/cartRoute.js`
- [Address routes](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/addressRoute.js): `server/routes/addressRoute.js`
- [Order routes](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/orderRoute.js): `server/routes/orderRoute.js`
- [Seller routes](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/routes/sellerRoute.js): `server/routes/sellerRoute.js`
- [Catalog logic](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/productController.js): `server/controllers/productController.js`
- [Cart logic](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/cartController.js): `server/controllers/cartController.js`
- [Address logic](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/addressController.js): `server/controllers/addressController.js`
- [Order and payment logic](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/orderController.js): `server/controllers/orderController.js`
- [Express application](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/server.js): `server/server.js`

### Authentication

- [User account logic](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/userController.js): `server/controllers/userController.js`
- [Seller account logic](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/controllers/sellerController.js): `server/controllers/sellerController.js`
- [Customer auth](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/middlewares/authUser.js): `server/middlewares/authUser.js`
- [Seller auth](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/middlewares/authSeller.js): `server/middlewares/authSeller.js`

### Persistence

- [User records](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/models/User.js): `server/models/User.js`
- [Product records](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/models/Product.js): `server/models/Product.js`
- [Order records](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/models/Order.js): `server/models/Order.js`
- [Address records](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/models/Address.js): `server/models/Address.js`
- [Database connection](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/configs/db.js): `server/configs/db.js`

### External services

- [Cloudinary media](https://github.com/sanjuka2001/sampath-supermart/blob/dev/server/configs/cloudinary.js): `server/configs/cloudinary.js`
- **Stripe checkout**

### Other components

- **Shopper**
- **Seller**

## Connections

- Shopper → App routing shell: uses (evidence: `client/src/App.jsx`)
- Seller → App routing shell: uses (evidence: `client/src/App.jsx`)
- App routing shell → Shared app state: reads state (evidence: `client/src/App.jsx`)
- App routing shell → Product browsing: routes to (evidence: `client/src/App.jsx`)
- App routing shell → Product details: routes to (evidence: `client/src/App.jsx`)
- App routing shell → Cart and address: routes to (evidence: `client/src/App.jsx`)
- App routing shell → Customer orders: routes to (evidence: `client/src/App.jsx`)
- App routing shell → Seller console: routes to (evidence: `client/src/App.jsx`)
- App routing shell → Customer sign-in: renders (evidence: `client/src/App.jsx`)
- App routing shell → Seller sign-in: routes to (evidence: `client/src/App.jsx`)
- Shared app state → User routes: requests user API (evidence: `client/src/context/AppContext.jsx`)
- Shared app state → Product routes: requests catalog API (evidence: `client/src/context/AppContext.jsx`)
- Shared app state → Cart routes: updates cart (evidence: `client/src/context/AppContext.jsx`)
- Express application → Database connection: connects (evidence: `server/server.js`)
- Express application → User routes: mounts (evidence: `server/server.js`)
- Express application → Seller routes: mounts (evidence: `server/server.js`)
- Express application → Product routes: mounts (evidence: `server/server.js`)
- Express application → Cart routes: mounts (evidence: `server/server.js`)
- Express application → Address routes: mounts (evidence: `server/server.js`)
- Express application → Order routes: mounts (evidence: `server/server.js`)
- User routes → User account logic: dispatches (evidence: `server/routes/userRoute.js`)
- User routes → Customer auth: protects (evidence: `server/routes/userRoute.js`)
- Seller routes → Seller account logic: dispatches (evidence: `server/routes/sellerRoute.js`)
- Seller routes → Seller auth: protects (evidence: `server/routes/sellerRoute.js`)
- Product routes → Catalog logic: dispatches (evidence: `server/routes/productRoute.js`)
- Product routes → Seller auth: protects (evidence: `server/routes/productRoute.js`)
- Cart routes → Cart logic: dispatches (evidence: `server/routes/cartRoute.js`)
- Cart routes → Customer auth: protects (evidence: `server/routes/cartRoute.js`)
- Address routes → Address logic: dispatches (evidence: `server/routes/addressRoute.js`)
- Address routes → Customer auth: protects (evidence: `server/routes/addressRoute.js`)
- Order routes → Order and payment logic: dispatches (evidence: `server/routes/orderRoute.js`)
- Order routes → Customer auth: protects (evidence: `server/routes/orderRoute.js`)
- Order routes → Seller auth: protects (evidence: `server/routes/orderRoute.js`)
- User account logic → User records: reads and writes (evidence: `server/controllers/userController.js`)
- Catalog logic → Product records: reads and writes (evidence: `server/controllers/productController.js`)
- Catalog logic → Cloudinary media: uploads images (evidence: `server/controllers/productController.js`)
- Cart logic → User records: updates cart (evidence: `server/controllers/cartController.js`)
- Address logic → Address records: reads and writes (evidence: `server/controllers/addressController.js`)
- Order and payment logic → Product records: prices items (evidence: `server/controllers/orderController.js`)
- Order and payment logic → Order records: creates and queries (evidence: `server/controllers/orderController.js`)
- Order and payment logic → User records: clears cart (evidence: `server/controllers/orderController.js`)
- Order and payment logic → Stripe checkout: creates checkout (evidence: `server/controllers/orderController.js`)
- Express application → Cloudinary media: initializes (evidence: `server/server.js`)
- Express application → Order and payment logic: registers webhook (evidence: `server/server.js`)
