
KhataGO
WhatsApp-first bookkeeping for Indian small businesses. A text or receipt photo becomes a ledger entry through Gemini function-calling, with webhook deduplication enforced in Postgres. Tracks transactions, receivables and payments received; exports to Tally.
Performance & Impact
8 → 1
Duplicate webhooks
Eight simultaneous deliveries of one message store one row, in the integration test against real Postgres
10
Tool calls
Gemini function-calling surface: transactions, receivables, payments, ledgers, reminders
21/21
Evals
Fixture conversations through the production loop under a scripted model, in CI, under both engines. Reproduce in the repository: npm run evals; npm run evals -- --engine=langgraph
3
Languages
Full i18n across English, Hindi, and Gujarati for both UI and bot responses
AES-256-GCM
Credential storage
Users bring their own Gemini key, encrypted at rest with authenticated encryption and a random IV per write. No read path returns it — not even to the person who saved it
The Problem
Small business owners in India struggle with complex accounting software. They often rely on manual notebooks (Khatas), which lead to data loss, calculation errors, and delays in GST compliance.
The Solution
A 'zero-learning-curve' platform that works where the user already is: WhatsApp. By combining the simplicity of chat with the power of AI, KhataGO makes business accounting as easy as sending a message.
System Architecture
KhataGO is a WhatsApp-first bookkeeping platform for Indian MSMEs. The backend is an idempotent ledger-write pipeline: Meta webhooks arrive with at-least-once delivery, and idempotency is enforced in Postgres rather than a cache — a unique constraint on the WhatsApp message id rejects duplicate deliveries, and a conditional UPDATE (PENDING→PROCESSING) atomically claims each message so concurrent redeliveries produce exactly one Gemini run instead of a double ledger write. The webhook persists the message and acknowledges Meta within the request; a containerized polling worker drains the queue — the same Postgres table, claimed through the same atomic UPDATE, retried with exponential backoff and jitter, and dead-lettered after three attempts with an audited admin replay. Gemini 2.0 Flash with function-calling parses both text ('Sold 500 to Ram') and receipt images (OCR → structured JSON with merchant/amount/date/line items) into 10 tool calls — create_transaction, create_receivable, record_payment_received, get_party_ledger, send_payment_reminder, and others — each mapped to a Prisma write. Results flow back to the user over WhatsApp; a CA portal exports Tally-ready XML vouchers for month-end close. Since 2026-09-05 (merged and in the live deploy), the tool-calling loop runs as an explicit, resumable state machine: the model's plan for each turn is persisted before any tool runs, and a write tool commits in the same transaction as its step, so a crash resumes from the last durable turn and at-most-once execution is a property of the database rather than of control flow. Bring-your-own Gemini keys get per-key cooldown isolation, so one user's 429 does not park a model for everyone. Each run is traced as one document (Postgres JSONB by default, a MongoDB adapter opt-in); 21 deterministic evals run in CI through promptproof under both the default loop and a LangGraph.js rendering behind a flag; retention crons bound traces and runs.
Core Engineering Achievements:
System Architecture
Ingress
AI / Tool calls
Agent runtime
Worker
Ledger
Interface & Integrations
"An idempotent ledger-write pipeline dressed up as a WhatsApp bot: events in, idempotency-guarded tool-calls transform them into ledger writes, export back to accountants' formats. The interesting engineering is upstream of the UI — dedup, function-calling determinism, double-entry prevention."
Screens
Screenshots from the shipped product.
Business Ledger Dashboard
A responsive, single-page summary tracking daily, weekly, and monthly incoming/outgoing financial trends.

Transaction Activity Feed
A chronological list of all categorized invoices, expenses, and payments with immediate export and edit capabilities.

Monthly Revenue & GST Portal
An integrated report generation interface allowing CA firms to download precise GST-ready and Tally XML statements.

The Engineering Challenge
Meta's WhatsApp Cloud API delivers at least once, so the same message arrives twice — and an LLM call is expensive enough that deduplicating after it is too late. Idempotency lives in Postgres instead of a cache: the message id is a unique column, so a duplicate insert fails at the DB, and processing starts with a conditional UPDATE that flips aiStatus PENDING→PROCESSING only if it is still PENDING. If that update changes zero rows, another delivery already claimed the message and this one exits — concurrent redeliveries yield exactly one Gemini run and one ledger write, with no cache to fall out of sync with the audit row. The webhook persists the message and acknowledges Meta immediately; a containerized polling worker drains the queue — the Postgres table itself, claimed with the same atomic conditional UPDATE, retried with exponential backoff and jitter, and dead-lettered after three attempts with an audited admin replay — so a burst never times out the handler and a crash mid-run is picked up within seconds rather than at the next cron. The Gemini OCR pipeline downloads the WhatsApp image, sends it to Gemini Vision, and maps the extracted JSON (merchant, amount, date, line items) to a ledger transaction. Tally XML export is the fiddly part: the voucher schema needs specific date formatting, ledger name lookups, and GST field structure — wrong XML silently fails to import, so it has its own unit-test suite.
User Journey
Onboarding
Business owners sign up on the web portal with their mobile number and a one-time code, then message the KhataGO WhatsApp number.
Master Data Setup
Configure customer/vendor records and categories in the web dashboard.
Transaction Logging
Send text messages or photos of bills directly to the KhataGO WhatsApp bot.
AI Processing OCR
The AI agent reads receipts via OCR and records the transactions automatically.
Reporting & Export
Review monthly GST summaries and export Tally-compatible XML vouchers for accountants.
Interested in the full engineering breakdown?
Happy to talk through the technical decisions, from state management strategies to infrastructure scaling.