Sync architecture (mobile)
Bondery mobile is local-first with a server-authoritative sync engine: Postgres is source of truth, mobile keeps tier-1 data in SQLite, writes go through an outbox (POST /api/sync/push), reads through bootstrap + pull (GET /api/sync/bootstrap, GET /api/sync/pull).
Related code: apps/mobile · apps/api/src/routes/sync · packages/schemas/src/sync
See .agents/skills/bondery-api/references/sync-architecture.md for the full checklist and protocol details.
Stack overview
| Component | Role |
|---|---|
| Postgres | Source of truth |
| sync_change_log | Per-user batched changelog (domain emission) |
| Fastify API | Push mutations + pull/bootstrap |
| expo-sqlite | On-device store for tier-1 domain data |
| pending_mutations | Outbox drained by push |
Electric is not used.
Protocol
X-Bondery-Sync-Protocol: 2X-Bondery-SQLite-Schema: 3
Adding a replicated table
- Postgres migration + SQLite DDL (
SQLITE_SCHEMA_VERSIONbump if needed). - Domain
emitSyncBatchafter writes. - Mobile materializer + bootstrap table list.
- Push mutation type + optimistic writer.