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

Description

Manages the mutation outbox by enqueuing, prioritising, and draining pending write operations that were created while offline. It processes mutations in FIFO order, applies exponential backoff on transient failures, and notifies Riverpod notifiers once a batch is successfully committed to the server.

Feature: Background Sync

sync-queue-service

Sources & reasoning

Lines 300-303 explicitly name the sync queue with retry/backoff and ID mapping as architectural components, which map directly to the BackgroundSyncWorker and SyncQueueService in the blueprint. Lines 50-54 reinforce that parallel operation during rollout requires the app's data to stay consistently synchronised with existing systems - silent background sync is the mechanism that makes this possible. The blueprint assigns MVP, consistent with offline-first being a launch-day architectural commitm

  • docs/source/likeperson.md · line 300-303
    Offline-first persistence (Drift + SQLCipher encrypted local DB, mutation outbox, sync queue with retry/backoff, ID mapping for offline-created entities, conflict resolver)
  • docs/source/likeperson.md · line 50-54
    Sterk enighet pÄ tvers: Eksisterende lÞsninger mÄ fungere parallelt til appen er godt etablert. Ingen av organisasjonene tÄler et hard-cut.

Responsibilities

  • Enqueue mutation records into the outbox with a timestamp and retry counter
  • Drain the outbox in order when network connectivity is detected
  • Apply exponential backoff and cap retry attempts for failed mutations
  • Emit batch-complete events so Riverpod notifiers can refresh local state
  • Deduplicate or collapse redundant mutations before transmission

Interfaces

enqueue(mutation: MutationRecord): void
drainQueue(): Future<SyncResult>
retryFailed(): Future<void>
clearQueue(): void
getQueueDepth(): int