Back to Case Studies
Retail Engineering & Edge Architecture

A Zero-Latency Local-First Operating System for High-Velocity Retail

How Golden Hat engineered an end-to-end billing engine for Kagzi Dry Fruits (Alwar, Rajasthan)—pairing in-browser SQLite (PowerSync + wa-sqlite), hardware-level smart weighing scales, AI purchase intelligence, and real-time P&L analytics.

Golden Hat EngineeringKagzi Dry Fruits (Alwar, Rajasthan)Edge POS & Distributed Sync6 min read

Operating out of the historic trade hub of Alwar, Rajasthan, Kagzi Dry Fruits is a premium dry fruits, nuts, exotic seeds, and artisanal confectionery destination. During festive seasons, wedding surges, and holiday rushes, checkout counters experience relentless foot traffic where hundreds of loose, variable-weight items must be weighed, packaged, priced, discounted, and billed per minute.

In retail environments where items are billed by fractional grams, counter speed is customer retention. Traditional cloud-based point-of-sale (POS) systems force cashiers into a catastrophic loop: every SKU lookup, weight reading, customer phone query, and checkout action triggers an HTTP roundtrip to a remote server.

When network latencies spike or connectivity drops, cashiers are paralyzed, queues spill into the aisles, and terminal operators resort to hasty manual calculations on scratchpads.

Golden Hat partnered with Kagzi Dry Fruits to architect and deploy a proprietary, modern retail operating system built around an uncompromising architectural principle: zero checkout latency, zero network dependency, and automated operational intelligence.

The Physical Friction of High-Velocity Dry Fruit Retail

Before laying down schema definitions or interface designs, our engineering team conducted an exhaustive operational audit at the store counters in Alwar. We uncovered four acute operational failure modes:

1. Network Jitter & Cloud POS Lockups

Standard web-based SaaS POS platforms rely on continuous client-server polling. A 500ms network timeout or cellular Wi-Fi blip translates into a frozen cashier terminal. In a rush with 15 shoppers waiting in line, even a three-second UI lag destroys checkout throughput.

2. Loose-Weight Tares & Human Input Error

Premium dry fruits (Mamra almonds, Kashmiri walnuts, Afghan figs, organic pine nuts) have high unit costs per 100 grams. Cashiers manually reading scale displays and typing digits into billing software resulted in frequent transcription mistakes, missed container tares, and margin leakage.

3. Multi-Terminal & Multi-Store Synchronization

During festive peaks, multiple billing counters operate simultaneously across the floor alongside warehouse dispatch. Keeping real-time inventory balances, customer loyalty points, and cash drawer reconciliations synced across independent terminals without lock contention was historically impossible.

4. Opacity in Real-Time Unit Economics & P&L

Market procurement prices for imported dry fruits fluctuate weekly. Without real-time batch-cost tracking, management could only review profitability weeks after monthly accounting tallies—making it impossible to calculate instant margins or detect margin-diluting discounts in real time.

“In dry fruit retail, especially during wedding and festive rushes, every single second at the counter counts. When Wi-Fi dipped in the past, our billing terminals would stall while queues stretched out the door. Golden Hat built us an edge system that never freezes, captures weights straight from our scales, and shows us exact real-time margins on every batch sold. It has completely transformed our counter throughput.”— Aman Somvanshi & Shyam Jangra, Founding Team Kagzi Dry Fruits

The Architecture: Local-First POS via PowerSync & WebAssembly SQLite

To eliminate network latency from the checkout path, we abandoned the conventional "client calls API on every click" model. Instead, we architected a Local-First Reactive Edge POS.

The entire transactional lifecycle—product catalog lookup, live weighing, barcode scanning, cart updates, loyalty deductions, and receipt generation—executes directly against an in-browser SQLite database embedded in the browser client via wa-sqlite and synchronized bi-directionally using PowerSync.

Kagzi Dry Fruits — Local-First POS Architecture
┌────────────────────────────────────────────────────────────────────────┐
│                   IN-STORE CLIENT BILLING TERMINAL                     │
│                                                                        │
│  ┌──────────────────────┐  WebSerial / USB-HID  ┌───────────────────┐  │
│  │ Digital Scale Telemetry ├─────────────────────► Live Tare & Weight│  │
│  └──────────────────────┘                       └─────────┬─────────┘  │
│                                                           │            │
│  ┌────────────────────────────────────────────────────────▼─────────┐  │
│  │             IN-BROWSER TRANSACTION ENGINE (0ms LATENCY)          │  │
│  │   • wa-sqlite (Wasm SQLite DB in IndexedDB/OPFS)                 │  │
│  │   • Dynamic Pricing & Real-Time GST Calculation                  │  │
│  │   • Instant Offline Invoice & Barcode Label Generation           │  │
│  └────────────────────────┬─────────────────────────────────────────┘  │
└───────────────────────────┼────────────────────────────────────────────┘
                            │ PowerSync Bi-directional Sync Stream
                            │ (Runs asynchronously in Background Worker)
                            ▼
┌────────────────────────────────────────────────────────────────────────┐
│               DISTRIBUTED CLOUD PERSISTENCE & CENTRAL OS               │
│                                                                        │
│  ┌──────────────────────────────────────────────────────────────────┐  │
│  │   Supabase Postgres Core (Row-Level Security + CDC Replication)  │  │
│  └───────┬──────────────────────────┬────────────────────────┬──────┘  │
│          │                          │                        │         │
│          ▼                          ▼                        ▼         │
│  ┌───────────────┐          ┌───────────────┐       ┌───────────────┐  │
│  │ Multi-Store   │          │ AI Suggestion │       │ Live Batch    │  │
│  │ Terminal Sync │          │ & Loyalty ML  │       │ Cost & P&L    │  │
│  └───────────────┘          └───────────────┘       └───────────────┘  │
└────────────────────────────────────────────────────────────────────────┘

1. True Local-First Edge POS (0ms Latency Path)

Because all product queries and transactions run against an in-browser SQLite instance, checkout operations respond in single-digit milliseconds. When an operator types a product code or adds an item, the interface responds immediately without waiting for an internet roundtrip.

If the fiber connection drops or the Wi-Fi router restarts mid-shift, terminal operations continue unimpeded. Invoices are signed locally, printed instantly, and queued. As soon as connectivity returns, PowerSync sync streams replicate local changes to the cloud Postgres database without data loss or race conditions.

2. Hardware-Integrated Smart Weighing Scale Telemetry

Loose-weight retail lives or dies by precision. We engineered direct hardware telemetry drivers linking counter digital weighing scales directly to the POS via modern browser Web Serial and USB-HID APIs.

When a clerk places a bag of premium pistachios or Medjool dates on the scale, the exact stabilized weight streams directly into the active cart line in real time with automatic container tare subtractions. Manual gram typing is completely eliminated, shutting the door on input errors and shaving seconds off every weighing step.

3. Real-Time AI Upsell & Purchase History Recommendations

When a customer phone number is captured at checkout, an intelligent client-side recommendation engine cross-references past order histories, festival preferences, and purchase frequency.

The cashier screen surfaces high-conversion, contextual pairings—such as suggesting seasonal Kashmiri saffron to a buyer purchasing Mamra almonds, or prompting a gift-box assortment pack during Diwali season. Average Order Value (AOV) increased significantly through relevant, unobtrusive prompts right at the register.

4. Integrated Cashbacks, Loyalty Ledgers & Referral Engine

Rather than relying on third-party marketing plugins that send annoying spam links, we designed a native customer rewards engine. Shoppers accumulate cashback balances on qualifying purchases and earn credits when friends cite their referral number.

All cashback debits and credits compute atomically with one-time verification safeguards directly on the invoice, incentivizing repeat visits without opening the store up to coupon abuse.

5. Granular Batch Costing & Live Real-Time P&L Intelligence

Wholesale commodity pricing changes rapidly across domestic and international dry fruit supply routes. We built a dynamic batch-cost attribution engine on top of Supabase Postgres.

Every sale automatically maps against its corresponding inventory lot cost (FIFO basis), calculating exact gross margin per SKU and per basket in real time. Store owners and managers can review live P&L breakdowns by category, terminal, or location on a mobile-first executive portal, spotting margin compression before it affects the bottom line.

6. Multi-Store, Multi-Terminal Distributed Mesh

The platform seamlessly handles multiple billing stations across store counters, packing counters, and back-room wholesale inventory rooms. Cash drawers, shifting registers, and day-end reconciliation operate across independent terminal IDs while maintaining a unified central inventory view.

The Measurable Impact

By replacing a fragile cloud dependency with a local-first reactive architecture and hardware integration, Kagzi Dry Fruits saw rapid operational and commercial gains:

Zero Checkout Latency (0ms)All lookups, scans, and cart mutations execute locally in-browser
65% Faster Average CheckoutAutomated scale telemetry cut weighing & invoice time from 90s to <30s
100% Offline ResilienceZero terminal lockups during peak-hour network blips or outages
+18% Increase in Average Order Value (AOV)Driven by contextual counter recommendations & cashback loyalty
Zero Scale Input DiscrepanciesDirect scale-to-POS integration eliminated manual tare & weight errors
Real-Time Continuous Margin VisibilityLive FIFO batch-cost accounting replacing monthly delayed tallies

Why Local-First Is the Future of Mission-Critical Retail

The modern web has spent a decade moving everything into central clouds. But for high-velocity physical operations—where a cashier is scanning products in front of an impatient queue—the cloud is the wrong place for the immediate transaction loop.

By pairing wa-sqlite, PowerSync, and modern browser hardware APIs, we delivered the best of both worlds: the raw instant responsiveness of a native 1990s desktop cash register, backed by the real-time syncing, AI analytics, and multi-store control of a modern cloud infrastructure.

Engineering a mission-critical retail or operations platform?

Book a discovery call to inspect your system architecture and evaluate local-first edge designs.

Book Discovery Call