Skip to content

26 Data Portability and Sync

Vicky Patel edited this page Sep 14, 2026 · 1 revision

26. Data Portability & Offline Sync Architecture

Engineering specifications for multi-device sync replication, offline queues, and account data portability.


🔄 Multi-Device Sync & Delta Replication

PACT OS supports offline-first operations via delta synchronization (20260916000000_multi_device_sync_and_replication.sql):

graph LR
    ClientOffline[Local Offline Queue IndexedDB] -->|Network Restored| SyncEndpoint[/api/sync/delta]
    SyncEndpoint -->|Verify Version & Hash| DeltaLog[(PostgreSQL sync_deltas)]
    DeltaLog -->|Apply Mutations| UserTables[(User Tables: tasks, habits, finance)]
Loading
  • Offline Action Queue: Mutations executed while offline are stored in a local browser IndexedDB queue (src/lib/offline/queue.ts).
  • Delta Log (sync_deltas): Database table tracking table name, record ID, mutation type (insert, update, delete), and sequence timestamp.
  • Conflict Resolution: Last-Write-Wins (LWW) based on server-evaluated updated_at timestamps.

📦 Sanitized Account Data Export (/api/user/export)

Users can export 100% of their personal data at any time in accordance with open-source data portability standards:

  • Export Format: Downloadable ZIP archive (pact-data-export.zip).
  • Included Files:
    • tasks.csv / tasks.json
    • goals.json, projects.json
    • habits.csv, habit_logs.csv
    • finance_transactions.csv, finance_categories.json
    • focus_sessions.json
    • weekly_reviews.json
  • Sanitization Guarantee: Secrets, password hashes, OAuth tokens, and session credentials are strictly stripped before packaging (src/lib/export/sanitizer.ts).

Clone this wiki locally