Sync and Offline
Sync and Offline
Section titled “Sync and Offline”Decision: CRDT for editable documents (v1)
Section titled “Decision: CRDT for editable documents (v1)”Use a CRDT for offline-capable, merge-safe data—not last-write-wins—for notes on web and mobile.
Mentorship messages use a normal message log (one writer per message); see Messaging. Mentor/mentee lists and assignments are online-first with read cache only.
Why CRDT here
Section titled “Why CRDT here”Notes may be edited on phone offline and on web later; CRDTs merge concurrent edits without silent data loss. Simplicity of LWW was rejected in favor of reliability.
Log entries and studies are server-authoritative metadata: cache the latest list locally for read-only offline display; create/update syncs when online (mobile SQLDelight + Apollo refresh).
Scope (v1)
Section titled “Scope (v1)”| Data | Strategy |
|---|---|
| Note body | CRDT document per note |
| Studies | Server authoritative; read cache offline (mobile: studies table) |
| Log entries | Server authoritative; read cache offline (mobile: study_log_entries table) |
| Habits / streaks | Server authoritative; show cached values offline |
| Mentorship messages | Online-first + send outbox; not CRDT |
| Bible text | Links only; no offline canon DB v1 |
Implementation
Section titled “Implementation”Wire format, GraphQL operations, server merge, Automerge document shape, IndexedDB outbox, and diagrams: Note CRDT sync (Developer → Architecture).
Mobile caches studies, log entries, notes, and streak summary via SQLDelight (GarrisonDatabase.sq); refresh pulls from GraphQL when online.
Conflict UX
Section titled “Conflict UX”CRDT should merge automatically; if merge fails (schema mismatch), show explicit “sync problem—copy your text” recovery (rare).