Service Layer medium complexity mobile
0
Dependencies
0
Dependents
3
Entities
0
Integrations

Description

Captures all write operations performed while the device is offline and stores them as ordered outbox entries. When connectivity resumes, it replays mutations against the backend in the original sequence and maps temporary offline IDs to server-assigned IDs across all affected records.

Feature: Offline Data Support

mutation-outbox-service

Sources & reasoning

Lines 302-303 explicitly define the offline-first architecture including SQLCipher, mutation outbox, conflict resolver, and optimistic mutations. The mobile app architecture section lists this as a core shared capability with no toggle, confirming MVP scope. The blueprint assigns this feature [MVP], consistent with Phase 1 foundational requirements.

  • Offline-first persistence (Drift + SQLCipher encrypted local DB, mutation outbox, sync queue with retry/backoff, ID mapping for offline-created entities, conflict resolver)
  • Optimistic mutations with automatic rollback on failure (contact edits and paginated list updates)

Responsibilities

  • Enqueue create, update, and delete mutations with a monotonic sequence number
  • Persist outbox entries durably in the local encrypted database
  • Replay queued mutations in order when network connectivity is restored
  • Resolve temporary offline entity IDs to canonical server IDs after successful sync
  • Emit sync progress events and surface per-mutation error states to callers

Interfaces

enqueue(mutation: OutboxEntry): void
replayPending(): Promise<SyncResult>
mapOfflineId(tempId: string, serverId: string): void
getPendingCount(): number
clearSynced(): void

Related Data Entities (3)

Data entities managed by this component