Inventory · Khata · Munshi AI
The stock register and khata of a Pakistani wholesaler — in books that can't drift.
Jodia Bazaar still runs on registers, udhaar diaries and WhatsApp. TradeFlow posts every sale once, ages every rupee of udhaar, tells you whom to collect from first, and answers questions from your own numbers — in English or Urdu.
No sign-up. A fictional Karachi wholesaler with 90 days of trade, running entirely in your browser. Switch between owner and munshi to see permissions change.
Collections desk · rank 1
Why this customer first
- · Oldest unpaid invoice is past 60 days
- · No payment for over a month
- · Over the credit limit you set
WhatsApp reminder · Roman Urdu
“Assalam-o-Alaikum … ke khata mein aap ka baqaya Rs … hai, jis mein se Rs … 30 din se zyada purana hai. Meherbani farma kar jald adaigi kar dein.”
Munshi AI
“Is haftay kya order karna chahiye?”
Answer built from get_sales_velocity · read-only · shows its sources
A trading day
Four jobs, done the same way every time.
01
Post once
Receiving stock or recording a sale updates inventory, cost and the party khata in one transaction. Cash settles the invoice; udhaar leaves it open.
02
Keep the khata honest
Invoice-aware aging (current / 30 / 60 / 90+), a running balance on every statement, PDF and WhatsApp-ready text.
03
Collect first what matters
The collections desk ranks who to call, explains why, and opens WhatsApp with a Roman-Urdu or English reminder. Nothing is sent automatically.
04
Ask Munshi
A read-only assistant that answers from your own books — reorder, udhaar, profit — and shows which tools it used.
Built like it holds real money
The database — not staff discipline — keeps the books correct.
Every business sees only its own books
One ORM hook scopes every query, write and Munshi tool to the caller's business. Two-business leak tests attack every endpoint.
Stock cannot be oversold
Stock is checked under a row lock. A 12-thread race against PostgreSQL proves exactly the available units sell.
A double tap posts once
Orders and payments take an Idempotency-Key. A retried request returns the original instead of posting twice.
History is never edited
Posted orders are corrected by an owner-only void that appends reversing stock and khata lines.
Yesterday's profit stays put
Weighted-average cost is snapshotted on each sale line and money is stored as exact NUMERIC.
Credit limits mean something
An udhaar sale over a customer's limit is refused. Only the owner can override it, and the approval is written into the khata.
FastAPI · SQLAlchemy 2 · PostgreSQL · Alembic · Next.js 16 · OpenAI Agents SDK · Expo companion app. The test suite, including the PostgreSQL concurrency tests, runs in CI on every push.
Munshi AI
An assistant that can read, never write.
Munshi runs on the OpenAI Agents SDK with five read-only tools: sales velocity, stock status, receivables aging, profit summary and party statement. The model narrates; it never computes the numbers and has no tool that changes stock or moves money.
- 01
Constitution first
Deterministic rules run before any model call. Requests for fake invoices, two sets of books, hidden income or smuggling are blocked; backdating and credit-limit overrides are flagged for a human.
- 02
Scoped to your business
Each tool opens its own session scoped to the caller's business. The model never sees, and cannot choose, that scope.
- 03
Works without a model
With no API key, or when the provider fails, Munshi answers straight from the same tools. The public demo runs in this mode.
See a wholesaler's day in two minutes.
Record a sale on udhaar, hit a credit limit, void a mistake, then open the collections desk. Reset the books any time.