Smart Dairy.
A production milk-delivery management platform digitizing end-to-end dairy operations — route optimization, real-time delivery tracking, payment reconciliation, and customer wallet management.
Architecture & Key Decisions
- 60+ REST APIs across 13+ controller modules serving admin and delivery personnel — customer management, route planning, drive execution, payments, analytics.
- Normalized PostgreSQL schema (10+ tables) with connection pooling (max 20) and transaction-based operations for financial data consistency.
- Query optimization: refactored N+1 queries into single CTE-based queries using window functions (
COUNT(*) OVER()). - JWT auth with role-based access; pagination, filtering, and sorting on all list endpoints, with response compression for mobile payloads.
The Hard Part
Data consistency under live delivery operations
The genuinely hard problems showed up in production: data-consistency and request-latency issues in the GPS tracking and QR-verification flows during live deliveries. These are real distributed-writes problems — reconciling concurrent updates from drivers in the field against a financial ledger that has to stay correct.
Key Features
- Real-time drive execution: GPS location logging plus QR-based sales recording.
- Customer wallet / points system with transaction history and payment reconciliation.
- Automated DLT-compliant SMS notifications via the 2factor.in API.
- Automated financial reconciliation with transaction integrity.
- CLI tooling that reduced admin setup time by ~40%; 1,200+ weekly transactions processed reliably.
Trade-offs & What v2 Adds
Why store points values vs recalculating from transactions?
Read performance — while the ledger remains the source of truth for audits.
Why optional transaction fetching?
Payload-size control for mobile clients on constrained networks.
What v2 would add
Redis caching for customer/route lists, rate limiting, FK + hot-column indexes, WebSockets for live drive updates, and CSV/Excel export.
Want the full walkthrough?
Happy to walk through the reconciliation model, the CTE query refactor, and the production consistency work.