# banothunithin/kot_ai architecture

> Architecture diagram of the GitHub repository banothunithin/kot_ai, 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/banothunithin/kot_ai
- Repository: https://github.com/banothunithin/kot_ai

## Overview

PrimeOps is a restaurant operations app centered on menu ordering, kitchen order tickets (KOTs), inventory reservations, payment, and invoicing, with authentication and AI inventory insights. The UI’s App component coordinates state and presents role-oriented views; the server handles authentication, AI requests, payments, and invoices backed by MySQL. The README documents stock reservation, deduction, and reversal behavior, but the corresponding implementation is not shown in the excerpts. Edges reflect excerpted calls, source-index references, or README statements; unsampled payment wiring is marked unverified.

Main entry points: [`App.tsx`](https://github.com/banothunithin/kot_ai/blob/main/App.tsx) (App coordinator), [`server/server.js`](https://github.com/banothunithin/kot_ai/blob/main/server/server.js) (Express server), [`components/KOTList.tsx`](https://github.com/banothunithin/kot_ai/blob/main/components/KOTList.tsx) (KOT list), [`server/routes/invoices.js`](https://github.com/banothunithin/kot_ai/blob/main/server/routes/invoices.js) (Invoice routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Operations UI"]
  node_app["App coordinator<br/>[App.tsx]"]
  node_login["Login<br/>[Login.tsx]"]
  node_register["Registration<br/>[Register.tsx]"]
  node_delivery["Delivery dashboard<br/>[DeliveryStats.tsx]"]
  node_active["Active orders view"]
  node_alerts["Alerts panel<br/>[AlertsPanel.tsx]"]
end

subgraph group_orders["Ordering and Stock"]
  node_menu["Menu ordering<br/>[MenuGrid.tsx]"]
  node_kotlist["KOT list<br/>[KOTList.tsx]"]
  node_inventory["Inventory table<br/>[InventoryTable.tsx]"]
  node_inventorymodal["Inventory detail<br/>[InventoryModal.tsx]"]
  node_aiui["Inventory insight client<br/>[geminiServices.ts]"]
end

subgraph group_backend["Backend Services"]
  node_server["Express server<br/>[server.js]"]
end

subgraph group_records["Accounts and Records"]
  node_auth["Authentication routes<br/>[auth.js]"]
  node_payments["Payment routes<br/>[payments.js]"]
  node_razorpay["Payment interface"]
  node_invoices["Invoice routes<br/>[invoices.js]"]
  node_pdf["Invoice PDF service<br/>[pdfService.js]"]
  node_mysql[("MySQL database<br/>[connection.js]")]
end

node_staff(("Restaurant staff"))
node_groq{{"Groq AI"}}
node_gateway{{"Payment gateway"}}

node_staff -->|"uses"| node_app
node_app -->|"renders"| node_login
node_app -->|"renders"| node_register
node_app -->|"coordinates"| node_menu
node_app -->|"coordinates"| node_kotlist
node_app -->|"renders"| node_inventory
node_app -->|"renders"| node_inventorymodal
node_app -->|"renders"| node_alerts
node_app -->|"renders"| node_delivery
node_app -->|"renders"| node_active
node_menu -.->|"submits order"| node_app
node_app -->|"requests insight"| node_aiui
node_aiui -->|"posts prompt"| node_server
node_server -->|"requests analysis"| node_groq
node_kotlist -->|"renders payment"| node_razorpay
node_kotlist -->|"requests payment"| node_app
node_razorpay -.->|"processes payment"| node_gateway
node_server -->|"mounts routes"| node_auth
node_server -->|"mounts routes"| node_invoices
node_server -->|"mounts routes"| node_payments
node_auth -->|"reads and writes"| node_mysql
node_invoices -->|"reads and writes"| node_mysql
node_invoices -->|"generates PDF"| node_pdf
node_payments -->|"uses authentication"| node_auth

click node_app "https://github.com/banothunithin/kot_ai/blob/main/App.tsx"
click node_login "https://github.com/banothunithin/kot_ai/blob/main/components/Login.tsx"
click node_register "https://github.com/banothunithin/kot_ai/blob/main/components/Register.tsx"
click node_delivery "https://github.com/banothunithin/kot_ai/blob/main/components/DeliveryStats.tsx"
click node_active "https://github.com/banothunithin/kot_ai/blob/main/components/ActiveOrdersDashboard.tsx"
click node_alerts "https://github.com/banothunithin/kot_ai/blob/main/components/AlertsPanel.tsx"
click node_menu "https://github.com/banothunithin/kot_ai/blob/main/components/MenuGrid.tsx"
click node_kotlist "https://github.com/banothunithin/kot_ai/blob/main/components/KOTList.tsx"
click node_inventory "https://github.com/banothunithin/kot_ai/blob/main/components/InventoryTable.tsx"
click node_inventorymodal "https://github.com/banothunithin/kot_ai/blob/main/components/InventoryModal.tsx"
click node_aiui "https://github.com/banothunithin/kot_ai/blob/main/services/geminiServices.ts"
click node_auth "https://github.com/banothunithin/kot_ai/blob/main/server/routes/auth.js"
click node_payments "https://github.com/banothunithin/kot_ai/blob/main/server/routes/payments.js"
click node_razorpay "https://github.com/banothunithin/kot_ai/blob/main/components/RazorpayPayment.tsx"
click node_invoices "https://github.com/banothunithin/kot_ai/blob/main/server/routes/invoices.js"
click node_pdf "https://github.com/banothunithin/kot_ai/blob/main/server/services/pdfService.js"
click node_mysql "https://github.com/banothunithin/kot_ai/blob/main/server/db/connection.js"
click node_server "https://github.com/banothunithin/kot_ai/blob/main/server/server.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_login,node_register,node_delivery,node_active,node_alerts toneBlue
class node_menu,node_kotlist,node_inventory,node_inventorymodal,node_aiui toneAmber
class node_server toneMint
class node_auth,node_payments,node_razorpay,node_invoices,node_pdf,node_mysql toneRose
class node_staff,node_groq,node_gateway toneIndigo
```

## Components

### Operations UI

- [App coordinator](https://github.com/banothunithin/kot_ai/blob/main/App.tsx): `App.tsx`
- [Login](https://github.com/banothunithin/kot_ai/blob/main/components/Login.tsx): `components/Login.tsx`
- [Registration](https://github.com/banothunithin/kot_ai/blob/main/components/Register.tsx): `components/Register.tsx`
- [Delivery dashboard](https://github.com/banothunithin/kot_ai/blob/main/components/DeliveryStats.tsx): `components/DeliveryStats.tsx`
- [Active orders view](https://github.com/banothunithin/kot_ai/blob/main/components/ActiveOrdersDashboard.tsx): `components/ActiveOrdersDashboard.tsx`
- [Alerts panel](https://github.com/banothunithin/kot_ai/blob/main/components/AlertsPanel.tsx): `components/AlertsPanel.tsx`

### Ordering and Stock

- [Menu ordering](https://github.com/banothunithin/kot_ai/blob/main/components/MenuGrid.tsx): `components/MenuGrid.tsx`
- [KOT list](https://github.com/banothunithin/kot_ai/blob/main/components/KOTList.tsx): `components/KOTList.tsx`
- [Inventory table](https://github.com/banothunithin/kot_ai/blob/main/components/InventoryTable.tsx): `components/InventoryTable.tsx`
- [Inventory detail](https://github.com/banothunithin/kot_ai/blob/main/components/InventoryModal.tsx): `components/InventoryModal.tsx`
- [Inventory insight client](https://github.com/banothunithin/kot_ai/blob/main/services/geminiServices.ts): `services/geminiServices.ts`

### Backend Services

- [Express server](https://github.com/banothunithin/kot_ai/blob/main/server/server.js): `server/server.js`

### Accounts and Records

- [Authentication routes](https://github.com/banothunithin/kot_ai/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [Payment routes](https://github.com/banothunithin/kot_ai/blob/main/server/routes/payments.js): `server/routes/payments.js`
- [Payment interface](https://github.com/banothunithin/kot_ai/blob/main/components/RazorpayPayment.tsx): `components/RazorpayPayment.tsx`
- [Invoice routes](https://github.com/banothunithin/kot_ai/blob/main/server/routes/invoices.js): `server/routes/invoices.js`
- [Invoice PDF service](https://github.com/banothunithin/kot_ai/blob/main/server/services/pdfService.js): `server/services/pdfService.js`
- [MySQL database](https://github.com/banothunithin/kot_ai/blob/main/server/db/connection.js): `server/db/connection.js`

### Other components

- **Restaurant staff**
- **Groq AI**
- **Payment gateway**

## Connections

- Restaurant staff → App coordinator: uses (evidence: `README.md`)
- App coordinator → Login: renders (evidence: `App.tsx`)
- App coordinator → Registration: renders (evidence: `App.tsx`)
- App coordinator → Menu ordering: coordinates (evidence: `App.tsx`)
- App coordinator → KOT list: coordinates (evidence: `App.tsx`)
- App coordinator → Inventory table: renders (evidence: `App.tsx`)
- App coordinator → Inventory detail: renders (evidence: `App.tsx`)
- App coordinator → Alerts panel: renders (evidence: `App.tsx`)
- App coordinator → Delivery dashboard: renders (evidence: `App.tsx`)
- App coordinator → Active orders view: renders (evidence: `App.tsx`)
- Menu ordering → App coordinator: submits order (evidence: `README.md`)
- App coordinator → Inventory insight client: requests insight (evidence: `App.tsx`)
- Inventory insight client → Express server: posts prompt (evidence: `services/geminiServices.ts`)
- Express server → Groq AI: requests analysis (evidence: `server/server.js`)
- KOT list → Payment interface: renders payment (evidence: `components/KOTList.tsx`)
- KOT list → App coordinator: requests payment (evidence: `components/KOTList.tsx`)
- Payment interface → Payment gateway: processes payment
- Express server → Authentication routes: mounts routes (evidence: `server/server.js`)
- Express server → Invoice routes: mounts routes (evidence: `server/server.js`)
- Express server → Payment routes: mounts routes (evidence: `server/server.js`)
- Authentication routes → MySQL database: reads and writes (evidence: `server/routes/auth.js`)
- Invoice routes → MySQL database: reads and writes (evidence: `server/routes/invoices.js`)
- Invoice routes → Invoice PDF service: generates PDF (evidence: `server/routes/invoices.js`)
- Payment routes → Authentication routes: uses authentication (evidence: `server/routes/payments.js`)
