Engineering Offline-First Enterprise Applications with SQLite WAL, Dexie IndexedDB & Idempotent Sync
An offline-first enterprise application treats local on-device or on-LAN storage (SQLite in WAL mode, browser IndexedDB via Dexie, or mobile Hive boxes) as the primary write target rather than a brittle cache. Network synchronization runs asynchronously via idempotent mutation queues keyed by client-generated UUIDs so retries never create duplicate orders or double-posted accounting vouchers.

Key Engineering Takeaways
- Why SQLite Write-Ahead Logging (WAL) paired with Fastify and better-sqlite3 handles concurrent POS reads and atomic order writes cleanly on local mini-PCs.
- How Dexie (IndexedDB) protects waiter tablets from brief Wi-Fi dead zones before orders even reach the LAN server.
- Why idempotent client_mutation_id deduplication is essential for safely replaying offline batches in FarmOS.
Three Real-World Offline Tiers We Ship in Production
Not every business requires the same synchronization complexity. Across our deployed systems, we match local storage engines to the physical operating environment:
- →Tier 1 — On-Device Local-First Mobile & Desktop (Al-Badar Accounts): Flutter + Hive binary boxes storing UUID-keyed vouchers locally with zero network dependency and one-tap CSV export for auditors.
- →Tier 2 — Local Area Network + Browser Resilience (Spice Pavilion ROS): React 19 + Dexie IndexedDB on touch screens backed by Fastify 5 + better-sqlite3 (SQLite WAL) + WebSockets over the restaurant LAN.
- →Tier 3 — Rural Field Sync to Multi-Tenant Cloud (FarmOS): LocalStorage / SQLite offline queues flushing batched field scouting and irrigation events to POST /api/v1/farms/{farm_id}/sync with client_mutation_id deduplication.
Preventing Duplicate Writes with Idempotent Sync Contracts
The most dangerous bug in naive offline sync is retry duplication: a mobile device uploads a batch over flaky 3G, the server commits the database transaction, the cellular tower drops the HTTP 200 acknowledgement, and the client retries the exact same payload—double-charging an invoice or double-logging irrigation hours.
Every offline mutation generated on the client must carry a deterministic client_mutation_id (UUIDv4) persisted alongside the server record under a unique constraint. When a retried batch arrives, the backend detects the existing mutation key and returns an idempotent acknowledgement without re-applying the write.
{
"device_id": "field-tablet-04",
"mutations": [
{
"client_mutation_id": "9f8c2a1b-4d7e-4c9a-9e21-7a3b1c0e8f42",
"entity_type": "crop_observation",
"recorded_at_utc": "2026-10-19T06:14:22Z",
"payload": { "field_id": "drip-zone-1", "note": "Normal emitter pressure" }
}
]
}Related Engineering Services
Related Project Case Studies
More From the CASDO Knowledge Center
Architecting a Similar System?
Discuss this architecture directly with the CASDO engineering leads who built and benchmarked it.