# varunbabburi/sujamart architecture

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

- Interactive diagram: https://gitdiagram.com/varunbabburi/sujamart
- Repository: https://github.com/varunbabburi/sujamart

## Overview

SujaMart is a grocery-commerce application with customer shopping and ordering, account and address management, and administrative operations for catalog, orders, payments, customers, and credit. Customers authenticate, browse products, manage a cart, and place and track orders; administrators manage the store through a separate routed interface. The backend exposes these functions through Express routes and MySQL-backed controllers, with OTP SMS and Socket.IO updates as integrations. Several paths are represented at their directory level because their source was not sampled; frontend-to-backend HTTP wiring is not shown and is marked unverified.

Main entry points: [`backend/routes`](https://github.com/varunbabburi/sujamart/tree/main/backend/routes) (API route modules), [`frontend/src/App.jsx`](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/App.jsx) (Web app routes), [`frontend/src/services/api.js`](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/services/api.js) (HTTP client), [`backend/config/db.js`](https://github.com/varunbabburi/sujamart/blob/main/backend/config/db.js) (MySQL pool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer shopping"]
  node_app["Web app routes<br/>[App.jsx]"]
  node_products["Product browsing<br/>[Products.jsx]"]
  node_cart["Cart and checkout<br/>[Cart.jsx]"]
  node_orders["Order history<br/>[Orders.jsx]"]
  node_orderdetails["Order details<br/>[OrderDetails.jsx]"]
  node_account["Account and addresses"]
  node_ledger["Credit ledger<br/>[Ledger.jsx]"]
  node_navbar["Navigation and updates<br/>[Navbar.jsx]"]
end

subgraph group_admin["Store administration"]
  node_adminui["Admin console"]
  node_admincatalog["Catalog management<br/>[Products.jsx]"]
  node_categoriesui["Category management<br/>[Categories.jsx]"]
  node_adminorders["Order operations<br/>[Orders.jsx]"]
  node_admincredit["Customer and credit ops<br/>[CreditAccounts.jsx]"]
end

subgraph group_backend["Backend services"]
  node_api["HTTP client<br/>[api.js]"]
  node_server["HTTP application<br/>[server.js]"]
  node_routes["API route modules"]
  node_cartctrl["Cart operations<br/>[cartController.js]"]
  node_orderctrl["Order processing<br/>[orderController.js]"]
  node_productctrl["Product catalog"]
  node_categoryctrl["Category operations"]
  node_adminctrl["Admin operations<br/>[adminController.js]"]
  node_otpctrl["OTP authentication<br/>[otpController.js]"]
  node_otherctrl["Account and payment services"]
  node_authmw["Token verification<br/>[authMiddleware.js]"]
  node_adminmw["Admin authorization<br/>[adminMiddleware.js]"]
  node_uploadmw["Image uploads"]
  node_validmw["Request validation<br/>[validate.js]"]
  node_database[("MySQL pool<br/>[db.js]")]
  node_logger["Event logging<br/>[logger.js]"]
end

subgraph group_integrations["Realtime and external"]
  node_socket["Socket.IO updates<br/>[server.js]"]
  node_sms["Fast2SMS"]
  node_razorpay["Razorpay payments<br/>[razorpay.js]"]
end

node_shopper(("Shopper"))

node_shopper -->|"uses"| node_app
node_app -->|"routes to"| node_products
node_app -->|"routes to"| node_cart
node_app -->|"routes to"| node_orders
node_app -->|"routes to"| node_orderdetails
node_app -->|"routes to"| node_account
node_app -->|"routes to"| node_ledger
node_app -->|"routes to"| node_adminui
node_products -->|"requests data"| node_api
node_cart -->|"requests data"| node_api
node_orders -.->|"requests data"| node_api
node_orderdetails -.->|"requests data"| node_api
node_admincatalog -->|"requests data"| node_api
node_categoriesui -->|"requests data"| node_api
node_adminui -.->|"requests data"| node_api
node_navbar -->|"requests data"| node_api
node_api -.->|"calls API"| node_server
node_server -->|"mounts routes"| node_routes
node_routes -->|"verifies token"| node_authmw
node_routes -->|"checks role"| node_adminmw
node_routes -->|"processes images"| node_uploadmw
node_routes -->|"validates input"| node_validmw
node_routes -->|"dispatches"| node_cartctrl
node_routes -->|"dispatches"| node_orderctrl
node_routes -->|"dispatches"| node_productctrl
node_routes -->|"dispatches"| node_categoryctrl
node_routes -->|"dispatches"| node_adminctrl
node_routes -->|"dispatches"| node_otpctrl
node_routes -.->|"dispatches"| node_otherctrl
node_cartctrl -->|"reads and writes"| node_database
node_orderctrl -->|"reads and writes"| node_database
node_productctrl -->|"reads and writes"| node_database
node_categoryctrl -->|"reads and writes"| node_database
node_adminctrl -->|"queries"| node_database
node_otpctrl -->|"reads and writes"| node_database
node_adminctrl -->|"logs events"| node_logger
node_orderctrl -->|"logs events"| node_logger
node_server -->|"hosts"| node_socket
node_orderctrl -->|"emits order event"| node_socket
node_adminctrl -->|"emits status update"| node_socket
node_otpctrl -->|"sends OTP"| node_sms
node_orderctrl -.->|"records payment IDs"| node_razorpay

click node_app "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/App.jsx"
click node_products "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/Products.jsx"
click node_cart "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/Cart.jsx"
click node_orders "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/Orders.jsx"
click node_orderdetails "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/OrderDetails.jsx"
click node_account "https://github.com/varunbabburi/sujamart/tree/main/frontend/src/pages"
click node_ledger "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/Ledger.jsx"
click node_navbar "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/components/Navbar.jsx"
click node_api "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/services/api.js"
click node_adminui "https://github.com/varunbabburi/sujamart/tree/main/frontend/src/pages/admin"
click node_admincatalog "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/admin/Products.jsx"
click node_categoriesui "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/admin/Categories.jsx"
click node_adminorders "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/admin/Orders.jsx"
click node_admincredit "https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/admin/CreditAccounts.jsx"
click node_server "https://github.com/varunbabburi/sujamart/blob/main/backend/server.js"
click node_routes "https://github.com/varunbabburi/sujamart/tree/main/backend/routes"
click node_cartctrl "https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/cartController.js"
click node_orderctrl "https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/orderController.js"
click node_productctrl "https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/productController.js"
click node_categoryctrl "https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/categoryController.js"
click node_adminctrl "https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/adminController.js"
click node_otpctrl "https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/otpController.js"
click node_otherctrl "https://github.com/varunbabburi/sujamart/tree/main/backend/controllers"
click node_authmw "https://github.com/varunbabburi/sujamart/blob/main/backend/middleware/authMiddleware.js"
click node_adminmw "https://github.com/varunbabburi/sujamart/blob/main/backend/middleware/adminMiddleware.js"
click node_uploadmw "https://github.com/varunbabburi/sujamart/blob/main/backend/middleware/uploadMiddleware.js"
click node_validmw "https://github.com/varunbabburi/sujamart/blob/main/backend/middleware/validate.js"
click node_database "https://github.com/varunbabburi/sujamart/blob/main/backend/config/db.js"
click node_logger "https://github.com/varunbabburi/sujamart/blob/main/backend/utils/logger.js"
click node_socket "https://github.com/varunbabburi/sujamart/blob/main/backend/server.js"
click node_razorpay "https://github.com/varunbabburi/sujamart/blob/main/backend/config/razorpay.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_products,node_cart,node_orders,node_orderdetails,node_account,node_ledger,node_navbar toneBlue
class node_adminui,node_admincatalog,node_categoriesui,node_adminorders,node_admincredit toneAmber
class node_api,node_server,node_routes,node_cartctrl,node_orderctrl,node_productctrl,node_categoryctrl,node_adminctrl,node_otpctrl,node_otherctrl,node_authmw,node_adminmw,node_uploadmw,node_validmw,node_database,node_logger toneMint
class node_socket,node_sms,node_razorpay toneRose
class node_shopper toneIndigo
```

## Components

### Customer shopping

- [Web app routes](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Product browsing](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/Products.jsx): `frontend/src/pages/Products.jsx`
- [Cart and checkout](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/Cart.jsx): `frontend/src/pages/Cart.jsx`
- [Order history](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/Orders.jsx): `frontend/src/pages/Orders.jsx`
- [Order details](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/OrderDetails.jsx): `frontend/src/pages/OrderDetails.jsx`
- [Account and addresses](https://github.com/varunbabburi/sujamart/tree/main/frontend/src/pages): `frontend/src/pages`
- [Credit ledger](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/Ledger.jsx): `frontend/src/pages/Ledger.jsx`
- [Navigation and updates](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`

### Store administration

- [Admin console](https://github.com/varunbabburi/sujamart/tree/main/frontend/src/pages/admin): `frontend/src/pages/admin`
- [Catalog management](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/admin/Products.jsx): `frontend/src/pages/admin/Products.jsx`
- [Category management](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/admin/Categories.jsx): `frontend/src/pages/admin/Categories.jsx`
- [Order operations](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/admin/Orders.jsx): `frontend/src/pages/admin/Orders.jsx`
- [Customer and credit ops](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/pages/admin/CreditAccounts.jsx): `frontend/src/pages/admin/CreditAccounts.jsx`

### Backend services

- [HTTP client](https://github.com/varunbabburi/sujamart/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [HTTP application](https://github.com/varunbabburi/sujamart/blob/main/backend/server.js): `backend/server.js`
- [API route modules](https://github.com/varunbabburi/sujamart/tree/main/backend/routes): `backend/routes`
- [Cart operations](https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/cartController.js): `backend/controllers/cartController.js`
- [Order processing](https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/orderController.js): `backend/controllers/orderController.js`
- [Product catalog](https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/productController.js): `backend/controllers/productController.js`
- [Category operations](https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/categoryController.js): `backend/controllers/categoryController.js`
- [Admin operations](https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/adminController.js): `backend/controllers/adminController.js`
- [OTP authentication](https://github.com/varunbabburi/sujamart/blob/main/backend/controllers/otpController.js): `backend/controllers/otpController.js`
- [Account and payment services](https://github.com/varunbabburi/sujamart/tree/main/backend/controllers): `backend/controllers`
- [Token verification](https://github.com/varunbabburi/sujamart/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`
- [Admin authorization](https://github.com/varunbabburi/sujamart/blob/main/backend/middleware/adminMiddleware.js): `backend/middleware/adminMiddleware.js`
- [Image uploads](https://github.com/varunbabburi/sujamart/blob/main/backend/middleware/uploadMiddleware.js): `backend/middleware/uploadMiddleware.js`
- [Request validation](https://github.com/varunbabburi/sujamart/blob/main/backend/middleware/validate.js): `backend/middleware/validate.js`
- [MySQL pool](https://github.com/varunbabburi/sujamart/blob/main/backend/config/db.js): `backend/config/db.js`
- [Event logging](https://github.com/varunbabburi/sujamart/blob/main/backend/utils/logger.js): `backend/utils/logger.js`

### Realtime and external

- [Socket.IO updates](https://github.com/varunbabburi/sujamart/blob/main/backend/server.js): `backend/server.js`
- **Fast2SMS**
- [Razorpay payments](https://github.com/varunbabburi/sujamart/blob/main/backend/config/razorpay.js): `backend/config/razorpay.js`

### Other components

- **Shopper**

## Connections

- Shopper → Web app routes: uses
- Web app routes → Product browsing: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Cart and checkout: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Order history: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Order details: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Account and addresses: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Credit ledger: routes to (evidence: `frontend/src/App.jsx`)
- Web app routes → Admin console: routes to (evidence: `frontend/src/App.jsx`)
- Product browsing → HTTP client: requests data (evidence: `frontend/src/pages/Products.jsx`)
- Cart and checkout → HTTP client: requests data (evidence: `frontend/src/pages/Cart.jsx`)
- Order history → HTTP client: requests data
- Order details → HTTP client: requests data
- Catalog management → HTTP client: requests data (evidence: `frontend/src/pages/admin/Products.jsx`)
- Category management → HTTP client: requests data (evidence: `frontend/src/pages/admin/Categories.jsx`)
- Admin console → HTTP client: requests data (evidence: `frontend/src/pages/admin/Products.jsx`)
- Navigation and updates → HTTP client: requests data (evidence: `frontend/src/components/Navbar.jsx`)
- HTTP client → HTTP application: calls API
- HTTP application → API route modules: mounts routes (evidence: `backend/server.js`)
- API route modules → Token verification: verifies token (evidence: `backend/routes/cartRoutes.js`)
- API route modules → Admin authorization: checks role (evidence: `backend/routes/adminRoutes.js`)
- API route modules → Image uploads: processes images (evidence: `backend/routes/productRoutes.js`)
- API route modules → Request validation: validates input (evidence: `backend/routes/cartRoutes.js`)
- API route modules → Cart operations: dispatches (evidence: `backend/routes/cartRoutes.js`)
- API route modules → Order processing: dispatches (evidence: `backend/routes/orderRoutes.js`)
- API route modules → Product catalog: dispatches (evidence: `backend/routes/productRoutes.js`)
- API route modules → Category operations: dispatches (evidence: `backend/routes/categoryRoutes.js`)
- API route modules → Admin operations: dispatches (evidence: `backend/routes/adminRoutes.js`)
- API route modules → OTP authentication: dispatches (evidence: `backend/routes/otpRoutes.js`)
- API route modules → Account and payment services: dispatches (evidence: `backend/routes/adminRoutes.js`)
- Cart operations → MySQL pool: reads and writes (evidence: `backend/controllers/cartController.js`)
- Order processing → MySQL pool: reads and writes (evidence: `backend/controllers/orderController.js`)
- Product catalog → MySQL pool: reads and writes (evidence: `backend/controllers/productController.js`)
- Category operations → MySQL pool: reads and writes (evidence: `backend/controllers/categoryController.js`)
- Admin operations → MySQL pool: queries (evidence: `backend/controllers/adminController.js`)
- OTP authentication → MySQL pool: reads and writes (evidence: `backend/controllers/otpController.js`)
- Admin operations → Event logging: logs events (evidence: `backend/controllers/adminController.js`)
- Order processing → Event logging: logs events (evidence: `backend/controllers/orderController.js`)
- HTTP application → Socket.IO updates: hosts (evidence: `backend/server.js`)
- Order processing → Socket.IO updates: emits order event (evidence: `backend/controllers/orderController.js`)
- Admin operations → Socket.IO updates: emits status update (evidence: `backend/controllers/adminController.js`)
- OTP authentication → Fast2SMS: sends OTP (evidence: `backend/controllers/otpController.js`)
- Order processing → Razorpay payments: records payment IDs
