SERVIDORDEV
All Case Studies

Offline-First SQLite Architecture for a Field-Sales React Native App

2025 Q3Enterprise Field Sales — Logistics10 weeks
React NativeSQLiteWatermelonDBWebSockets

The Problem

A logistics company with 200 field sales reps operating in rural areas with intermittent 3G connectivity. Their existing React Native app required a stable connection to create orders, check inventory, or log customer visits. Reps resorted to paper forms and manual data entry at end-of-day, introducing transcription errors and 24-hour data latency.

Architecture Decision

WatermelonDB was selected as the local persistence layer — a high-performance SQLite wrapper purpose-built for React Native that lazy-loads records and handles relational data efficiently. An append-only oplog captures every local mutation (create, update, delete) with a Lamport timestamp. A background sync worker drains the oplog into the Node.js API via batched POST requests, resolving conflicts with last-write-wins semantics.

Sync Protocol

The sync protocol is pull-then-push. On connectivity, the client pulls server-side changes since its last known sync token, merges them into the local database, then pushes its oplog entries. Merge conflicts are resolved per-field: the most recent timestamp wins, with a conflict journal written to a separate table for manual review. Real-time order status updates stream from a Redis pub/sub channel through a WebSocket connection that auto-reconnects with exponential backoff.

Outcome

Order entry latency dropped from 24 hours to sub-second local writes with average sync time under 3 seconds on 3G. Rep adoption rate hit 94% within the first month. Data entry errors from paper-to-digital transcription were eliminated entirely. The ops team gained real-time visibility into field activity for the first time.