# sonusatya/grocnest architecture

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

- Interactive diagram: https://gitdiagram.com/sonusatya/grocnest
- Repository: https://github.com/sonusatya/grocnest

## Overview

This is a grocery-commerce and delivery application with a React storefront and an Express/Prisma API. The main documented-in-source workflow is order placement: the API checks products and stock, creates an order, and emits inventory and order events; background functions handle low-stock alerts and rider assignment. Other product capabilities include browsing and deals, account and address management, administration, delivery-partner operations, payments, and live order tracking. Client-side relationships and several route/controller links are not evidenced by the available excerpts, so they are shown without inferred call edges.

Main entry points: [`server/config/prisma.ts`](https://github.com/sonusatya/grocnest/blob/main/server/config/prisma.ts) (Prisma Database), [`server/server.ts`](https://github.com/sonusatya/grocnest/blob/main/server/server.ts) (Express API), [`server/controllers/orderController.ts`](https://github.com/sonusatya/grocnest/blob/main/server/controllers/orderController.ts) (Order Operations), [`server/routes/orderRoutes.ts`](https://github.com/sonusatya/grocnest/blob/main/server/routes/orderRoutes.ts) (Order Routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Customer Storefront"]
  node_storefront_app["Storefront<br/>[App.tsx]"]
  node_catalog_ui["Catalog and Deals<br/>[Products.tsx]"]
  node_product_detail_ui["Product Details<br/>[ProductPage.tsx]"]
  node_cart_checkout_ui["Cart and Checkout<br/>[Checkout.tsx]"]
  node_account_ui["Account and Addresses<br/>[Addresses.tsx]"]
  node_tracking_ui["Order Tracking<br/>[OrderTracking.tsx]"]
  node_admin_ui["Admin Console<br/>[AdminDashboard.tsx]"]
  node_delivery_ui["Delivery Console"]
end

subgraph group_commerce["Commerce API"]
  node_api_server["Express API<br/>[server.ts]"]
  node_product_api["Product Operations"]
  node_account_api["Authentication<br/>[authController.ts]"]
  node_address_api["Address Management"]
  node_order_api["Order Operations<br/>[orderController.ts]"]
  node_payment_webhook["Payment Webhook<br/>[webhooks.ts]"]
  node_db[("Prisma Database<br/>[prisma.ts]")]
  node_order_routes["Order Routes<br/>[orderRoutes.ts]"]
end

subgraph group_operations["Admin and Delivery"]
  node_admin_api["Admin Operations<br/>[adminController.ts]"]
  node_delivery_api["Delivery Operations"]
  node_delivery_routes["Delivery Routes"]
  node_delivery_auth["Delivery Authorization<br/>[deliveryAuth.ts]"]
end

subgraph group_background["Events and Integrations"]
  node_events["Background Workflows<br/>[index.ts]"]
  node_email["Email Delivery<br/>[nodemailer.ts]"]
  node_stripe["Stripe"]
end

node_shopper(("Customer"))

node_api_server -->|"mounts"| node_order_routes
node_api_server -->|"mounts"| node_delivery_routes
node_api_server -->|"routes webhook"| node_payment_webhook
node_order_routes -->|"dispatches"| node_order_api
node_order_routes -->|"authorizes"| node_delivery_auth
node_delivery_routes -->|"dispatches"| node_delivery_api
node_delivery_routes -->|"authorizes"| node_delivery_auth
node_order_api -->|"reads and writes"| node_db
node_order_api -->|"sends events"| node_events
node_delivery_api -->|"reads and writes"| node_db
node_admin_api -->|"reads and writes"| node_db
node_address_api -->|"reads and writes"| node_db
node_product_api -->|"reads and writes"| node_db
node_delivery_auth -->|"checks partner"| node_db
node_payment_webhook -.->|"handles payments"| node_stripe
node_events -->|"reads and writes"| node_db
node_events -->|"sends mail"| node_email

click node_storefront_app "https://github.com/sonusatya/grocnest/blob/main/client/src/App.tsx"
click node_catalog_ui "https://github.com/sonusatya/grocnest/blob/main/client/src/pages/Products.tsx"
click node_product_detail_ui "https://github.com/sonusatya/grocnest/blob/main/client/src/pages/ProductPage.tsx"
click node_cart_checkout_ui "https://github.com/sonusatya/grocnest/blob/main/client/src/pages/Checkout.tsx"
click node_account_ui "https://github.com/sonusatya/grocnest/blob/main/client/src/pages/Addresses.tsx"
click node_tracking_ui "https://github.com/sonusatya/grocnest/blob/main/client/src/pages/OrderTracking.tsx"
click node_admin_ui "https://github.com/sonusatya/grocnest/blob/main/client/src/pages/admin/AdminDashboard.tsx"
click node_delivery_ui "https://github.com/sonusatya/grocnest/blob/main/client/src/pages/delivery/DeliveryDashboard.tsx"
click node_api_server "https://github.com/sonusatya/grocnest/blob/main/server/server.ts"
click node_product_api "https://github.com/sonusatya/grocnest/blob/main/server/controllers/productController.ts"
click node_account_api "https://github.com/sonusatya/grocnest/blob/main/server/controllers/authController.ts"
click node_address_api "https://github.com/sonusatya/grocnest/blob/main/server/controllers/addressController.ts"
click node_order_api "https://github.com/sonusatya/grocnest/blob/main/server/controllers/orderController.ts"
click node_payment_webhook "https://github.com/sonusatya/grocnest/blob/main/server/controllers/webhooks.ts"
click node_admin_api "https://github.com/sonusatya/grocnest/blob/main/server/controllers/adminController.ts"
click node_delivery_api "https://github.com/sonusatya/grocnest/blob/main/server/controllers/deliveryPartnerController.ts"
click node_db "https://github.com/sonusatya/grocnest/blob/main/server/config/prisma.ts"
click node_order_routes "https://github.com/sonusatya/grocnest/blob/main/server/routes/orderRoutes.ts"
click node_delivery_routes "https://github.com/sonusatya/grocnest/blob/main/server/routes/deliveryPartnerRoutes.ts"
click node_delivery_auth "https://github.com/sonusatya/grocnest/blob/main/server/middleware/deliveryAuth.ts"
click node_events "https://github.com/sonusatya/grocnest/blob/main/server/inngest/index.ts"
click node_email "https://github.com/sonusatya/grocnest/blob/main/server/config/nodemailer.ts"

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_storefront_app,node_catalog_ui,node_product_detail_ui,node_cart_checkout_ui,node_account_ui,node_tracking_ui,node_admin_ui,node_delivery_ui toneBlue
class node_api_server,node_product_api,node_account_api,node_address_api,node_order_api,node_payment_webhook,node_db,node_order_routes toneAmber
class node_admin_api,node_delivery_api,node_delivery_routes,node_delivery_auth toneMint
class node_events,node_email,node_stripe toneRose
class node_shopper toneIndigo
```

## Components

### Customer Storefront

- [Storefront](https://github.com/sonusatya/grocnest/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Catalog and Deals](https://github.com/sonusatya/grocnest/blob/main/client/src/pages/Products.tsx): `client/src/pages/Products.tsx`
- [Product Details](https://github.com/sonusatya/grocnest/blob/main/client/src/pages/ProductPage.tsx): `client/src/pages/ProductPage.tsx`
- [Cart and Checkout](https://github.com/sonusatya/grocnest/blob/main/client/src/pages/Checkout.tsx): `client/src/pages/Checkout.tsx`
- [Account and Addresses](https://github.com/sonusatya/grocnest/blob/main/client/src/pages/Addresses.tsx): `client/src/pages/Addresses.tsx`
- [Order Tracking](https://github.com/sonusatya/grocnest/blob/main/client/src/pages/OrderTracking.tsx): `client/src/pages/OrderTracking.tsx`
- [Admin Console](https://github.com/sonusatya/grocnest/blob/main/client/src/pages/admin/AdminDashboard.tsx): `client/src/pages/admin/AdminDashboard.tsx`
- [Delivery Console](https://github.com/sonusatya/grocnest/blob/main/client/src/pages/delivery/DeliveryDashboard.tsx): `client/src/pages/delivery/DeliveryDashboard.tsx`

### Commerce API

- [Express API](https://github.com/sonusatya/grocnest/blob/main/server/server.ts): `server/server.ts`
- [Product Operations](https://github.com/sonusatya/grocnest/blob/main/server/controllers/productController.ts): `server/controllers/productController.ts`
- [Authentication](https://github.com/sonusatya/grocnest/blob/main/server/controllers/authController.ts): `server/controllers/authController.ts`
- [Address Management](https://github.com/sonusatya/grocnest/blob/main/server/controllers/addressController.ts): `server/controllers/addressController.ts`
- [Order Operations](https://github.com/sonusatya/grocnest/blob/main/server/controllers/orderController.ts): `server/controllers/orderController.ts`
- [Payment Webhook](https://github.com/sonusatya/grocnest/blob/main/server/controllers/webhooks.ts): `server/controllers/webhooks.ts`
- [Prisma Database](https://github.com/sonusatya/grocnest/blob/main/server/config/prisma.ts): `server/config/prisma.ts`
- [Order Routes](https://github.com/sonusatya/grocnest/blob/main/server/routes/orderRoutes.ts): `server/routes/orderRoutes.ts`

### Admin and Delivery

- [Admin Operations](https://github.com/sonusatya/grocnest/blob/main/server/controllers/adminController.ts): `server/controllers/adminController.ts`
- [Delivery Operations](https://github.com/sonusatya/grocnest/blob/main/server/controllers/deliveryPartnerController.ts): `server/controllers/deliveryPartnerController.ts`
- [Delivery Routes](https://github.com/sonusatya/grocnest/blob/main/server/routes/deliveryPartnerRoutes.ts): `server/routes/deliveryPartnerRoutes.ts`
- [Delivery Authorization](https://github.com/sonusatya/grocnest/blob/main/server/middleware/deliveryAuth.ts): `server/middleware/deliveryAuth.ts`

### Events and Integrations

- [Background Workflows](https://github.com/sonusatya/grocnest/blob/main/server/inngest/index.ts): `server/inngest/index.ts`
- [Email Delivery](https://github.com/sonusatya/grocnest/blob/main/server/config/nodemailer.ts): `server/config/nodemailer.ts`
- **Stripe**

### Other components

- **Customer**

## Connections

- Express API → Order Routes: mounts (evidence: `server/server.ts`)
- Express API → Delivery Routes: mounts (evidence: `server/server.ts`)
- Express API → Payment Webhook: routes webhook (evidence: `server/server.ts`)
- Order Routes → Order Operations: dispatches (evidence: `server/routes/orderRoutes.ts`)
- Order Routes → Delivery Authorization: authorizes (evidence: `server/routes/orderRoutes.ts`)
- Delivery Routes → Delivery Operations: dispatches (evidence: `server/routes/deliveryPartnerRoutes.ts`)
- Delivery Routes → Delivery Authorization: authorizes (evidence: `server/routes/deliveryPartnerRoutes.ts`)
- Order Operations → Prisma Database: reads and writes (evidence: `server/controllers/orderController.ts`)
- Order Operations → Background Workflows: sends events (evidence: `server/controllers/orderController.ts`)
- Delivery Operations → Prisma Database: reads and writes (evidence: `server/controllers/deliveryPartnerController.ts`)
- Admin Operations → Prisma Database: reads and writes (evidence: `server/controllers/adminController.ts`)
- Address Management → Prisma Database: reads and writes (evidence: `server/controllers/addressController.ts`)
- Product Operations → Prisma Database: reads and writes (evidence: `server/controllers/productController.ts`)
- Delivery Authorization → Prisma Database: checks partner (evidence: `server/middleware/deliveryAuth.ts`)
- Payment Webhook → Stripe: handles payments
- Background Workflows → Prisma Database: reads and writes (evidence: `server/inngest/index.ts`)
- Background Workflows → Email Delivery: sends mail (evidence: `server/inngest/index.ts`)
