Problem: On reconnection, the app fetched fresh server data and overwrote local state — including work completed offline. No conflict resolution existed. Approximately 30 work orders lost per week.
Solution: WatermelonDB logged every table change with a monotonic sequence number. On reconnect: pull server changes newer than last-known sequence, apply locally, then push local changes. Conflicts resolved by business rules: dispatcher assignment wins, engineer completion status wins. Conflict metadata written to audit log.
Technology: React Native · WatermelonDB · SQLite · Node.js · PostgreSQL
Optimisation pattern: cache-and-overwrite-to-pull-then-push-sequence-reconciliation
Outcomes:
Zero work orders lost in 8 months post-launch (vs ~30/week). Sync after 3-hour offline gap: under 12 seconds (50–200 changed records). App startup: 1.1 s cold, 280 ms warm. Battery usage reduced 31% — event-driven sync, no polling.