# dhruv-ns/mandi-khata architecture

> Architecture diagram of the GitHub repository dhruv-ns/mandi-khata, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dhruv-ns/mandi-khata
- Repository: https://github.com/dhruv-ns/mandi-khata

## Overview

Mandi Khata is a voice-first mandi inventory and accounting application. Traders dictate through Wispr Flow or type a command, review a parsed draft, then confirm it; confirmed operations update inventory, party balances, and auditable transaction records. The UI also exposes dashboard, inventory, parties, transactions, reports, and settings. The README describes these capabilities, but unsampled routes and storage schema limit which internal relationships can be verified; omitted links are not assumed.

Main entry points: [`client/src/App.jsx`](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/App.jsx) (App Shell), [`client/src/services/api.js`](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/services/api.js) (REST Client), [`server/src/services/transactionService.js`](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/services/transactionService.js) (Transaction Engine), [`server/src/app.js`](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/app.js) (Express API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Trader Interface"]
  node_app["App Shell<br/>[App.jsx]"]
  node_layout["Navigation<br/>[AppLayout.jsx]"]
  node_voicepage["Voice Assistant"]
  node_voicehook["Voice Workflow"]
  node_mic["Browser Mic<br/>[useBrowserMic.js]"]
  node_readback["Speech Readback"]
  node_offline[("Offline Queue<br/>[offlineQueue.js]")]
  node_api["REST Client<br/>[api.js]"]
  node_inventoryui["Inventory UI<br/>[InventoryPage.jsx]"]
  node_partiesui["Party Ledger UI<br/>[PartiesPage.jsx]"]
  node_transactionsui["Transactions UI"]
  node_dashboardui["Dashboard UI<br/>[DashboardPage.jsx]"]
  node_reportsui["Reports UI<br/>[ReportsPage.jsx]"]
  node_settingsui["Settings UI<br/>[SettingsPage.jsx]"]
  node_receipt["Receipt Modal<br/>[ReceiptModal.jsx]"]
end

subgraph group_server["Command Processing"]
  node_assistantroute["Assistant API<br/>[assistantRoutes.js]"]
  node_parser["Command Parser<br/>[commandParser.js]"]
  node_numbers["Number Parser<br/>[numberParser.js]"]
  node_units["Unit Parser<br/>[unitParser.js]"]
  node_regional["Regional Mappings"]
end

subgraph group_ops["Business Operations"]
  node_transactionservice["Transaction Engine"]
  node_inventoryroute["Inventory API<br/>[inventoryRoutes.js]"]
  node_partyroute["Party API<br/>[partyRoutes.js]"]
  node_txroute["Transaction API"]
  node_dashboardroute["Dashboard and Reports API<br/>[dashboardRoutes.js]"]
  node_serverapp["Express API<br/>[app.js]"]
end

subgraph group_data["Persistence and Insights"]
  node_database[("SQLite Store<br/>[db.js]")]
  node_schema["Database Schema<br/>[schema.js]"]
  node_seed["Demo Data Seed<br/>[seed.js]"]
end

node_trader(("Trader"))
node_wispr(("Wispr Flow"))

node_trader -->|"enters command"| node_voicepage
node_wispr -->|"dictates text"| node_voicepage
node_app -->|"renders"| node_layout
node_app -->|"renders"| node_voicepage
node_app -->|"renders"| node_inventoryui
node_app -->|"renders"| node_partiesui
node_app -->|"renders"| node_transactionsui
node_app -->|"renders"| node_dashboardui
node_app -->|"renders"| node_reportsui
node_app -->|"renders"| node_settingsui
node_app -->|"creates workflow"| node_voicehook
node_voicepage -->|"uses workflow"| node_voicehook
node_voicehook -->|"uses microphone"| node_mic
node_voicehook -.->|"reads summaries"| node_readback
node_voicehook -->|"queues offline"| node_offline
node_voicehook -->|"submits commands"| node_api
node_inventoryui -->|"requests inventory"| node_api
node_partiesui -->|"requests ledgers"| node_api
node_transactionsui -->|"requests transactions"| node_api
node_dashboardui -->|"requests dashboard"| node_api
node_reportsui -->|"requests reports"| node_api
node_settingsui -->|"requests settings"| node_api
node_api -->|"sends REST requests"| node_serverapp
node_serverapp -->|"routes requests"| node_assistantroute
node_serverapp -->|"routes requests"| node_dashboardroute
node_serverapp -->|"routes requests"| node_inventoryroute
node_serverapp -->|"routes requests"| node_partyroute
node_serverapp -->|"routes requests"| node_txroute
node_assistantroute -->|"parses command"| node_parser
node_parser -->|"normalizes numbers"| node_numbers
node_parser -->|"interprets units"| node_units
node_parser -->|"uses language mappings"| node_regional
node_assistantroute -->|"executes business actions"| node_transactionservice
node_inventoryroute -->|"records wastage"| node_transactionservice
node_partyroute -->|"records containers"| node_transactionservice
node_txroute -->|"handles transactions"| node_transactionservice
node_dashboardroute -->|"computes ageing"| node_transactionservice
node_transactionservice -->|"calculates totals"| node_units
node_transactionservice -->|"reads and writes"| node_database
node_dashboardroute -->|"queries reports"| node_database
node_database -->|"initializes schema"| node_schema
node_database -->|"loads demo data"| node_seed
node_app -->|"opens receipt"| node_receipt

click node_app "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/App.jsx"
click node_layout "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/layouts/AppLayout.jsx"
click node_voicepage "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/VoiceAssistantPage.jsx"
click node_voicehook "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/hooks/useVoiceAssistant.js"
click node_mic "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/hooks/useBrowserMic.js"
click node_readback "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/hooks/useSpeechReadback.js"
click node_offline "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/services/offlineQueue.js"
click node_api "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/services/api.js"
click node_inventoryui "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/InventoryPage.jsx"
click node_partiesui "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/PartiesPage.jsx"
click node_transactionsui "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/TransactionsPage.jsx"
click node_dashboardui "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/DashboardPage.jsx"
click node_reportsui "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/ReportsPage.jsx"
click node_settingsui "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/SettingsPage.jsx"
click node_assistantroute "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/routes/assistantRoutes.js"
click node_parser "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/parser/commandParser.js"
click node_numbers "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/parser/numberParser.js"
click node_units "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/parser/unitParser.js"
click node_regional "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/parser/regionalMappings.js"
click node_transactionservice "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/services/transactionService.js"
click node_inventoryroute "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/routes/inventoryRoutes.js"
click node_partyroute "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/routes/partyRoutes.js"
click node_txroute "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/routes/transactionRoutes.js"
click node_dashboardroute "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/routes/dashboardRoutes.js"
click node_serverapp "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/app.js"
click node_database "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/database/db.js"
click node_schema "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/database/schema.js"
click node_seed "https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/database/seed.js"
click node_receipt "https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/components/ReceiptModal.jsx"

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_layout,node_voicepage,node_voicehook,node_mic,node_readback,node_offline,node_api,node_inventoryui,node_partiesui,node_transactionsui,node_dashboardui,node_reportsui,node_settingsui,node_receipt toneBlue
class node_assistantroute,node_parser,node_numbers,node_units,node_regional toneAmber
class node_transactionservice,node_inventoryroute,node_partyroute,node_txroute,node_dashboardroute,node_serverapp toneMint
class node_database,node_schema,node_seed toneRose
class node_trader,node_wispr toneIndigo
```

## Components

### Trader Interface

- [App Shell](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Navigation](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/layouts/AppLayout.jsx): `client/src/layouts/AppLayout.jsx`
- [Voice Assistant](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/VoiceAssistantPage.jsx): `client/src/pages/VoiceAssistantPage.jsx`
- [Voice Workflow](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/hooks/useVoiceAssistant.js): `client/src/hooks/useVoiceAssistant.js`
- [Browser Mic](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/hooks/useBrowserMic.js): `client/src/hooks/useBrowserMic.js`
- [Speech Readback](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/hooks/useSpeechReadback.js): `client/src/hooks/useSpeechReadback.js`
- [Offline Queue](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/services/offlineQueue.js): `client/src/services/offlineQueue.js`
- [REST Client](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/services/api.js): `client/src/services/api.js`
- [Inventory UI](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/InventoryPage.jsx): `client/src/pages/InventoryPage.jsx`
- [Party Ledger UI](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/PartiesPage.jsx): `client/src/pages/PartiesPage.jsx`
- [Transactions UI](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/TransactionsPage.jsx): `client/src/pages/TransactionsPage.jsx`
- [Dashboard UI](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/DashboardPage.jsx): `client/src/pages/DashboardPage.jsx`
- [Reports UI](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/ReportsPage.jsx): `client/src/pages/ReportsPage.jsx`
- [Settings UI](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/pages/SettingsPage.jsx): `client/src/pages/SettingsPage.jsx`
- [Receipt Modal](https://github.com/dhruv-ns/mandi-khata/blob/main/client/src/components/ReceiptModal.jsx): `client/src/components/ReceiptModal.jsx`

### Command Processing

- [Assistant API](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/routes/assistantRoutes.js): `server/src/routes/assistantRoutes.js`
- [Command Parser](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/parser/commandParser.js): `server/src/parser/commandParser.js`
- [Number Parser](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/parser/numberParser.js): `server/src/parser/numberParser.js`
- [Unit Parser](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/parser/unitParser.js): `server/src/parser/unitParser.js`
- [Regional Mappings](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/parser/regionalMappings.js): `server/src/parser/regionalMappings.js`

### Business Operations

- [Transaction Engine](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/services/transactionService.js): `server/src/services/transactionService.js`
- [Inventory API](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/routes/inventoryRoutes.js): `server/src/routes/inventoryRoutes.js`
- [Party API](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/routes/partyRoutes.js): `server/src/routes/partyRoutes.js`
- [Transaction API](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/routes/transactionRoutes.js): `server/src/routes/transactionRoutes.js`
- [Dashboard and Reports API](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/routes/dashboardRoutes.js): `server/src/routes/dashboardRoutes.js`
- [Express API](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/app.js): `server/src/app.js`

### Persistence and Insights

- [SQLite Store](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/database/db.js): `server/src/database/db.js`
- [Database Schema](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/database/schema.js): `server/src/database/schema.js`
- [Demo Data Seed](https://github.com/dhruv-ns/mandi-khata/blob/main/server/src/database/seed.js): `server/src/database/seed.js`

### Other components

- **Trader**
- **Wispr Flow**

## Connections

- Trader → Voice Assistant: enters command (evidence: `README.md`)
- Wispr Flow → Voice Assistant: dictates text (evidence: `README.md`)
- App Shell → Navigation: renders (evidence: `client/src/App.jsx`)
- App Shell → Voice Assistant: renders (evidence: `client/src/App.jsx`)
- App Shell → Inventory UI: renders (evidence: `client/src/App.jsx`)
- App Shell → Party Ledger UI: renders (evidence: `client/src/App.jsx`)
- App Shell → Transactions UI: renders (evidence: `client/src/App.jsx`)
- App Shell → Dashboard UI: renders (evidence: `client/src/App.jsx`)
- App Shell → Reports UI: renders (evidence: `client/src/App.jsx`)
- App Shell → Settings UI: renders (evidence: `client/src/App.jsx`)
- App Shell → Voice Workflow: creates workflow (evidence: `client/src/App.jsx`)
- Voice Assistant → Voice Workflow: uses workflow (evidence: `client/src/App.jsx`)
- Voice Workflow → Browser Mic: uses microphone (evidence: `client/src/hooks/useVoiceAssistant.js`)
- Voice Workflow → Speech Readback: reads summaries (evidence: `client/src/hooks/useVoiceAssistant.js`)
- Voice Workflow → Offline Queue: queues offline (evidence: `client/src/hooks/useVoiceAssistant.js`)
- Voice Workflow → REST Client: submits commands (evidence: `client/src/hooks/useVoiceAssistant.js`)
- Inventory UI → REST Client: requests inventory (evidence: `client/src/pages/InventoryPage.jsx`)
- Party Ledger UI → REST Client: requests ledgers (evidence: `client/src/pages/PartiesPage.jsx`)
- Transactions UI → REST Client: requests transactions (evidence: `client/src/pages/TransactionsPage.jsx`)
- Dashboard UI → REST Client: requests dashboard (evidence: `client/src/pages/DashboardPage.jsx`)
- Reports UI → REST Client: requests reports (evidence: `client/src/pages/ReportsPage.jsx`)
- Settings UI → REST Client: requests settings (evidence: `client/src/pages/SettingsPage.jsx`)
- REST Client → Express API: sends REST requests (evidence: `client/src/services/api.js`)
- Express API → Assistant API: routes requests (evidence: `server/src/app.js`)
- Express API → Dashboard and Reports API: routes requests (evidence: `server/src/app.js`)
- Express API → Inventory API: routes requests (evidence: `server/src/app.js`)
- Express API → Party API: routes requests (evidence: `server/src/app.js`)
- Express API → Transaction API: routes requests (evidence: `server/src/app.js`)
- Assistant API → Command Parser: parses command (evidence: `server/src/routes/assistantRoutes.js`)
- Command Parser → Number Parser: normalizes numbers (evidence: `server/src/parser/commandParser.js`)
- Command Parser → Unit Parser: interprets units (evidence: `server/src/parser/commandParser.js`)
- Command Parser → Regional Mappings: uses language mappings (evidence: `server/src/parser/commandParser.js`)
- Assistant API → Transaction Engine: executes business actions (evidence: `server/src/routes/assistantRoutes.js`)
- Inventory API → Transaction Engine: records wastage (evidence: `server/src/routes/inventoryRoutes.js`)
- Party API → Transaction Engine: records containers (evidence: `server/src/routes/partyRoutes.js`)
- Transaction API → Transaction Engine: handles transactions (evidence: `server/src/routes/transactionRoutes.js`)
- Dashboard and Reports API → Transaction Engine: computes ageing (evidence: `server/src/routes/dashboardRoutes.js`)
- Transaction Engine → Unit Parser: calculates totals (evidence: `server/src/services/transactionService.js`)
- Transaction Engine → SQLite Store: reads and writes (evidence: `server/src/services/transactionService.js`)
- Dashboard and Reports API → SQLite Store: queries reports (evidence: `server/src/routes/dashboardRoutes.js`)
- SQLite Store → Database Schema: initializes schema (evidence: `server/src/database/db.js`)
- SQLite Store → Demo Data Seed: loads demo data (evidence: `server/src/database/db.js`)
- App Shell → Receipt Modal: opens receipt (evidence: `client/src/App.jsx`)
