Skip to main content

Worked Answer: Offline-First Field App

Prompt

Design an offline-first field app where technicians inspect assets, capture notes/photos, update job status, and sync later on unreliable networks.

Clarify

Ask:

  • What must work fully offline?
  • What data is sensitive?
  • What conflicts are possible?
  • Are photos or large files required?
  • Can multiple users edit the same job?
  • What happens when permissions change while offline?

Architecture overview

Local-first model

ConcernDecision
local storeIndexedDB or equivalent durable store with migrations
commandsappend-only command queue with idempotency keys
mediaseparate upload queue with resumable strategy
conflictdomain-specific policies by object type
permissionsserver revalidates during replay
diagnosticsredacted sync report for support

State and data

DataOffline behaviorConflict policy
assigned jobscached before shiftserver wins for assignment removal
inspection checklisteditable offlinefield-level or operation merge
job statusqueued commandlatest valid transition with audit
noteseditable offlineappend or manual merge
photosstored locally until uploadidempotent media upload

Failure modes

FailureUX
sync delayed"saved locally" with oldest unsynced age
permission revokedcommand rejected with explanation
conflictreview panel with local and remote changes
storage fullblock new media, preserve existing work
migration failuresafe recovery and support diagnostics

Observability

Track:

  • unsynced command count
  • oldest unsynced command age
  • conflict rate
  • authorization rejects during replay
  • local migration failures
  • media upload retry count
  • storage quota errors

Tradeoffs

DecisionTradeoff
durable local storemore complexity, protects offline work
command queueeasier replay/audit, requires schema discipline
manual conflict for high-value datamore UX work, less silent data loss
server permission recheckpossible offline rejection, safer security

Strong close

The key is to be honest with users: distinguish saved locally, syncing, synced, conflict, rejected, and storage-full states. Offline-first is not a cache feature; it is a product contract with sync, conflict, permission, and recovery semantics.