# nik-coder-10/whatsapp_automation architecture

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

- Interactive diagram: https://gitdiagram.com/nik-coder-10/whatsapp_automation
- Repository: https://github.com/nik-coder-10/whatsapp_automation

## Overview

Trolift is a B2B equipment ordering platform: customers browse a catalogue, build a cart, check delivery and place an order, submit a UPI payment claim, then track the order. Staff administer products, customers, orders, payments, delivery and fulfillment, and issue invoices or quotations. The graph combines documented capabilities with sampled route and module relationships; unsampled implementation details are represented only at supported subsystem paths.

Main entry points: [`app/api`](https://github.com/nik-coder-10/whatsapp_automation/tree/main/app/api) (API route handlers), [`app/admin/(protected)`](https://github.com/nik-coder-10/whatsapp_automation/tree/main/app/admin/(protected)) (Admin dashboard), [`lib/delivery`](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/delivery) (Delivery calculation), [`lib/orders`](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/orders) (Order creation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Customer storefront"]
  node_catalogue["Product catalogue"]
  node_product_views["Product browsing"]
  node_cart["Shopping cart"]
  node_checkout["Checkout form<br/>[CheckoutForm.tsx]"]
end

subgraph group_commerce["Ordering and fulfillment"]
  node_delivery["Delivery calculation"]
  node_orders["Order creation"]
  node_guest_tracking["Guest order access"]
  node_payment_claims["UPI payment claims"]
  node_shipments["Shipment management"]
  node_documents["Invoices and quotes"]
end

subgraph group_operations["Staff operations"]
  node_admin_ui["Admin dashboard"]
  node_admin_catalog["Product and customer admin"]
  node_admin_orders["Order administration<br/>[orders.ts]"]
  node_admin_delivery["Delivery configuration<br/>[delivery.ts]"]
end

subgraph group_platform["Platform services"]
  node_proof_storage["Payment proof storage<br/>[payment-proofs.ts]"]
  node_supabase[("Supabase database<br/>[server.ts]")]
  node_api["API route handlers"]
  node_api_foundation["API handling<br/>[handler.ts]"]
  node_notifications["Email notifications"]
end

node_customer(("B2B customer"))
node_staff(("Trolift staff"))
node_upi(("UPI payment service"))

node_customer -->|"browses"| node_product_views
node_product_views -->|"loads products"| node_catalogue
node_customer -->|"adds items"| node_cart
node_cart -->|"proceeds to"| node_checkout
node_checkout -->|"submits order"| node_api
node_api -->|"creates order"| node_orders
node_api -->|"checks serviceability"| node_delivery
node_orders -.->|"persists order"| node_supabase
node_orders -->|"issues access token"| node_guest_tracking
node_customer -->|"submits UPI claim"| node_payment_claims
node_api -->|"submits claim"| node_payment_claims
node_api -->|"uploads proof"| node_proof_storage
node_customer -->|"pays directly"| node_upi
node_staff -->|"manages platform"| node_admin_ui
node_admin_ui -.->|"manages products"| node_admin_catalog
node_admin_ui -->|"manages orders"| node_admin_orders
node_admin_ui -.->|"configures delivery"| node_admin_delivery
node_admin_orders -->|"manages fulfillment"| node_shipments
node_admin_orders -->|"issues documents"| node_documents
node_api -->|"wraps requests"| node_api_foundation
node_api -->|"sends order notice"| node_notifications
node_delivery -->|"reads delivery rules"| node_supabase
node_delivery -.->|"uses configured rates"| node_admin_delivery

click node_catalogue "https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/catalog"
click node_product_views "https://github.com/nik-coder-10/whatsapp_automation/tree/main/app/products"
click node_cart "https://github.com/nik-coder-10/whatsapp_automation/tree/main/components/cart"
click node_checkout "https://github.com/nik-coder-10/whatsapp_automation/blob/main/components/checkout/CheckoutForm.tsx"
click node_delivery "https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/delivery"
click node_orders "https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/orders"
click node_guest_tracking "https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/guest-access"
click node_payment_claims "https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/payments"
click node_proof_storage "https://github.com/nik-coder-10/whatsapp_automation/blob/main/lib/storage/payment-proofs.ts"
click node_shipments "https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/shipments"
click node_documents "https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/invoices"
click node_admin_ui "https://github.com/nik-coder-10/whatsapp_automation/tree/main/app/admin/(protected)"
click node_admin_catalog "https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/admin"
click node_admin_orders "https://github.com/nik-coder-10/whatsapp_automation/blob/main/lib/admin/orders.ts"
click node_admin_delivery "https://github.com/nik-coder-10/whatsapp_automation/blob/main/lib/admin/delivery.ts"
click node_supabase "https://github.com/nik-coder-10/whatsapp_automation/blob/main/lib/supabase/server.ts"
click node_api "https://github.com/nik-coder-10/whatsapp_automation/tree/main/app/api"
click node_api_foundation "https://github.com/nik-coder-10/whatsapp_automation/blob/main/lib/api/handler.ts"
click node_notifications "https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/notifications"

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_catalogue,node_product_views,node_cart,node_checkout toneBlue
class node_delivery,node_orders,node_guest_tracking,node_payment_claims,node_shipments,node_documents toneAmber
class node_admin_ui,node_admin_catalog,node_admin_orders,node_admin_delivery toneMint
class node_proof_storage,node_supabase,node_api,node_api_foundation,node_notifications toneRose
class node_customer,node_staff,node_upi toneIndigo
```

## Components

### Customer storefront

- [Product catalogue](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/catalog): `lib/catalog`
- [Product browsing](https://github.com/nik-coder-10/whatsapp_automation/tree/main/app/products): `app/products`
- [Shopping cart](https://github.com/nik-coder-10/whatsapp_automation/tree/main/components/cart): `components/cart`
- [Checkout form](https://github.com/nik-coder-10/whatsapp_automation/blob/main/components/checkout/CheckoutForm.tsx): `components/checkout/CheckoutForm.tsx`

### Ordering and fulfillment

- [Delivery calculation](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/delivery): `lib/delivery`
- [Order creation](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/orders): `lib/orders`
- [Guest order access](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/guest-access): `lib/guest-access`
- [UPI payment claims](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/payments): `lib/payments`
- [Shipment management](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/shipments): `lib/shipments`
- [Invoices and quotes](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/invoices): `lib/invoices`

### Staff operations

- [Admin dashboard](https://github.com/nik-coder-10/whatsapp_automation/tree/main/app/admin/(protected)): `app/admin/(protected)`
- [Product and customer admin](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/admin): `lib/admin`
- [Order administration](https://github.com/nik-coder-10/whatsapp_automation/blob/main/lib/admin/orders.ts): `lib/admin/orders.ts`
- [Delivery configuration](https://github.com/nik-coder-10/whatsapp_automation/blob/main/lib/admin/delivery.ts): `lib/admin/delivery.ts`

### Platform services

- [Payment proof storage](https://github.com/nik-coder-10/whatsapp_automation/blob/main/lib/storage/payment-proofs.ts): `lib/storage/payment-proofs.ts`
- [Supabase database](https://github.com/nik-coder-10/whatsapp_automation/blob/main/lib/supabase/server.ts): `lib/supabase/server.ts`
- [API route handlers](https://github.com/nik-coder-10/whatsapp_automation/tree/main/app/api): `app/api`
- [API handling](https://github.com/nik-coder-10/whatsapp_automation/blob/main/lib/api/handler.ts): `lib/api/handler.ts`
- [Email notifications](https://github.com/nik-coder-10/whatsapp_automation/tree/main/lib/notifications): `lib/notifications`

### Other components

- **B2B customer**
- **Trolift staff**
- **UPI payment service**

## Connections

- B2B customer → Product browsing: browses
- Product browsing → Product catalogue: loads products (evidence: `app/products/page.tsx`)
- B2B customer → Shopping cart: adds items
- Shopping cart → Checkout form: proceeds to
- Checkout form → API route handlers: submits order
- API route handlers → Order creation: creates order (evidence: `app/api/orders/route.ts`)
- API route handlers → Delivery calculation: checks serviceability (evidence: `app/api/delivery/check/route.ts`)
- Order creation → Supabase database: persists order
- Order creation → Guest order access: issues access token (evidence: `app/api/orders/route.ts`)
- B2B customer → UPI payment claims: submits UPI claim
- API route handlers → UPI payment claims: submits claim (evidence: `app/api/payments/claim/route.ts`)
- API route handlers → Payment proof storage: uploads proof (evidence: `app/api/payments/claim/route.ts`)
- B2B customer → UPI payment service: pays directly
- Trolift staff → Admin dashboard: manages platform
- Admin dashboard → Product and customer admin: manages products (evidence: `app/admin/(protected)/page.tsx`)
- Admin dashboard → Order administration: manages orders
- Admin dashboard → Delivery configuration: configures delivery
- Order administration → Shipment management: manages fulfillment (evidence: `lib/shipments/service.ts`)
- Order administration → Invoices and quotes: issues documents (evidence: `lib/invoices/service.ts`)
- API route handlers → API handling: wraps requests (evidence: `app/api/orders/route.ts`)
- API route handlers → Email notifications: sends order notice (evidence: `app/api/orders/route.ts`)
- Delivery calculation → Supabase database: reads delivery rules (evidence: `lib/delivery/engine.ts`)
- Delivery calculation → Delivery configuration: uses configured rates
