# shantanu700/khata_flow_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/shantanu700/khata_flow_frontend
- Repository: https://github.com/shantanu700/khata_flow_frontend

## Overview

KhataFlow is a voice-first shop ledger for kirana merchants. A merchant signs in, opens one of six persistent tabs, and views or updates shop data fetched through the app’s server-side API proxy; Speak records commands and can show live transcription and command progress. The product spans dashboard summaries, customer credit, stock, staff, entries, and voice interaction, with language catalogs supporting the screens. The README and selected source establish the main routing, API, and voice relationships; unsampled screen internals and backend processing are represented only at the documented level.

Main entry points: [`components/app/khata-app.tsx`](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/khata-app.tsx) (App shell), [`components/app/bolo.tsx`](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/bolo.tsx) (Speak), [`lib/api.ts`](https://github.com/shantanu700/khata_flow_frontend/blob/main/lib/api.ts) (API client), [`app/api/v1/[...path]/route.ts`](https://github.com/shantanu700/khata_flow_frontend/blob/main/app/api/v1/%5B...path%5D/route.ts) (API proxy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Merchant experience"]
  node_route["Screen route<br/>[page.tsx]"]
  node_app["App shell<br/>[khata-app.tsx]"]
end

subgraph group_commerce["Shop workflows"]
  node_dashboard["Dashboard<br/>[dashboard.tsx]"]
  node_ledger["Customer ledger<br/>[khata.tsx]"]
  node_stock["Stock<br/>[stock.tsx]"]
  node_staff["Staff<br/>[staff.tsx]"]
  node_entries["Entries<br/>[entries.tsx]"]
end

subgraph group_voice["Voice and language"]
  node_speak["Speak<br/>[bolo.tsx]"]
  node_live_mic["Live microphone<br/>[live-mic.ts]"]
  node_language["Language catalogs<br/>[i18n.tsx]"]
end

subgraph group_connectivity["API connectivity"]
  node_data["Shop data<br/>[data.ts]"]
  node_session_route["Session endpoint<br/>[route.ts]"]
  node_proxy["API proxy<br/>[route.ts]"]
  node_session["Session settings<br/>[session.ts]"]
  node_api_client["API client<br/>[api.ts]"]
  node_generated_sdk["Generated API SDK<br/>[sdk.gen.ts]"]
end

node_merchant(("Merchant"))
node_backend{{"KhataFlow API"}}

node_merchant -->|"opens screens"| node_route
node_route -->|"serves app"| node_app
node_app -->|"shows tab"| node_dashboard
node_app -->|"shows tab"| node_ledger
node_app -->|"shows tab"| node_stock
node_app -->|"shows tab"| node_staff
node_app -->|"shows tab"| node_entries
node_app -->|"shows tab"| node_speak
node_app -->|"loads data"| node_data
node_data -->|"calls API"| node_api_client
node_api_client -->|"uses SDK"| node_generated_sdk
node_api_client -->|"sends requests"| node_proxy
node_proxy -->|"forwards requests"| node_backend
node_session_route -->|"uses settings"| node_session
node_proxy -->|"uses token"| node_session
node_session_route -->|"authenticates"| node_backend
node_speak -->|"streams audio"| node_live_mic
node_speak -->|"sends command"| node_backend
node_speak -->|"requests transcript"| node_backend
node_language -->|"loads catalogs"| node_api_client
node_backend -->|"provides strings"| node_language

click node_route "https://github.com/shantanu700/khata_flow_frontend/blob/main/app/%5B%5B...screen%5D%5D/page.tsx"
click node_app "https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/khata-app.tsx"
click node_dashboard "https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/dashboard.tsx"
click node_ledger "https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/khata.tsx"
click node_stock "https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/stock.tsx"
click node_staff "https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/staff.tsx"
click node_entries "https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/entries.tsx"
click node_speak "https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/bolo.tsx"
click node_live_mic "https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/live-mic.ts"
click node_data "https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/data.ts"
click node_language "https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/i18n.tsx"
click node_session_route "https://github.com/shantanu700/khata_flow_frontend/blob/main/app/api/session/route.ts"
click node_proxy "https://github.com/shantanu700/khata_flow_frontend/blob/main/app/api/v1/%5B...path%5D/route.ts"
click node_session "https://github.com/shantanu700/khata_flow_frontend/blob/main/lib/session.ts"
click node_api_client "https://github.com/shantanu700/khata_flow_frontend/blob/main/lib/api.ts"
click node_generated_sdk "https://github.com/shantanu700/khata_flow_frontend/blob/main/lib/client/sdk.gen.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_route,node_app toneBlue
class node_dashboard,node_ledger,node_stock,node_staff,node_entries toneAmber
class node_speak,node_live_mic,node_language,node_backend toneMint
class node_data,node_session_route,node_proxy,node_session,node_api_client,node_generated_sdk toneRose
class node_merchant toneIndigo
```

## Components

### Merchant experience

- [Screen route](https://github.com/shantanu700/khata_flow_frontend/blob/main/app/%5B%5B...screen%5D%5D/page.tsx): `app/[[...screen]]/page.tsx`
- [App shell](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/khata-app.tsx): `components/app/khata-app.tsx`

### Shop workflows

- [Dashboard](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/dashboard.tsx): `components/app/dashboard.tsx`
- [Customer ledger](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/khata.tsx): `components/app/khata.tsx`
- [Stock](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/stock.tsx): `components/app/stock.tsx`
- [Staff](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/staff.tsx): `components/app/staff.tsx`
- [Entries](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/entries.tsx): `components/app/entries.tsx`

### Voice and language

- [Speak](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/bolo.tsx): `components/app/bolo.tsx`
- [Live microphone](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/live-mic.ts): `components/app/live-mic.ts`
- [Language catalogs](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/i18n.tsx): `components/app/i18n.tsx`

### API connectivity

- [Shop data](https://github.com/shantanu700/khata_flow_frontend/blob/main/components/app/data.ts): `components/app/data.ts`
- [Session endpoint](https://github.com/shantanu700/khata_flow_frontend/blob/main/app/api/session/route.ts): `app/api/session/route.ts`
- [API proxy](https://github.com/shantanu700/khata_flow_frontend/blob/main/app/api/v1/%5B...path%5D/route.ts): `app/api/v1/[...path]/route.ts`
- [Session settings](https://github.com/shantanu700/khata_flow_frontend/blob/main/lib/session.ts): `lib/session.ts`
- [API client](https://github.com/shantanu700/khata_flow_frontend/blob/main/lib/api.ts): `lib/api.ts`
- [Generated API SDK](https://github.com/shantanu700/khata_flow_frontend/blob/main/lib/client/sdk.gen.ts): `lib/client/sdk.gen.ts`

### Other components

- **Merchant**
- **KhataFlow API**

## Connections

- Merchant → Screen route: opens screens (evidence: `README.md`)
- Screen route → App shell: serves app (evidence: `app/[[...screen]]/page.tsx`)
- App shell → Dashboard: shows tab (evidence: `README.md`)
- App shell → Customer ledger: shows tab (evidence: `README.md`)
- App shell → Stock: shows tab (evidence: `README.md`)
- App shell → Staff: shows tab (evidence: `README.md`)
- App shell → Entries: shows tab (evidence: `README.md`)
- App shell → Speak: shows tab (evidence: `README.md`)
- App shell → Shop data: loads data (evidence: `README.md`)
- Shop data → API client: calls API (evidence: `components/app/data.ts`)
- API client → Generated API SDK: uses SDK (evidence: `lib/api.ts`)
- API client → API proxy: sends requests (evidence: `README.md`)
- API proxy → KhataFlow API: forwards requests (evidence: `app/api/v1/[...path]/route.ts`)
- Session endpoint → Session settings: uses settings (evidence: `app/api/session/route.ts`)
- API proxy → Session settings: uses token (evidence: `app/api/v1/[...path]/route.ts`)
- Session endpoint → KhataFlow API: authenticates (evidence: `README.md`)
- Speak → Live microphone: streams audio (evidence: `README.md`)
- Speak → KhataFlow API: sends command (evidence: `README.md`)
- Speak → KhataFlow API: requests transcript (evidence: `README.md`)
- Language catalogs → API client: loads catalogs (evidence: `components/app/i18n.tsx`)
- KhataFlow API → Language catalogs: provides strings (evidence: `components/app/i18n.tsx`)
