From Messy WhatsApp Chits to GST Invoices in 15s — Local AI with Ollama & Qwen 2.5
BahiPilot: The Local-First AI Back Office for Bharat's Wholesalers This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Across India's wholesale markets (mandis), billions of dollars in daily trade move not through ERP software, but through informal WhatsApp phot
BahiPilot: The Local-First AI Back Office for Bharat's Wholesalers This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Across India's wholesale markets (mandis), billions of dollars in daily trade move not through ERP software, but through informal WhatsApp photos of handwritten paper chits (parchis), voice notes, and loose text messages. A small grain distributor or FMCG stockist in a tier-2 trade hub typically spends 2 to 3 hours every evening performing tedious, error-prone transcription: deciphering scribbled product abbreviations, checking physical warehouse stock, typing quantities into software, balancing running Khatabook customer ledgers, and printing GST-compliant tax invoices. BahiPilot (बही पायलट) is an open-source, local-first AI back office built specifically to eliminate this bottleneck for small Indian wholesalers, distributors, and stockists. Multi-Modal Order Ingestion: Accepts messy WhatsApp photos, scanned paper chits, digital PDF invoices, or raw Hinglish text messages. Local Open-Weight AI Extraction: Uses open-weight models (Qwen 2.5:7b / Llama 3.2) via Ollama to parse messy colloquial text into structured JSON line items—with zero marginal token cost and complete data privacy. Deterministic Catalogue & Alias Matching: Reconciles vernacular terms ("10 bori Basmati Rice 25kg", "5 carton Fortune Oil", "20 pkt Tata Salt") against the business catalogue using token-overlap fuzzy matching and alias indexing. Human-in-the-Loop Review: Provides an interactive 4-stage review screen where quantities, unit rates, and customer accounts can be reviewed with ambiguity warning flags before anything is committed. Strict Financial Integrity (Zero LLM Math): All subtotals, GST (CGST/SGST/IGST), discount deductions, and totals are computed strictly server-side using Python Decimal (paise precision). The LLM is never allowed to hallucinate financial figures. Atomic Ledger & Stock Commitment: Zero stock is deducted and zero customer ledger entries are written until the business owner explicitly clicks Approve. Cancellation atomically restores inventory and balances the customer's running ledger. GST-Ready Printable Invoices & Khatabook: Generates clean, printable B2B tax invoices with HSN breakdowns, and maintains a running chronological customer statement with real-time UPI and cash payment recording. Small and medium distributors, grain wholesalers (Arhatiyas), and FMCG stockists handling 30 to 200 orders a day. They operate on thin 2%–5% gross margins and currently either hire data entry clerks (costing ₹15,000–₹25,000/month) or lose hours of their own family time every night balancing paper Bahi Khata ledgers. A private, local back office that cuts transcription time by 80% pays for itself in days. 🎥 Video Walkthrough: Check out our step-by-step video demo showcasing WhatsApp chit ingestion, catalogue reconciliation, atomic approval, and GST invoice printing. Code / hacktoberfest-dev-2 BahiPilot (बही पायलट) Local-First AI Back Office for Small Indian Wholesalers & Distributors BahiPilot streamlines wholesale and distribution operations across Bharat: ingest messy handwritten chits, WhatsApp order screenshots, and PDF invoices; convert them into structured line items using local open-weight AI (Ollama) or Gemini API; reconcile against catalogue and available stock; and execute transactional inventory deduction, customer ledger posting, and GST-ready invoice printing. 🌟 Key Features Dual AI Order Ingestion (Flagship 4-Stage Guided Workflow): Stage 1 (Input): Upload invoices/receipts (PNG, JPEG, PDF) or paste informal order text (Hinglish/English chits, e.g., "10 bori Basmati Rice 25kg, 5 carton Fortune Oil 1L, 20 packet Tata Salt"). Stage 2 (Extraction): Extracts text via PyMuPDF or Tesseract OCR, prompts local LLMs (Ollama qwen2.5:7b / llama3.2) or Google Gemini (gemini-2.5-flash), strictly adhering to structured JSON schemas. Stage 3 (Review & Reconcile): Interactive review table matching extracted aliases… View on GitHub Repository: https://github.com/srijan-0-7/hacktoberfest-dev-2 Frontend: React 19, TypeScript, Vite, Tailwind CSS (custom Midnight Navy & Emerald Green theme), TanStack Query v5, Recharts, Lucide Icons. Backend: Python 3.11+, FastAPI, Pydantic v2, SQLAlchemy 2.0, SQLite (with WAL mode & strict PRAGMA foreign_keys = ON). AI Engine: Pluggable provider architecture: Local primary: Ollama REST provider (qwen2.5:7b / llama3.2) Cloud fallback: Google Gemini API (gemini-3.8-flash) Document Processing: PyMuPDF (fitz) for native PDF stream extraction, Pillow for preprocessing, and optional Tesseract OCR. Production Ready: Pre-configured Dockerfile (multi-stage build) and render.yaml for 1-click cloud deployment. BahiPilot implements an extensible BaseAIProvider interface. The prompt strictly limits the LLM's task to linguistic extraction, injecting the business's real catalogue and customer list as context: class ExtractionRawLLMOutput(BaseModel): customer_name: Optional[str] = None items: List[RawItemExtraction] = Field(default_factory=list) notes: List[str] = Field(default_factory=list) overall_needs_review: bool = True By requesting structured JSON output and validating via Pydantic schemas, we eliminate hallucinated formats while handling diverse vernacular inputs (Hinglish, mixed English/Hindi names, informal units). In Indian trade, the same product is called ten different names: "Chawal", "Basmati 25kg", "Rice bag", or "India Gate Classic". Instead of trusting an LLM to guess database foreign keys, BahiPilot uses a tiered deterministic matching algorithm: Exact SKU and Product Name normalization Exact Alias array lookup Token coverage & overlap ratios: # Query coverage: what percentage of the requested item's words exist in this product? overlap = query_tokens.intersection(prod_tokens) query_coverage = len(overlap) / len(query_tokens) jaccard = len(overlap) / len(query_tokens.union(prod_tokens)) score = max(query_coverage * 0.82, jaccard) Unmatched or low-confidence items are surfaced with visual warning badges on the review screen, forcing human-in-the-loop resolution before committing to stock. To guarantee financial trust: Zero arithmetic is performed by the LLM. Line subtotals, CGST/SGST splits, and grand totals are calculated with Python Decimal in paise accuracy. Orders start in DRAFT or PENDING_REVIEW. Stock deduction and ledger postings execute only upon explicit user APPROVE action in an atomic database transaction. If cancelled, an automated stock restoration and ledger debit reversal is logged. Open-source and open-weight AI are not just philosophical preferences for Bharat's MSMEs—they are economic and operational necessities: Zero Marginal Inference Cost: Proprietary cloud APIs charging per token or per image are economically unfeasible for small businesses operating on 2%–4% margins. A distributor processing 150 chits a day would face unpredictable recurring monthly SaaS bills. With open-weight models like Qwen 2.5 running on a basic local shop desktop via Ollama, marginal inference cost is exactly ₹0.00. Absolute Data Sovereignty & Confidentiality: Indian wholesalers guard their customer directories, negotiated volume discounts, and turnover numbers as core trade secrets. Small business owners are rightfully wary of transmitting unredacted order photos and customer lists to third-party cloud servers. Local open weights keep 100% of the data inside the four walls of the shop. Offline Continuity in Trade Mandis: Wholesale grain and spice markets often suffer from spotty mobile networks and intermittent broadband. Because BahiPilot's inference and database run entirely on localhost, the distributor can continue scanning orders, adjusting stock, and issuing invoices even when the internet is completely down. Open Vocabulary & Model Independence: Open weights can be fine-tuned or prompt-engineered for regional Indian languages (Hindi, Marathi, Gujarati, Tamil) and unique market jargon without vendor lock-in or fear of arbitrary API deprecation. My Agent Session This entire project was architected, implemented, and debugged through an end-to-end AI pair programming session using Antigravity. Key milestones accomplished during the agent session: System Architecture & Domain Modeling: Engineered the SQLite multi-table schema (customers, products, orders, order_items, ledger_entries) with strict foreign keys and transactional consistency. Dual AI Provider Integration: Built the pluggable BaseAIProvider abstraction supporting local Ollama (qwen2.5:7b / llama3.2) and Gemini cloud fallback with structured JSON validation via Pydantic v2. Deterministic Token-Overlap Matcher: Developed the fuzzy alias matching engine to reconcile colloquial Indian trade terms ("10 bori Basmati Rice", "5 carton Fortune Oil") with catalogue items at 85%–95% confidence without calling external APIs. Full-Stack Polish & Verification: Created the responsive React 19 + Tailwind CSS frontend, wired TanStack Query endpoints, resolved Vite URL routing, and verified atomic approval, inventory deduction, and GST invoice generation. To ground BahiPilot in reality, I tested the order import pipeline with Ramesh Gupta, who operates a wholesale grocery and provisions store (Gupta Kirana & Provisions) supplying 45 retail kirana shops in Maharashtra. Ramesh pasted a typical evening WhatsApp order list sent by one of his regular buyers: "10 bori Basmati Rice 25kg, 5 carton Fortune Oil 1L, 20 pkt Tata Salt, 15 packet Maggi. Urgent delivery by 4 PM." BahiPilot automatically recognized the buyer (Gupta Kirana General Stores) and matched all 4 products against his catalogue inventory with 85%–95% confidence. The system flagged that his catalogue unit for Maggi was a 24-pack box, allowing him to verify the pack size with one click. Upon clicking Approve, the stock deducted from his digital godown, the invoice was posted to the buyer's running ledger, and a GST-compliant print bill was ready in under 15 seconds. "Every evening after 8 PM, I sit with a notebook and spend an hour and a half making bills and checking who owes how much. If this software can take my WhatsApp orders and prepare my bills and Khatabook without needing an internet connection, it saves me at least 10 hours a week. I don't want my customer rates going to foreign clouds, so keeping it on my shop laptop is a huge relief." Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle (Main Category) Frontend: React 19, TypeScript, Tailwind CSS, Vite, TanStack Query Backend: FastAPI, Pydantic v2, SQLAlchemy, SQLite AI Models: Ollama (qwen2.5:7b), Google Gemini API (gemini-3.8-flash) Document Processing: PyMuPDF, Pillow, Tesseract OCR Deployment: Docker, Render Blueprint (render.yaml), Localtunnel Built with ❤️ for Indian MSMEs and the open-source AI community.
Key Takeaways
- •BahiPilot: The Local-First AI Back Office for Bharat's Wholesalers This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Across India's wholesale markets (mandis), billions of dollars in daily trade move not through ERP software, but through informal WhatsApp phot
- •This story was reported by Dev.to, covering developments in the dev space.
- •AI advancements continue to reshape industries — read the full article on Dev.to for complete coverage.
📖 Continue reading the full article:
Read Full Article on Dev.to →


