How shahmeerabdul/khata-v2 works
Khata is a bilingual, mobile-first ledger for shopkeepers, with voice-driven sales, customer credit, payments, and supplier payables as its main workflow. A shopkeeper records an utterance; the client sends audio to the voice API, whose server pipeline uses Gemini to classify it, resolves customer and purchase records in MongoDB, and returns a result mirrored into the local ledger. The UI also supports manual ledger entry, contacts, entry management, and dashboards. WhatsApp messaging is optional. The voice flow is documented and the API route is sampled; details of the pipeline implementation and most page wiring are represented only where the README or tree supports them.
Main entry points: voice-intent.ts Intent pipeline · ledger-store.ts Local ledger · page.tsx Record flow · route.ts Customer delete API
Components 22
Shopkeeper app
- Record flow
client/app/record/page.tsx - Audio capture
client/lib/hooks/useAudioRecorder.ts - Confirmation receipt
client/app/record/receipt/page.tsx - Ledger screens
client/app - Manual entries
client/app/new - Contacts screens
client/app/contacts - Demo auth
client/lib/store/auth-store.ts
Voice processing
- Voice record API
client/app/api/voice/record/route.ts - Voice commit API
client/app/api/voice/commit/route.ts - Voice undo API
client/app/api/voice/undo/route.ts - Intent pipeline
server/src/actions/voice-intent.ts - Customer delete API
client/app/api/customers/delete/route.ts
Ledger data
- Customer records
server/src/db/customers.ts - Purchase records
server/src/db/purchases.ts - Local ledger
client/lib/store/ledger-store.ts
External services
- Intent extraction
server/src/integrations/gemini-client.ts - WhatsApp messaging
server/src/integrations/twilio-client.ts
Other components
- Shopkeeper
- Google Gemini
- MongoDB
- Browser storage
- Twilio WhatsApp
Connections 24
- Shopkeeper → Record flow: records speech
- Record flow → Audio capture: captures audio
- Record flow → Voice record API: uploads audio
- Voice record API → Intent pipeline: runs intent
- Voice commit API → Intent pipeline: commits choice
- Voice undo API → Intent pipeline: undoes entry
- Intent pipeline → Intent extraction: requests intent
- Intent extraction → Google Gemini: sends audio
- Intent pipeline → Customer records: resolves customer
- Intent pipeline → Purchase records: records purchase
- Customer records → MongoDB: reads and writes
- Purchase records → MongoDB: reads and writes
- Record flow → Local ledger: mirrors result
- Local ledger → Browser storage: persists ledger
- Ledger screens → Local ledger: reads ledger
- Manual entries → Local ledger: updates ledger
- Contacts screens → Local ledger: reads contacts
- Contacts screens → Customer delete API: requests deletion
- Customer delete API → Customer records: deletes customer
- Customer delete API → Purchase records: deletes purchases
- Intent pipeline → WhatsApp messaging: sends messages
- WhatsApp messaging → Twilio WhatsApp: sends WhatsApp
- Record flow → Confirmation receipt: shows result
- Local ledger → Demo auth