# vinodarokiarajv/demart architecture

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

- Interactive diagram: https://gitdiagram.com/vinodarokiarajv/demart
- Repository: https://github.com/vinodarokiarajv/demart

## Overview

DeMart is an e-commerce application with an Express API and browser frontend. The main customer workflow is account access, product discovery, order creation with stock reservation and address geocoding, then Stripe payment and delivery tracking; administrators also manage orders and users. The graph includes AI assistance, location/store capabilities, and persistence as distinct supporting branches. Several controller and service implementations are not excerpted, so their connections are included only where the SOURCE INDEX or shown code supports them.

Main entry points: [`backend/src/server.js`](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/server.js) (API server), [`backend/src/services/paymentService.js`](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/paymentService.js) (Stripe payments), [`backend/src/services/orderService.js`](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/orderService.js) (Order management), [`backend/src/db/db.js`](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/db/db.js) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and access"]
  node_server["API server<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_authmw["Authentication<br/>[authMiddleware.js]"]
  node_adminmw["Admin authorization<br/>[adminMiddleware.js]"]
  node_frontend["Browser storefront<br/>[app.js]"]
  node_adminui["Admin screens<br/>[admin-orders.js]"]
end

subgraph group_commerce["Shopping and orders"]
  node_products["Product catalog<br/>[productService.js]"]
  node_productcontroller["Product API"]
  node_orders["Order management<br/>[orderService.js]"]
  node_ordercontroller["Order API<br/>[orderController.js]"]
  node_inventory["Stock reservations"]
  node_orderstore["Order records<br/>[orderRepository.js]"]
end

subgraph group_fulfillment["Payments and delivery"]
  node_paymentcontroller["Payment API"]
  node_payments["Stripe payments<br/>[paymentService.js]"]
  node_paymentstore["Payment records"]
  node_deliverytracking["Delivery tracking"]
  node_deliverystore["Delivery records"]
  node_trackingstore["Tracking records"]
end

subgraph group_accounts["Accounts and location"]
  node_accounts["Account service<br/>[authService.js]"]
  node_authcontroller["Account API<br/>[authController.js]"]
  node_locations["Location service<br/>[locationService.js]"]
  node_geocoding["Address geocoding"]
  node_geoprovider["Geoapify"]
end

subgraph group_platform["Assistance and data"]
  node_ai["AI responses<br/>[aiService.js]"]
  node_aicontroller["AI assistant API<br/>[aiController.js]"]
  node_database[("PostgreSQL<br/>[db.js]")]
end

node_customer(("Customer"))
node_admin(("Administrator"))

node_customer -.->|"uses"| node_frontend
node_admin -.->|"uses"| node_adminui
node_frontend -.->|"requests"| node_server
node_adminui -.->|"requests"| node_server
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_productcontroller
node_server -->|"mounts"| node_ordercontroller
node_server -->|"mounts"| node_paymentcontroller
node_server -->|"mounts"| node_aicontroller
node_authroutes -->|"routes to"| node_authcontroller
node_authroutes -->|"protects"| node_authmw
node_productcontroller -->|"calls"| node_products
node_ordercontroller -.->|"calls"| node_orders
node_paymentcontroller -->|"calls"| node_payments
node_aicontroller -->|"requests"| node_ai
node_aicontroller -->|"queries"| node_products
node_aicontroller -->|"queries"| node_orders
node_aicontroller -->|"queries"| node_deliverytracking
node_authcontroller -->|"calls"| node_accounts
node_authcontroller -->|"validates location"| node_locations
node_authcontroller -->|"geocodes address"| node_geocoding
node_orders -->|"reads and writes"| node_orderstore
node_orders -->|"reserves stock"| node_inventory
node_orders -->|"geocodes address"| node_geocoding
node_payments -->|"updates"| node_paymentstore
node_payments -->|"updates status"| node_orderstore
node_payments -->|"creates delivery"| node_deliverystore
node_payments -->|"uses reservations"| node_inventory
node_paymentcontroller -->|"records webhook"| node_paymentstore
node_deliverytracking -->|"reads"| node_deliverystore
node_deliverytracking -->|"reads and writes"| node_trackingstore
node_locations -.->|"persists via"| node_database
node_geocoding -->|"delegates"| node_geoprovider
node_geoprovider -.->|"configured via"| node_database
node_accounts -->|"queries"| node_database
node_authmw -->|"checks account"| node_database
node_orders -->|"transacts via"| node_database
node_payments -->|"transacts via"| node_database

click node_server "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/server.js"
click node_authroutes "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/routes/authRoutes.js"
click node_authmw "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/middleware/authMiddleware.js"
click node_adminmw "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/middleware/adminMiddleware.js"
click node_products "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/productService.js"
click node_productcontroller "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/controllers/productController.js"
click node_orders "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/orderService.js"
click node_ordercontroller "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/controllers/orderController.js"
click node_inventory "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/repositories/inventoryReservationRepository.js"
click node_orderstore "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/repositories/orderRepository.js"
click node_paymentcontroller "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/controllers/paymentController.js"
click node_payments "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/paymentService.js"
click node_paymentstore "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/repositories/paymentRepository.js"
click node_deliverytracking "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/deliveryTrackingService.js"
click node_deliverystore "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/repositories/deliveryRepository.js"
click node_trackingstore "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/repositories/deliveryTrackingRepository.js"
click node_accounts "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/authService.js"
click node_authcontroller "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/controllers/authController.js"
click node_locations "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/locationService.js"
click node_geocoding "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/geocodingService.js"
click node_geoprovider "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/providers/geoapifyProvider.js"
click node_ai "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/aiService.js"
click node_aicontroller "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/controllers/aiController.js"
click node_database "https://github.com/vinodarokiarajv/demart/blob/main/backend/src/db/db.js"
click node_frontend "https://github.com/vinodarokiarajv/demart/blob/main/frontend/js/app.js"
click node_adminui "https://github.com/vinodarokiarajv/demart/blob/main/frontend/js/admin-orders.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_server,node_authroutes,node_authmw,node_adminmw,node_frontend,node_adminui toneBlue
class node_products,node_productcontroller,node_orders,node_ordercontroller,node_inventory,node_orderstore toneAmber
class node_paymentcontroller,node_payments,node_paymentstore,node_deliverytracking,node_deliverystore,node_trackingstore toneMint
class node_accounts,node_authcontroller,node_locations,node_geocoding,node_geoprovider toneRose
class node_ai,node_aicontroller,node_database,node_customer,node_admin toneIndigo
```

## Components

### API and access

- [API server](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/server.js): `backend/src/server.js`
- [Auth routes](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/routes/authRoutes.js): `backend/src/routes/authRoutes.js`
- [Authentication](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/middleware/authMiddleware.js): `backend/src/middleware/authMiddleware.js`
- [Admin authorization](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/middleware/adminMiddleware.js): `backend/src/middleware/adminMiddleware.js`
- [Browser storefront](https://github.com/vinodarokiarajv/demart/blob/main/frontend/js/app.js): `frontend/js/app.js`
- [Admin screens](https://github.com/vinodarokiarajv/demart/blob/main/frontend/js/admin-orders.js): `frontend/js/admin-orders.js`

### Shopping and orders

- [Product catalog](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/productService.js): `backend/src/services/productService.js`
- [Product API](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/controllers/productController.js): `backend/src/controllers/productController.js`
- [Order management](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/orderService.js): `backend/src/services/orderService.js`
- [Order API](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/controllers/orderController.js): `backend/src/controllers/orderController.js`
- [Stock reservations](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/repositories/inventoryReservationRepository.js): `backend/src/repositories/inventoryReservationRepository.js`
- [Order records](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/repositories/orderRepository.js): `backend/src/repositories/orderRepository.js`

### Payments and delivery

- [Payment API](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/controllers/paymentController.js): `backend/src/controllers/paymentController.js`
- [Stripe payments](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/paymentService.js): `backend/src/services/paymentService.js`
- [Payment records](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/repositories/paymentRepository.js): `backend/src/repositories/paymentRepository.js`
- [Delivery tracking](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/deliveryTrackingService.js): `backend/src/services/deliveryTrackingService.js`
- [Delivery records](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/repositories/deliveryRepository.js): `backend/src/repositories/deliveryRepository.js`
- [Tracking records](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/repositories/deliveryTrackingRepository.js): `backend/src/repositories/deliveryTrackingRepository.js`

### Accounts and location

- [Account service](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/authService.js): `backend/src/services/authService.js`
- [Account API](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [Location service](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/locationService.js): `backend/src/services/locationService.js`
- [Address geocoding](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/geocodingService.js): `backend/src/services/geocodingService.js`
- [Geoapify](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/providers/geoapifyProvider.js): `backend/src/providers/geoapifyProvider.js`

### Assistance and data

- [AI responses](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/services/aiService.js): `backend/src/services/aiService.js`
- [AI assistant API](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/controllers/aiController.js): `backend/src/controllers/aiController.js`
- [PostgreSQL](https://github.com/vinodarokiarajv/demart/blob/main/backend/src/db/db.js): `backend/src/db/db.js`

### Other components

- **Customer**
- **Administrator**

## Connections

- Customer → Browser storefront: uses
- Administrator → Admin screens: uses
- Browser storefront → API server: requests
- Admin screens → API server: requests
- API server → Auth routes: mounts (evidence: `backend/src/server.js`)
- API server → Product API: mounts (evidence: `backend/src/server.js`)
- API server → Order API: mounts (evidence: `backend/src/server.js`)
- API server → Payment API: mounts (evidence: `backend/src/server.js`)
- API server → AI assistant API: mounts (evidence: `backend/src/server.js`)
- Auth routes → Account API: routes to (evidence: `backend/src/routes/authRoutes.js`)
- Auth routes → Authentication: protects (evidence: `backend/src/routes/authRoutes.js`)
- Product API → Product catalog: calls (evidence: `backend/src/controllers/productController.js`)
- Order API → Order management: calls
- Payment API → Stripe payments: calls (evidence: `backend/src/controllers/paymentController.js`)
- AI assistant API → AI responses: requests (evidence: `backend/src/controllers/aiController.js`)
- AI assistant API → Product catalog: queries (evidence: `backend/src/controllers/aiController.js`)
- AI assistant API → Order management: queries (evidence: `backend/src/controllers/aiController.js`)
- AI assistant API → Delivery tracking: queries (evidence: `backend/src/controllers/aiController.js`)
- Account API → Account service: calls (evidence: `backend/src/controllers/authController.js`)
- Account API → Location service: validates location (evidence: `backend/src/controllers/authController.js`)
- Account API → Address geocoding: geocodes address (evidence: `backend/src/controllers/authController.js`)
- Order management → Order records: reads and writes (evidence: `backend/src/services/orderService.js`)
- Order management → Stock reservations: reserves stock (evidence: `backend/src/services/orderService.js`)
- Order management → Address geocoding: geocodes address (evidence: `backend/src/services/orderService.js`)
- Stripe payments → Payment records: updates (evidence: `backend/src/services/paymentService.js`)
- Stripe payments → Order records: updates status (evidence: `backend/src/services/paymentService.js`)
- Stripe payments → Delivery records: creates delivery (evidence: `backend/src/services/paymentService.js`)
- Stripe payments → Stock reservations: uses reservations (evidence: `backend/src/services/paymentService.js`)
- Payment API → Payment records: records webhook (evidence: `backend/src/controllers/paymentController.js`)
- Delivery tracking → Delivery records: reads (evidence: `backend/src/services/deliveryTrackingService.js`)
- Delivery tracking → Tracking records: reads and writes (evidence: `backend/src/services/deliveryTrackingService.js`)
- Location service → PostgreSQL: persists via
- Address geocoding → Geoapify: delegates (evidence: `backend/src/services/geocodingService.js`)
- Geoapify → PostgreSQL: configured via
- Account service → PostgreSQL: queries (evidence: `backend/src/services/authService.js`)
- Authentication → PostgreSQL: checks account (evidence: `backend/src/middleware/authMiddleware.js`)
- Order management → PostgreSQL: transacts via (evidence: `backend/src/services/orderService.js`)
- Stripe payments → PostgreSQL: transacts via (evidence: `backend/src/services/paymentService.js`)
