Offline-First POS & Financial ERP · Sep, 2026
Husban
An enterprise-grade, offline-first Point of Sale (POS), inventory control, and double-entry bookkeeping ERP system tailored for retail merchants with zero-trust cryptographic security.

Built with
- Kotlin
- Jetpack Compose
- NestJS
- Fastify
- PostgreSQL
- Room 3
- SQLCipher
- Dagger Hilt
- TypeScript
- Next.js
- Upstash Redis
- Prisma
Key features
- Offline-First SQLite Outbox
- Double-Entry General Ledger
- Hardware-Backed AES-256-GCM Encryption
- Asymmetric ECDSA Device Signatures
- Sub-Cent Multi-Currency Precision
- On-Device ML Kit Barcode Vision
- Zero-Memory Excel Streaming
Project Overview
Husban (حُسبان) is an enterprise-grade, offline-first Point of Sale (POS), inventory control, and double-entry bookkeeping ERP system engineered for small and medium retail merchants operating in volatile network environments. Unlike conventional cloud-only POS software, Husban establishes the local device as the primary system of record, guaranteeing zero downtime and cryptographic auditability without persistent connectivity.
Core Architecture & Engineering Highlights
1. Zero-Trust Cryptography & Anti-Fraud
- Hardware-Backed Key Wrapping: The local SQLite database is encrypted with SQLCipher 4 using a raw 256-bit key protected inside the Android Keystore hardware enclave (AES-GCM), eliminating slow startup key derivations.
- Asymmetric Request Signing: Every mobile device signs synchronization payloads with an in-enclave ECDSA P-256 private key, mathematically validated on the backend API via custom guards.
- Monotonic Clock Guard (
ClockGuard): Mitigates time-tampering attacks where users roll back system clocks to artificially extend offline license leases, cross-validating hardware elapsed uptime against cryptographic server timestamps.
2. Deterministic Synchronization Engine
- Asynchronous SQLite Outbox: Sales transactions and stock journal updates commit to an atomic local outbox before reaching the network.
- UUIDv7 Conflict Resolution: Employs time-ordered UUIDv7 identifiers and transactional cursor-based page pulls to achieve deterministic data convergence across distributed devices.
3. High-Precision Financial Accounting
- Fixed-Point Arithmetic: Designed custom 64-bit value classes (
Money,Quantity,UnitCost) with explicit scaling and commercial half-up rounding, completely eliminating IEEE-754 floating-point rounding hazards across multi-currency tenders (ILS, JOD, USD, SAR). - Automated Double-Entry Ledger: Seamlessly translates operational receipt events into balanced debit/credit journal lines in real-time.
Key Metrics & Technical Verification
- Codebase Volume: Over 79,000+ lines of strictly typed Kotlin and TypeScript across 26 decoupled modules.
- Test Automation: 105 automated backend integration tests validating cryptographic signatures and synchronization policies with Testcontainers, alongside 65 Android domain unit test suites.
- Optimized Release Footprint: Compiled with full R8 code minification and resource shrinking into a compact 18.2 MB production binary.