SSVIKAS — Mandi Trade & Commission Accounting ERP
High-performance offline-first desktop ERP and double-entry accounting engine engineered for agricultural mandi trading firms and produce commission agents.

Technologies & Architecture Stack
Project Overview
Banana Ledger (Shree Sidhi Vinay Kela Agency Ledger ERP) is an offline-first desktop enterprise application engineered specifically for agricultural commission agents (Adatyas) and wholesale produce trading firms operating in Indian Agricultural Produce Market Committees (APMC Mandis). In high-volume produce trading hubs (such as Raver, Burhanpur, and Jalgaon), commission agents operate under razor-thin margins, coordinating the harvesting, weighing, loading, and cross-state dispatch of commercial banana trucks. A single dispatch aggregates harvests from multiple independent farmers into one truck destined for distant wholesale markets (e.g., Delhi, Agra, UP). Traditional generic enterprise accounting tools (such as Tally or Zoho) fail completely in this environment because they lack domain-specific mechanisms for produce tare deductions (Patti leaf cushioning vs. Danda stem weight adjustments), APMC statutory mandi tax splits, hammali (manual labor loading fees), dharmada charity cess, and dynamic multi-party voucher generation. Banana Ledger bridges this gap by combining an embedded WebAssembly-powered relational SQLite database with a modern React 19 desktop interface wrapped in Electron. It automates the entire mandi lifecycle—from high-speed Jantri dispatch billing, dynamic tare weight reconciliation, and farmer crop advances to multi-party double-entry bookkeeping, running ledger balances, and audit-ready Chartered Accountant (CA) financial statements (Trial Balance, Balance Sheet, and Day Book).
The Engineering Problem
1. Multi-Party Dispatch Complexity: A single truck consignment ('Jantri') involves 5 to 15 different farmers supplying varied quantities, bunched weights ('Lung'), and individual agreed rates, all billed to a single outstation merchant. Splitting revenues, commission fees, and transport levies manually across ledgers took over 45 minutes per truck and was prone to severe human calculation errors. 2. Agricultural Tare Deductions: Produce weight differs between the farm weighment and the final truck scale. Accounting must mathematically balance 'Patti Wt' (protective banana leaf weight deduction) and 'Danda Wt' (stalk weight addition) across both individual farmer payouts and merchant billing. 3. Zero Internet Mandi Environment: APMC mandis and loading yards frequently experience severe network blackouts. A cloud-dependent web app would cause catastrophic delays during live loading operations, where weighbridge slips must be issued in seconds. 4. Intricate Agricultural Credit Cycles: Commission agents advance capital to farmers during the plantation cycle. These loans carry specialized daily/monthly interest accruals (Simple vs. Compound) and must be seamlessly offset against future banana crop deliveries.
The Solution
1. Embedded Relational Architecture: Integrated sql.js (WebAssembly-compiled SQLite) within Electron's NodeJS backend. This provides zero-latency, ACID-compliant local transactions without requiring users to install, configure, or run an external database server. 2. Atomic Jantri Dispatch Engine: Designed an interactive, spreadsheet-like data grid where an operator enters weighbridge data and farmer crop allocations. The system automatically computes row-level tare differences, net weights, total banana valuation, hammali (labor), commission (default 5%), and 1% APMC mandi tax, committing the entire transaction atomically. 3. Automated Multi-Party Double-Entry Posting: When a Jantri is finalized, the engine automatically decomposes the transaction into perfectly balanced journal vouchers—debiting the merchant’s receivables while crediting individual farmer payables, commission income, labor expenses, and mandi tax liabilities. 4. Built-in Agricultural Loan & Interest Engine: Engineered an interest computation engine supporting customizable monthly/yearly and simple/compound accrual periods with automatic settlement through direct cash receipts or crop yield offsets. 5. CA-Compliant Audit Reporting & Print Engine: Implemented dynamic Trial Balance and Balance Sheet generators with one-click CSV export for spreadsheet analysis, alongside custom CSS print stylesheets formatted for official physical vouchers and thermal dispatch receipts.
System Architecture & Data Flow
Banana Ledger uses an Electron multi-process architecture with a strict security boundary and isolated execution environments: 1. Presentation Layer (Renderer Process): - Built with React 19, Vite, and Lucide React. - Global state orchestrated via React Context (DbContext), which caches dynamic financial aggregates (merchant receivables, farmer payables, cash/bank reserves). - Interactive analytics rendered through Recharts for monthly turnover and crop variety distributions. - Ergonomic keyboard-first navigation with global function keys (F1 for Jantri Entry, F2 for Register, F3 for Vouchers, F4 for Party Ledgers, F5 for Cash/Bank Books). 2. Bridge Layer (Preload & IPC): - Secure Electron context isolation (contextIsolation: true, nodeIntegration: false). - Exposes safe asynchronous IPC bridges (window.api.query, window.api.transaction, window.api.exportBackup, window.api.importBackup). 3. Persistence & Engine Layer (Main Process): - Electron Main process executes sql.js (SQLite compiled to WebAssembly). - Write operations invoke atomic write flushes that persist the binary SQLite state directly to %APPDATA%/banana_ledger.db. - Complete backup pipeline using Electron native dialogs to export and restore .db binary dumps. Data Flow Pipeline: Weighbridge / Dispatch Input -> Jantri Interactive Grid -> Automated Tare & Tax Validation -> IPC Batch Dispatch -> Main Process Atomic SQL Transaction (BEGIN ... COMMIT) -> Disk Persistence -> Context State Invalidation -> Header KPI & Ledger Re-calculation.
Core Engineering Features
Technical Challenges & Overcoming Them
Results & Impact
- 93% Reduction in Billing Time: Slashed truck dispatch documentation time from 45 minutes of manual ledger calculation down to under 3 minutes per truck consignment. - 100% Offline Resilience: Delivered zero downtime and complete operational independence from internet connectivity across demanding rural APMC mandi conditions. - Zero Accounting Discrepancy: Eliminated manual calculation discrepancies in tare deductions, hammali labor charges, and mandi tax splits across hundreds of farmer consignments. - Sub-15ms Query Response: In-memory SQLite execution via WebAssembly provided instantaneous search, filtering, and ledger rendering across thousands of historical transaction rows. - Instant Tax Audit Preparation: Reduced end-of-year CA audit preparation from weeks of manual paperwork to instant one-click CSV export of Trial Balances and Balance Sheets.
Key Takeaways
- Domain-Driven Design (DDD) in Traditional Industries: Building software for real-world traditional businesses requires deeply understanding field vocabulary and trade nuances (e.g., Patti vs. Danda weight, Jantri, Hammali) rather than forcing rigid, off-the-shelf software patterns. - WebAssembly & Embedded Relational Databases: Mastering the lifecycle of in-memory WebAssembly SQLite (sql.js) inside Electron, including memory export buffers, file system synchronization, and ACID transaction safety. - Double-Entry Accounting Architecture: Deepened expertise in building robust, balanced general ledger systems, multi-party posting decomposition, running balance computations, and financial statement generation. - Desktop UX for High-Speed Environments: Learned the value of keyboard navigation, immediate visual feedback, and print-ready document design for non-technical users who prioritize speed and efficiency over complex UI animations.
Future Roadmap
- Cloud Sync & Multi-Terminal Support: Peer-to-peer or encrypted cloud backup syncing (via Supabase or CouchDB) allowing multiple weight-entry stations in the same mandi yard to work simultaneously. - Direct Weighbridge Serial COM Port Integration: Connecting Electron directly to industrial electronic weighbridge indicators via Node serialport to automatically capture loaded and empty truck weights without manual typing. - Automated Farmer SMS / WhatsApp Vouchers: Integration with WhatsApp Business API / Twilio to send automated crop settlement slips and payment confirmations directly to farmers' mobile phones upon truck dispatch. - Bluetooth Thermal Slip Printer Support: Native ESC/POS driver integration for printing rapid 3-inch slip receipts directly at the loading ramp.