Skip to content

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.

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).

DataStrategy
Note bodyCRDT document per note
StudiesServer authoritative; read cache offline (mobile: studies table)
Log entriesServer authoritative; read cache offline (mobile: study_log_entries table)
Habits / streaksServer authoritative; show cached values offline
Mentorship messagesOnline-first + send outbox; not CRDT
Bible textLinks only; no offline canon DB v1

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.

CRDT should merge automatically; if merge fails (schema mismatch), show explicit “sync problem—copy your text” recovery (rare).