Data Layer medium complexity mobile
0
Dependencies
0
Dependents
0
Entities
0
Integrations

Description

Manages persistent storage of queued mutations in the local SQLite database on device. It provides CRUD operations for enqueuing, retrieving, and removing sync records across app sessions. All queue state survives app restarts, ensuring no mutation is lost during extended offline periods.

Feature: Background Sync

sync-queue-repository

Sources & reasoning

Line 302 explicitly lists "sync queue with retry/backoff" as part of the core offline architecture. The blueprint assigns dedicated components BackgroundSyncService and RetryBackoffScheduler to this feature, confirming it is distinct from the outbox storage layer. Blueprint marks it [MVP], consistent with offline-first being a Phase 1 foundational requirement across all organizations.

  • Offline-first persistence (Drift + SQLCipher encrypted local DB, mutation outbox, sync queue with retry/backoff, ID mapping for offline-created entities, conflict resolver)

Responsibilities

  • Persist mutation records to the local database sync queue table
  • Retrieve pending mutations ordered by creation time and retry count
  • Update mutation status fields (pending, in-flight, synced, failed)
  • Delete successfully synced records to prevent queue bloat
  • Query queue depth and oldest-pending timestamps for health metrics

Interfaces

enqueue(mutation: SyncMutation): Promise<void>
getPending(limit: number): Promise<SyncMutation[]>
markSynced(id: string): Promise<void>
markFailed(id: string, error: string): Promise<void>
getQueueDepth(): Promise<number>
clear(): Promise<void>