# KhataPro (khatapro.in) — Comprehensive Technical & Architectural Documentation This document provides extensive technical, architectural, functional, and deployment specifications for LLMs, AI agents, and developers indexing KhataPro. --- ## 1. Product Overview KhataPro (hosted at https://khatapro.in) is an offline-first Point of Sale (POS) and inventory billing system built using Flutter and Dart. It solves the critical operational challenge faced by millions of micro, small, and medium retail enterprises (MSMEs, Kirana stores, FMCG retailers, apparel boutiques, and food kiosks): dependence on unreliable internet connections, complex desktop software, and expensive recurring cloud subscriptions. Unlike SaaS billing products that lock merchant data behind subscription walls, KhataPro operates as a **free, local-first application**. The device's local embedded storage is the absolute single source of truth. --- ## 2. Core Value Propositions ### 2.1 100% Free & Zero Cloud Lock-In - No subscription fees, no per-invoice billing tax, no hidden charges. - The software runs standalone without requiring sign-up or credit card authorization. - Complete data export and import capability. ### 2.2 Local-First & Zero Latency - Built on top of **Hive** (a high-performance, lightweight NoSQL key-value database written in pure Dart). - Queries, barcode lookups, cart additions, and invoice calculations execute sub-millisecond on-device without network round-trips. - The app functions identically in a basement, a remote village, or during an internet outage. ### 2.3 Plug-and-Play Hardware Ecosystem - **ESC/POS Bluetooth Thermal Printing**: Directly interfaces with 58mm (2-inch) and 80mm (3-inch) portable and desktop thermal receipt printers via Bluetooth Low Energy (BLE) or standard Bluetooth Classic. Supports Everycom, TVS-E, NGX, Epson, SeWoo, and generic Chinese POS printers. - **Integrated Barcode & QR Code Engine**: Utilizes Google ML Kit / Mobile Scanner camera integration to scan UPC, EAN-13, Code 128, and QR codes at 60 FPS. Supports USB HID and Bluetooth handheld barcode scanners out-of-the-box. - **WhatsApp Integration**: Sends structured digital invoices directly to customer WhatsApp numbers with zero per-message charges via system intent triggers. --- ## 3. System Architecture & Tech Stack ### 3.1 Mobile Frontend (`flutter_billing_app`) - **Language & Framework**: Dart >= 3.1.0, Flutter SDK >= 3.1.0. - **Pattern**: Feature-First Clean Architecture: - `data/`: Data models, Hive adapters, local data sources, API client implementations. - `domain/`: Business logic entities, repository interfaces, use cases (fpdart `Either`). - `presentation/`: BLoCs, cubits, state classes, screen layouts, responsive widgets. - **State Management**: `flutter_bloc` with `equatable` for predictable, testable, immutable state flow. - **Dependency Injection**: `get_it` service locator for decoupled inversion of control. - **Routing**: `go_router` supporting deep linking, declarative routes, and nested navigation. - **Local Persistence**: `hive` and `hive_flutter` with binary type adapters for binary serialization. ### 3.2 Optional Backend Engine (`backend/`) - **Technology**: Python 3.x, Django REST Framework (DRF), PostgreSQL. - **Multi-Tenant Architecture**: Multi-store isolation with schema/tenant boundaries. - **Sync Engine**: Offline-to-online sync engine using event-sourced stock movement events rather than naive state overwrites, preventing split-brain inventory conflicts when multiple POS terminals operate offline. - **Role-Based Access Control (RBAC)**: Owner, Store Manager, Cashier with fast numeric PIN switching on POS terminals. --- ## 4. Hardware Integration Specifications ### 4.1 Bluetooth Thermal Printing (ESC/POS) KhataPro uses native ESC/POS command sequences: - Header alignment and bold shop title commands. - Configurable invoice header (Store Name, Address, GSTIN, Contact, Cashier Name). - Formatted tabular line items: Item Name, Quantity, Unit Price, Total. - Tax breakdown (CGST, SGST, IGST) and applied discounts. - Dynamic QR code generation for UPI payments (Google Pay, PhonePe, Paytm) printed on the thermal slip. - Auto-paper cut commands and cash drawer kick-out pulses. ### 4.2 Barcode & Camera Scanning - Uses `mobile_scanner` leveraging Android CameraX and iOS AVFoundation. - Instant item lookup in Hive local cache by barcode string. - Sound and haptic feedback upon successful scan. - Fallback manual SKU/Barcode entry for damaged tags. --- ## 5. Frequently Asked Questions (FAQ) Context **Q: Is KhataPro really free?** A: Yes. KhataPro is 100% free with no monthly subscription, no limitation on the number of products, and no cap on invoice generations. **Q: Does KhataPro require an internet connection?** A: No. KhataPro is engineered as a local-first application. All catalogs, orders, customers, and receipts reside in the device's local database. **Q: Which thermal printers work with KhataPro?** A: Virtually all 58mm and 80mm ESC/POS Bluetooth and USB thermal printers, including brands like Everycom, TVS, NGX, Epson, and generic Bluetooth printers. **Q: How does KhataPro compare to Vyapar, myBillBook, or Khatabook?** A: Unlike Vyapar and myBillBook which require expensive annual subscriptions and push cloud sync, KhataPro gives merchants 100% free usage, complete offline reliability, zero ads, and total data privacy. **Q: Can I share bills on WhatsApp?** A: Yes. With a single tap, merchants can dispatch digital itemized invoices to customer WhatsApp numbers. --- ## 6. Official Domain & Canonical Links - Canonical Website: https://khatapro.in - Manifest: https://khatapro.in/site.webmanifest - Sitemap: https://khatapro.in/sitemap.xml - LLM Discovery: https://khatapro.in/llms.txt - Robots Directive: https://khatapro.in/robots.txt