In a household app with shared lists and notes, when does a CRDT or operational transform earn its cost, and for which data?
answer
- which data is left over
- ids, field merge and increments cover lists
- free text edited at the same time
- history that cannot be trimmed
- one data type, not the whole app
basics
~20 sOnly for free text two people really edit at once, such as a note written together. Lists, ticks and counters are covered by item ids, per-field merge and increments, without the history and server work a text-merging type adds.
solid answer
~50 sMost of this app's data does not need it. Items carry their own ids, so concurrent adds never collide; ticks, titles and quantities merge per field; counters travel as increments; order uses a sort key per item. What is left is free text: two partners changing one note body. If that clash is rare, keeping both versions and letting a person choose costs almost nothing. A text-merging type, a CRDT or operational transform, earns its keep only when writing the same note together is a feature and a 'pick one' prompt would routinely lose work. The costs are then real: a CRDT keeps a change history the phone cannot easily trim, because a partner might reconnect months later; the server must store and serve that format instead of plain text; existing notes need converting; search, previews and server-side checks get harder. Choose it for that one data type, not the app.
go deeper
Remember that most list data merges fine with ids and per-field rules; special text-merging types are for text edited together.
Explain which data types the simpler policies already cover, and why free text is the one they do not.
Show the cost on device and server, history growth, a new storage format, migration, and judge whether co-editing frequency justifies it.
Treat it as a long-term format commitment for one data type, owned across client and server, with a plan for old builds.
## What the machinery buys Two families of technique let several copies of a document accept edits independently and still end up the same: - A **CRDT** (conflict-free replicated data type) is a data structure whose copies can be merged in any order and still converge. A text CRDT gives every character an identity, so concurrent insertions and deletions can be combined without a referee. - **Operational transform (OT)** rewrites each incoming edit against the edits it did not know about, so it still applies at the right place. OT is the more established route for live co-editing and usually relies on a central server to order operations; CRDTs can merge without one, which is why the local-first argument for offline collaboration leans on them. Both answer one question: how do two people edit **the same text** without either losing work? How they work inside is a subject of its own. The design question for a mobile app is narrower: does any of my data need this at all? ## What the household app already has without it In a **shared household app**, two partners keep shopping lists, chore checklists and notes on their phones, often offline. | Data | Concurrent change | Already handled by | |---|---|---| | New list items | Both add items offline | Each item's own id; both adds coexist | | Checked flag, title | Both change it | Last-write-wins; the loss is small and visible | | Item fields | One renames, one changes quantity | Per-field merge | | Chore counter | Both record a completion | Increments the server adds up | | Item order | Both move items | A sort key per item | | Note body | Both rewrite it | **Nothing yet**: keep both versions and ask, or a text-merging type | The local-first argument illustrates a CRDT with a to-do list where one device adds an item while another ticks one. For a single app with a server in the middle, ids and per-field merge already achieve that result with far less machinery. ## The one candidate: a shared note body A text-merging type is worth evaluating only when all of these hold: 1. **Co-editing is a feature**, not an accident. Partners are expected to write the same note at the same time, such as a shared holiday plan. 2. **Clashes are frequent enough** that a "pick one" prompt would routinely throw away paragraphs. 3. **Offline gaps are long**, so whole-body versions diverge a lot before they meet. 4. **The team can own the format** on the phone and on the server for years. If co-writing is rare, keeping both versions and asking the user is honest, cheap and easy to explain. ## What it costs on a phone and its server - **History that keeps growing.** CRDTs keep fine-grained change history, down to single keystrokes, and it is hard to truncate because a partner might reconnect after months away and still need to merge. - **Storage and memory on the device.** That history lives in the phone's local store and is loaded when the note opens. - **A new server format.** The server must store and merge the same structure rather than a plain text column, and every server-side feature that reads notes, search, previews, size limits, moderation, has to read through it. - **Migration.** Existing notes must be converted, and older app builds that only send whole bodies must still be accepted. - **Conflicts do not vanish.** Concurrent rewrites of the same sentence converge to one deterministic result that may contain both rewrites interleaved, and for a single value both partners set, the structure keeps both values for the app or the user to settle. - **Debugging.** A merged note that looks wrong is much harder to explain from a change log than a stored version. ## A decision procedure 1. List every data type and its existing policy. 2. Mark the ones where a clash loses work a person cannot recreate. 3. For each, estimate how often both partners edit it at once. 4. Use "keep both and ask" unless clashes are routine. 5. Introduce a text-merging type for that one field only, behind a server that still owns the record.
- Does a CRDT for the note body remove conflicts entirely?No. It guarantees that both phones converge on the same text, not that the text is what either partner meant. Two rewrites of the same sentence can merge into both versions interleaved, and when both set one value, such as a note's colour, the structure keeps both values for the app or the user to settle.
- How would you introduce it for notes in an app that has already shipped?For the note body only. Convert existing notes on the server, ship the client support before switching it on, and keep accepting whole-body writes from older builds, turned into edits against the merged text on the server, because some partners will not update for months. Lists, items and counters keep their current policies.
- Every shared list needs a CRDT, or concurrent item adds will be lost.
- A CRDT makes conflicts disappear, so no user-facing resolution is ever needed.
- A CRDT's history is small, because it can be discarded right after each sync.
- Adopting a CRDT for notes changes nothing on the server.