# vinay99199/grocery-store architecture

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

- Interactive diagram: https://gitdiagram.com/vinay99199/grocery-store
- Repository: https://github.com/vinay99199/grocery-store

## Overview

This is a grocery e-commerce application. Customers browse products, manage a cart, and submit a checkout; the backend validates stock and delivery eligibility, creates orders, and sends notifications. Customers can then view order status, while administrators manage the catalog and orders. The README also documents product requests, analytics, reviews, wishlists, and delivery OTPs. Source excerpts show the order and review paths; other documented capabilities are represented at their exact tree paths, with uncertain internal links omitted.

Main entry points: [`backend/controllers/orderController.js`](https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/orderController.js) (Order lifecycle), [`frontend/src/services/api.js`](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/services/api.js) (API client), [`frontend/src/routes/AppRoutes.jsx`](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/routes/AppRoutes.jsx) (Page routing), [`frontend/src/pages/AdminDashboard.jsx`](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/pages/AdminDashboard.jsx) (Admin dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Customer and admin UI"]
  node_app["UI entry<br/>[App.jsx]"]
  node_routes["Page routing<br/>[AppRoutes.jsx]"]
  node_authcontext["Authentication state<br/>[AuthContext.jsx]"]
  node_authhook["Auth hook<br/>[useAuth.js]"]
  node_productsui["Product browsing<br/>[Products.jsx]"]
  node_checkoutui["Checkout<br/>[Checkout.jsx]"]
  node_ordersui["Order views<br/>[OrderDetail.jsx]"]
  node_adminui["Admin dashboard<br/>[AdminDashboard.jsx]"]
  node_requestui["Request service<br/>[requestService.js]"]
end

subgraph group_api["API and access"]
  node_apisvc["API client<br/>[api.js]"]
  node_server["Express app<br/>[app.js]"]
  node_authroutes["Authentication routes<br/>[authRoutes.js]"]
  node_authcontroller["Authentication<br/>[authController.js]"]
  node_productroutes["Product routes<br/>[productRoutes.js]"]
  node_userdb[("User records<br/>[User.js]")]
  node_authmw["Authentication gate<br/>[authMiddleware.js]"]
  node_adminmw["Admin gate<br/>[adminMiddleware.js]"]
end

subgraph group_commerce["Catalog and shopping"]
  node_productcontroller["Catalog operations"]
  node_categorycontroller["Category operations"]
  node_cartcontroller["Cart operations<br/>[cartController.js]"]
  node_productmodel[("Product records<br/>[Product.js]")]
  node_categorymodel[("Category records<br/>[Category.js]")]
  node_cartmodel[("Cart records<br/>[Cart.js]")]
  node_wishlist["Wishlist capability"]
  node_requests[("Product requests<br/>[ProductRequest.js]")]
  node_reviews["Product reviews"]
end

subgraph group_fulfillment["Orders and engagement"]
  node_ordercontroller["Order lifecycle<br/>[orderController.js]"]
  node_ordermodel[("Order records<br/>[Order.js]")]
  node_deliveryrules["Delivery pricing<br/>[deliveryRules.js]"]
  node_notificationservice["Notification service"]
  node_notificationmodel[("Notification records<br/>[Notification.js]")]
  node_analytics["Store analytics"]
end

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

node_customer -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"renders"| node_routes
node_routes -->|"checks state"| node_authhook
node_authhook -->|"reads"| node_authcontext
node_routes -->|"routes to"| node_productsui
node_routes -->|"routes to"| node_adminui
node_productsui -.->|"requests data"| node_apisvc
node_checkoutui -.->|"submits order"| node_apisvc
node_ordersui -.->|"requests orders"| node_apisvc
node_adminui -->|"requests admin data"| node_apisvc
node_apisvc -.->|"calls API"| node_server
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_productroutes
node_productroutes -->|"dispatches"| node_productcontroller
node_productcontroller -->|"reads and writes"| node_productmodel
node_productcontroller -->|"uses categories"| node_categorymodel
node_categorycontroller -->|"reads and writes"| node_categorymodel
node_cartcontroller -->|"reads and writes"| node_cartmodel
node_cartcontroller -->|"checks products"| node_productmodel
node_authroutes -->|"dispatches"| node_authcontroller
node_authcontroller -->|"reads and writes"| node_userdb
node_productroutes -->|"protects routes"| node_authmw
node_productroutes -->|"guards admin actions"| node_adminmw
node_adminmw -->|"checks role"| node_userdb
node_ordercontroller -->|"creates and updates"| node_ordermodel
node_ordercontroller -->|"loads and clears"| node_cartmodel
node_ordercontroller -->|"updates purchases"| node_userdb
node_ordercontroller -->|"checks stock"| node_productmodel
node_ordercontroller -->|"calculates charge"| node_deliveryrules
node_ordercontroller -->|"creates alerts"| node_notificationservice
node_notificationservice -->|"saves alerts"| node_notificationmodel
node_reviews -->|"updates reviews"| node_productmodel
node_reviews -->|"checks purchase"| node_ordermodel
node_adminui -.->|"views metrics"| node_analytics
node_adminui -.->|"handles requests"| node_requests
node_requestui -.->|"submits requests"| node_requests
node_customer -.->|"manages wishlist"| node_wishlist

click node_app "https://github.com/vinay99199/grocery-store/blob/main/frontend/src/App.jsx"
click node_routes "https://github.com/vinay99199/grocery-store/blob/main/frontend/src/routes/AppRoutes.jsx"
click node_authcontext "https://github.com/vinay99199/grocery-store/blob/main/frontend/src/context/AuthContext.jsx"
click node_authhook "https://github.com/vinay99199/grocery-store/blob/main/frontend/src/hooks/useAuth.js"
click node_productsui "https://github.com/vinay99199/grocery-store/blob/main/frontend/src/pages/Products.jsx"
click node_checkoutui "https://github.com/vinay99199/grocery-store/blob/main/frontend/src/pages/Checkout.jsx"
click node_ordersui "https://github.com/vinay99199/grocery-store/blob/main/frontend/src/pages/OrderDetail.jsx"
click node_adminui "https://github.com/vinay99199/grocery-store/blob/main/frontend/src/pages/AdminDashboard.jsx"
click node_apisvc "https://github.com/vinay99199/grocery-store/blob/main/frontend/src/services/api.js"
click node_server "https://github.com/vinay99199/grocery-store/blob/main/backend/app.js"
click node_authroutes "https://github.com/vinay99199/grocery-store/blob/main/backend/routes/authRoutes.js"
click node_authcontroller "https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/authController.js"
click node_productroutes "https://github.com/vinay99199/grocery-store/blob/main/backend/routes/productRoutes.js"
click node_productcontroller "https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/productController.js"
click node_categorycontroller "https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/categoryController.js"
click node_cartcontroller "https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/cartController.js"
click node_productmodel "https://github.com/vinay99199/grocery-store/blob/main/backend/models/Product.js"
click node_categorymodel "https://github.com/vinay99199/grocery-store/blob/main/backend/models/Category.js"
click node_cartmodel "https://github.com/vinay99199/grocery-store/blob/main/backend/models/Cart.js"
click node_userdb "https://github.com/vinay99199/grocery-store/blob/main/backend/models/User.js"
click node_authmw "https://github.com/vinay99199/grocery-store/blob/main/backend/middleware/authMiddleware.js"
click node_adminmw "https://github.com/vinay99199/grocery-store/blob/main/backend/middleware/adminMiddleware.js"
click node_ordercontroller "https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/orderController.js"
click node_ordermodel "https://github.com/vinay99199/grocery-store/blob/main/backend/models/Order.js"
click node_deliveryrules "https://github.com/vinay99199/grocery-store/blob/main/backend/utils/deliveryRules.js"
click node_notificationservice "https://github.com/vinay99199/grocery-store/blob/main/backend/services/notificationService.js"
click node_notificationmodel "https://github.com/vinay99199/grocery-store/blob/main/backend/models/Notification.js"
click node_wishlist "https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/wishlistController.js"
click node_requests "https://github.com/vinay99199/grocery-store/blob/main/backend/models/ProductRequest.js"
click node_analytics "https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/analyticsController.js"
click node_reviews "https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/reviewController.js"
click node_requestui "https://github.com/vinay99199/grocery-store/blob/main/frontend/src/services/requestService.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_routes,node_authcontext,node_authhook,node_productsui,node_checkoutui,node_ordersui,node_adminui,node_requestui toneBlue
class node_apisvc,node_server,node_authroutes,node_authcontroller,node_productroutes,node_userdb,node_authmw,node_adminmw toneAmber
class node_productcontroller,node_categorycontroller,node_cartcontroller,node_productmodel,node_categorymodel,node_cartmodel,node_wishlist,node_requests,node_reviews toneMint
class node_ordercontroller,node_ordermodel,node_deliveryrules,node_notificationservice,node_notificationmodel,node_analytics toneRose
class node_customer,node_admin toneIndigo
```

## Components

### Customer and admin UI

- [UI entry](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Page routing](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/routes/AppRoutes.jsx): `frontend/src/routes/AppRoutes.jsx`
- [Authentication state](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Auth hook](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/hooks/useAuth.js): `frontend/src/hooks/useAuth.js`
- [Product browsing](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/pages/Products.jsx): `frontend/src/pages/Products.jsx`
- [Checkout](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/pages/Checkout.jsx): `frontend/src/pages/Checkout.jsx`
- [Order views](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/pages/OrderDetail.jsx): `frontend/src/pages/OrderDetail.jsx`
- [Admin dashboard](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/pages/AdminDashboard.jsx): `frontend/src/pages/AdminDashboard.jsx`
- [Request service](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/services/requestService.js): `frontend/src/services/requestService.js`

### API and access

- [API client](https://github.com/vinay99199/grocery-store/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Express app](https://github.com/vinay99199/grocery-store/blob/main/backend/app.js): `backend/app.js`
- [Authentication routes](https://github.com/vinay99199/grocery-store/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Authentication](https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Product routes](https://github.com/vinay99199/grocery-store/blob/main/backend/routes/productRoutes.js): `backend/routes/productRoutes.js`
- [User records](https://github.com/vinay99199/grocery-store/blob/main/backend/models/User.js): `backend/models/User.js`
- [Authentication gate](https://github.com/vinay99199/grocery-store/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`
- [Admin gate](https://github.com/vinay99199/grocery-store/blob/main/backend/middleware/adminMiddleware.js): `backend/middleware/adminMiddleware.js`

### Catalog and shopping

- [Catalog operations](https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/productController.js): `backend/controllers/productController.js`
- [Category operations](https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/categoryController.js): `backend/controllers/categoryController.js`
- [Cart operations](https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/cartController.js): `backend/controllers/cartController.js`
- [Product records](https://github.com/vinay99199/grocery-store/blob/main/backend/models/Product.js): `backend/models/Product.js`
- [Category records](https://github.com/vinay99199/grocery-store/blob/main/backend/models/Category.js): `backend/models/Category.js`
- [Cart records](https://github.com/vinay99199/grocery-store/blob/main/backend/models/Cart.js): `backend/models/Cart.js`
- [Wishlist capability](https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/wishlistController.js): `backend/controllers/wishlistController.js`
- [Product requests](https://github.com/vinay99199/grocery-store/blob/main/backend/models/ProductRequest.js): `backend/models/ProductRequest.js`
- [Product reviews](https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/reviewController.js): `backend/controllers/reviewController.js`

### Orders and engagement

- [Order lifecycle](https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/orderController.js): `backend/controllers/orderController.js`
- [Order records](https://github.com/vinay99199/grocery-store/blob/main/backend/models/Order.js): `backend/models/Order.js`
- [Delivery pricing](https://github.com/vinay99199/grocery-store/blob/main/backend/utils/deliveryRules.js): `backend/utils/deliveryRules.js`
- [Notification service](https://github.com/vinay99199/grocery-store/blob/main/backend/services/notificationService.js): `backend/services/notificationService.js`
- [Notification records](https://github.com/vinay99199/grocery-store/blob/main/backend/models/Notification.js): `backend/models/Notification.js`
- [Store analytics](https://github.com/vinay99199/grocery-store/blob/main/backend/controllers/analyticsController.js): `backend/controllers/analyticsController.js`

### Other components

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

## Connections

- Customer → UI entry: uses (evidence: `README.md`)
- Administrator → UI entry: uses (evidence: `README.md`)
- UI entry → Page routing: renders (evidence: `frontend/src/App.jsx`)
- Page routing → Auth hook: checks state (evidence: `frontend/src/routes/AppRoutes.jsx`)
- Auth hook → Authentication state: reads (evidence: `frontend/src/hooks/useAuth.js`)
- Page routing → Product browsing: routes to (evidence: `frontend/src/routes/AppRoutes.jsx`)
- Page routing → Admin dashboard: routes to (evidence: `frontend/src/routes/AppRoutes.jsx`)
- Product browsing → API client: requests data
- Checkout → API client: submits order
- Order views → API client: requests orders
- Admin dashboard → API client: requests admin data (evidence: `frontend/src/pages/AdminDashboard.jsx`)
- API client → Express app: calls API
- Express app → Authentication routes: mounts (evidence: `backend/app.js`)
- Express app → Product routes: mounts (evidence: `backend/app.js`)
- Product routes → Catalog operations: dispatches (evidence: `backend/routes/productRoutes.js`)
- Catalog operations → Product records: reads and writes (evidence: `backend/controllers/productController.js`)
- Catalog operations → Category records: uses categories (evidence: `backend/controllers/productController.js`)
- Category operations → Category records: reads and writes (evidence: `backend/controllers/categoryController.js`)
- Cart operations → Cart records: reads and writes (evidence: `backend/controllers/cartController.js`)
- Cart operations → Product records: checks products (evidence: `backend/controllers/cartController.js`)
- Authentication routes → Authentication: dispatches (evidence: `backend/routes/authRoutes.js`)
- Authentication → User records: reads and writes (evidence: `backend/controllers/authController.js`)
- Product routes → Authentication gate: protects routes (evidence: `backend/routes/productRoutes.js`)
- Product routes → Admin gate: guards admin actions (evidence: `backend/routes/productRoutes.js`)
- Admin gate → User records: checks role (evidence: `backend/middleware/adminMiddleware.js`)
- Order lifecycle → Order records: creates and updates (evidence: `backend/controllers/orderController.js`)
- Order lifecycle → Cart records: loads and clears (evidence: `backend/controllers/orderController.js`)
- Order lifecycle → User records: updates purchases (evidence: `backend/controllers/orderController.js`)
- Order lifecycle → Product records: checks stock (evidence: `backend/controllers/orderController.js`)
- Order lifecycle → Delivery pricing: calculates charge (evidence: `backend/controllers/orderController.js`)
- Order lifecycle → Notification service: creates alerts (evidence: `backend/controllers/orderController.js`)
- Notification service → Notification records: saves alerts (evidence: `backend/services/notificationService.js`)
- Product reviews → Product records: updates reviews (evidence: `backend/controllers/reviewController.js`)
- Product reviews → Order records: checks purchase (evidence: `backend/controllers/reviewController.js`)
- Admin dashboard → Store analytics: views metrics
- Admin dashboard → Product requests: handles requests
- Request service → Product requests: submits requests
- Customer → Wishlist capability: manages wishlist
