# muhammadjunaidfarooq/grocery-delivery-app architecture

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

- Interactive diagram: https://gitdiagram.com/muhammadjunaidfarooq/grocery-delivery-app
- Repository: https://github.com/muhammadjunaidfarooq/grocery-delivery-app

## Overview

OmniMart is a role-based grocery delivery app. Customers browse and order groceries, admins manage products and dispatch orders, and riders accept jobs, share location, chat, and complete deliveries. The map emphasizes those user journeys, with authentication, pricing, persistence, and realtime messaging as supporting layers. The README documents the separate Socket.IO server and its HTTP/event relationships; source-index references support several API-to-helper links. Some routes and UI components were not sampled, so their internal call paths are omitted.

Main entry points: [`src/app/api/user/payment/route.ts`](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/user/payment/route.ts) (Online payment), [`src/app/api/admin/add-grocery/route.ts`](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/admin/add-grocery/route.ts) (Product management), [`src/app/api/admin/update-order-status/[orderId]/route.ts`](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/admin/update-order-status/%5BorderId%5D/route.ts) (Order dispatch), [`src/models/order.model.ts`](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/models/order.model.ts) (Order records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer ordering"]
  node_storefront["Storefront<br/>[page.tsx]"]
  node_catalog["Grocery catalog<br/>[route.ts]"]
  node_cart["Persistent cart<br/>[cartSlice.ts]"]
  node_checkout["Checkout flow<br/>[page.tsx]"]
  node_order_api["Order creation<br/>[route.ts]"]
  node_payment_api["Online payment<br/>[route.ts]"]
  node_tracking["Order tracking<br/>[page.tsx]"]
end

subgraph group_operations["Admin operations"]
  node_admin_ui["Admin console"]
  node_product_admin["Product management<br/>[route.ts]"]
  node_order_admin["Order dispatch<br/>[route.ts]"]
  node_dashboard_api["Sales dashboard<br/>[route.ts]"]
end

subgraph group_delivery["Rider delivery"]
  node_rider_ui["Rider dashboard"]
  node_delivery_api["Assignment actions<br/>[route.ts]"]
  node_live_map["Live map<br/>[LiveMap.tsx]"]
  node_chat["Delivery chat<br/>[DeliveryChat.tsx]"]
end

subgraph group_platform["Application platform"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_authorization["Role checks<br/>[requireAuth.ts]"]
  node_pricing["Order pricing<br/>[orderPricing.ts]"]
  node_events["Event notifier"]
  node_user_model["User records<br/>[user.model.ts]"]
  node_grocery_model["Grocery records<br/>[grocery.model.ts]"]
  node_order_model["Order records<br/>[order.model.ts]"]
  node_assignment_model["Delivery assignments"]
end

node_browser(("Browser users"))
node_socket["Socket.IO server"]
node_mongo[("MongoDB")]
node_stripe["Stripe Checkout"]
node_cloudinary["Cloudinary images"]

node_browser -->|"browses"| node_storefront
node_browser -->|"checks out"| node_checkout
node_browser -->|"manages"| node_admin_ui
node_browser -->|"delivers"| node_rider_ui
node_storefront -.->|"loads products"| node_catalog
node_browser -->|"updates"| node_cart
node_checkout -->|"places COD order"| node_order_api
node_checkout -->|"starts payment"| node_payment_api
node_order_api -->|"prices items"| node_pricing
node_payment_api -->|"prices items"| node_pricing
node_payment_api -->|"creates session"| node_stripe
node_payment_api -->|"creates order"| node_order_model
node_browser -->|"tracks order"| node_tracking
node_admin_ui -->|"loads metrics"| node_dashboard_api
node_dashboard_api -->|"aggregates orders"| node_order_model
node_dashboard_api -->|"counts customers"| node_user_model
node_admin_ui -.->|"manages products"| node_product_admin
node_product_admin -->|"writes products"| node_grocery_model
node_product_admin -.->|"uploads images"| node_cloudinary
node_admin_ui -.->|"dispatches orders"| node_order_admin
node_order_admin -->|"updates status"| node_order_model
node_order_admin -->|"finds nearby riders"| node_user_model
node_order_admin -->|"creates offers"| node_assignment_model
node_order_admin -->|"notifies changes"| node_events
node_events -->|"posts events"| node_socket
node_socket -->|"broadcasts updates"| node_browser
node_rider_ui -.->|"accepts jobs"| node_delivery_api
node_rider_ui -->|"shows location"| node_live_map
node_rider_ui -->|"exchanges messages"| node_chat
node_browser -->|"connects directly"| node_socket
node_socket -.->|"saves messages"| node_order_model
node_auth -->|"loads identity"| node_user_model
node_authorization -->|"checks session"| node_auth
node_order_api -->|"checks role"| node_authorization
node_payment_api -->|"checks role"| node_authorization
node_product_admin -->|"checks role"| node_authorization
node_order_api -->|"stores order"| node_order_model
node_product_admin -->|"validates options"| node_grocery_model
node_chat -->|"sends chat"| node_socket

click node_storefront "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/page.tsx"
click node_catalog "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/admin/groceries/route.ts"
click node_cart "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/redux/cartSlice.ts"
click node_checkout "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/user/checkout/page.tsx"
click node_order_api "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/user/order/route.ts"
click node_payment_api "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/user/payment/route.ts"
click node_tracking "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/user/track-order/%5BorderId%5D/page.tsx"
click node_admin_ui "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/components/AdminDashboardClient.tsx"
click node_product_admin "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/admin/add-grocery/route.ts"
click node_order_admin "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/admin/update-order-status/%5BorderId%5D/route.ts"
click node_dashboard_api "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/admin/dashboard/route.ts"
click node_rider_ui "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/components/DeliveryBoysDashboard.tsx"
click node_delivery_api "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/delivery/assignment/%5Bid%5D/accept-assignment/route.ts"
click node_live_map "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/components/LiveMap.tsx"
click node_chat "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/components/DeliveryChat.tsx"
click node_auth "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/auth.ts"
click node_authorization "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/lib/requireAuth.ts"
click node_pricing "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/lib/orderPricing.ts"
click node_events "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/lib/emitEventHandler.ts"
click node_user_model "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/models/user.model.ts"
click node_grocery_model "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/models/grocery.model.ts"
click node_order_model "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/models/order.model.ts"
click node_assignment_model "https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/models/deliveryAssignment.model.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,node_catalog,node_cart,node_checkout,node_order_api,node_payment_api,node_tracking,node_browser toneBlue
class node_admin_ui,node_product_admin,node_order_admin,node_dashboard_api,node_mongo toneAmber
class node_rider_ui,node_delivery_api,node_live_map,node_chat,node_socket toneMint
class node_auth,node_authorization,node_pricing,node_events,node_user_model,node_grocery_model,node_order_model,node_assignment_model toneRose
class node_stripe,node_cloudinary toneIndigo
```

## Components

### Customer ordering

- [Storefront](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Grocery catalog](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/admin/groceries/route.ts): `src/app/api/admin/groceries/route.ts`
- [Persistent cart](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/redux/cartSlice.ts): `src/redux/cartSlice.ts`
- [Checkout flow](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/user/checkout/page.tsx): `src/app/user/checkout/page.tsx`
- [Order creation](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/user/order/route.ts): `src/app/api/user/order/route.ts`
- [Online payment](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/user/payment/route.ts): `src/app/api/user/payment/route.ts`
- [Order tracking](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/user/track-order/%5BorderId%5D/page.tsx): `src/app/user/track-order/[orderId]/page.tsx`

### Admin operations

- [Admin console](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/components/AdminDashboardClient.tsx): `src/components/AdminDashboardClient.tsx`
- [Product management](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/admin/add-grocery/route.ts): `src/app/api/admin/add-grocery/route.ts`
- [Order dispatch](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/admin/update-order-status/%5BorderId%5D/route.ts): `src/app/api/admin/update-order-status/[orderId]/route.ts`
- [Sales dashboard](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/admin/dashboard/route.ts): `src/app/api/admin/dashboard/route.ts`

### Rider delivery

- [Rider dashboard](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/components/DeliveryBoysDashboard.tsx): `src/components/DeliveryBoysDashboard.tsx`
- [Assignment actions](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/app/api/delivery/assignment/%5Bid%5D/accept-assignment/route.ts): `src/app/api/delivery/assignment/[id]/accept-assignment/route.ts`
- [Live map](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/components/LiveMap.tsx): `src/components/LiveMap.tsx`
- [Delivery chat](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/components/DeliveryChat.tsx): `src/components/DeliveryChat.tsx`

### Application platform

- [Authentication](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/auth.ts): `src/auth.ts`
- [Role checks](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/lib/requireAuth.ts): `src/lib/requireAuth.ts`
- [Order pricing](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/lib/orderPricing.ts): `src/lib/orderPricing.ts`
- [Event notifier](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/lib/emitEventHandler.ts): `src/lib/emitEventHandler.ts`
- [User records](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/models/user.model.ts): `src/models/user.model.ts`
- [Grocery records](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/models/grocery.model.ts): `src/models/grocery.model.ts`
- [Order records](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/models/order.model.ts): `src/models/order.model.ts`
- [Delivery assignments](https://github.com/muhammadjunaidfarooq/grocery-delivery-app/blob/main/src/models/deliveryAssignment.model.ts): `src/models/deliveryAssignment.model.ts`

### Other components

- **Browser users**
- **Socket.IO server**
- **MongoDB**
- **Stripe Checkout**
- **Cloudinary images**

## Connections

- Browser users → Storefront: browses
- Browser users → Checkout flow: checks out
- Browser users → Admin console: manages
- Browser users → Rider dashboard: delivers
- Storefront → Grocery catalog: loads products
- Browser users → Persistent cart: updates
- Checkout flow → Order creation: places COD order
- Checkout flow → Online payment: starts payment
- Order creation → Order pricing: prices items (evidence: `src/app/api/user/order/route.ts`)
- Online payment → Order pricing: prices items (evidence: `src/app/api/user/payment/route.ts`)
- Online payment → Stripe Checkout: creates session (evidence: `src/app/api/user/payment/route.ts`)
- Online payment → Order records: creates order (evidence: `src/app/api/user/payment/route.ts`)
- Browser users → Order tracking: tracks order
- Admin console → Sales dashboard: loads metrics (evidence: `src/components/AdminDashboardClient.tsx`)
- Sales dashboard → Order records: aggregates orders (evidence: `src/app/api/admin/dashboard/route.ts`)
- Sales dashboard → User records: counts customers (evidence: `src/app/api/admin/dashboard/route.ts`)
- Admin console → Product management: manages products
- Product management → Grocery records: writes products (evidence: `src/app/api/admin/add-grocery/route.ts`)
- Product management → Cloudinary images: uploads images
- Admin console → Order dispatch: dispatches orders
- Order dispatch → Order records: updates status (evidence: `src/app/api/admin/update-order-status/[orderId]/route.ts`)
- Order dispatch → User records: finds nearby riders (evidence: `src/app/api/admin/update-order-status/[orderId]/route.ts`)
- Order dispatch → Delivery assignments: creates offers (evidence: `src/app/api/admin/update-order-status/[orderId]/route.ts`)
- Order dispatch → Event notifier: notifies changes (evidence: `src/app/api/admin/update-order-status/[orderId]/route.ts`)
- Event notifier → Socket.IO server: posts events (evidence: `src/lib/emitEventHandler.ts`)
- Socket.IO server → Browser users: broadcasts updates
- Rider dashboard → Assignment actions: accepts jobs
- Rider dashboard → Live map: shows location (evidence: `src/components/DeliveryBoysDashboard.tsx`)
- Rider dashboard → Delivery chat: exchanges messages (evidence: `src/components/DeliveryBoysDashboard.tsx`)
- Browser users → Socket.IO server: connects directly
- Socket.IO server → Order records: saves messages
- Authentication → User records: loads identity (evidence: `src/auth.ts`)
- Role checks → Authentication: checks session (evidence: `src/lib/requireAuth.ts`)
- Order creation → Role checks: checks role (evidence: `src/app/api/user/order/route.ts`)
- Online payment → Role checks: checks role (evidence: `src/app/api/user/payment/route.ts`)
- Product management → Role checks: checks role (evidence: `src/app/api/admin/add-grocery/route.ts`)
- Order creation → Order records: stores order (evidence: `src/app/api/user/order/route.ts`)
- Product management → Grocery records: validates options (evidence: `src/app/api/admin/add-grocery/route.ts`)
- Delivery chat → Socket.IO server: sends chat
