Inspiration

Walk into any small shop in India and there's a khata: a paper ledger of who owes what. It works, until the book gets wet, a page goes missing, the totals drift, or the shopkeeper has to awkwardly ask a regular to pay up. Most "khata apps" ask shopkeepers to change how they work: forms, dropdowns, English menus. I wanted the opposite: keep the habit of speaking, writing and photographing bills, and do the bookkeeping behind it.

What it does

Khata is a Telegram bot (@Ledgy637Bot) with a web demo.

  • Speak or type in Hindi, Punjabi, Hinglish or English: "Ramesh ko paanch sau udhaar" becomes a ₹500 credit entry, with Ramesh's new balance shown.
  • Make bills in chat: atta 2 kg 45, sabun 2 x 35 gives a draft you can edit, then a PDF bill. Rates are remembered.
  • Photograph a bill, printed or handwritten (kacha). It reads every line and checks the arithmetic. It caught a planted mistake: \( 3 \times 45 = 135 \neq 145 \).
  • Nothing is saved until you tap Yes. Mistakes can be corrected in plain words: "nahi, Suresh", "nahi, maine diye", or after saving, "uska naam Ramesh hai, Mujhko Ramesh nahi". If a correction is unclear, it asks instead of guessing.
  • Your own two-way Google Sheet. /start walks you through connecting it. Edit, add or delete rows there and the bot picks it up. Any table exports as PDF or Excel.
  • Ghosts collect the dues. Every customer who owes you becomes a ghost. Tap one and WhatsApp opens with a polite reminder in their language. You decide whether to send it.

The Frankenstein parts

A rule-based multilingual text brain, Groq Whisper ears, Groq vision eyes, a Telegram voice box, a SQLite heart, a Google Sheets spine and a PDF/Excel printing press. There's also a read-only MCP server, so other AI tools can query the khata. None of these parts were made to work together, and any one can fail without losing data:

  • With the AI off, typing, sample bills and ghosts still work.
  • Render's free tier wipes the disk on restart, so on boot each shop's ledger is rebuilt from its own Google Sheet.

The Lab panel on the web page shows which parts are alive.

How I built it

Python, FastAPI and SQLite, built in Kiro:

  • Specs: the Telegram channel went through requirements → design → 54 tasks, with 16 correctness properties.
  • Steering: always-on project rules. Money is integer paise, every query is scoped to one shop, and nothing is saved without confirmation.
  • Hooks: tests run on save, and evals run whenever the extractor changes.
  • A custom Kiro agent, khata-eval-guard, that reviews every change to the parser. It runs the evals, checks money safety, and returns ACCEPT or REJECT.
  • 432 tests, including Hypothesis property-based tests. One of them proves an old Telegram "Yes" button can never confirm a different entry.

Everything runs on free tiers: Groq, Telegram, Google Sheets and Render.

Challenges

  • Who paid whom. "Maine Ramesh ko 500 lautaye" (I returned 500 to Ramesh) and "Ramesh ne 500 lautaye" (Ramesh returned 500) move money in opposite directions. Getting this wrong flips a balance.
  • Corrections are where rules break. "maine nahi diye" (I did not give), "not credit", "usne usko diye": every wording I handled exposed another. My eval-guard agent rejected the correction feature four times, each time with concrete failing phrases, before accepting it.
  • Whisper sometimes writes Hindi in Urdu script. The bot detects that and retries in Hindi.
  • The sheet is both a report and an input. Edits are compared with what the bot last wrote, so a stale sheet never undoes a newer entry. Rows that can't be read stay visible with a reason, and nothing typed is lost.

Accomplishments

  • On a blind test set written before any tuning, 16/20 correct, and no wrong entry ever reached confirmation unflagged.
  • A shopkeeper who only ever opens Google Sheets can still run their whole khata.
  • It runs on ₹0 of infrastructure.

What I learned

  • In money software, "ask, don't guess" beats clever parsing. A confirm step plus plain-language corrections is what makes it trustworthy.
  • An AI reviewer that is allowed to say REJECT caught bugs I would have shipped.
  • I tested gpt-oss-120b with tools that only propose entries. It handled the correction sentences my rules struggled with, but a smaller model invented a customer's name. That's why the code, not the model, should decide what gets saved.

What's next

  • An LLM conversation layer on top of the current safety rules, with the rule-based parser kept as the offline fallback.
  • A collections agent that sends UPI payment links.
  • Reading whole handwritten khata pages.
  • Daily sales and profit.

Built With

Share this project:

Updates

Submission history