Engineering
Operational Transformation Algorithms
A shared data layer for real-time collaborative editing in which a text document and a mind map are two live projections of one structure, kept consistent under concurrent edits, offline work and multi-user undo.
Collaborative editing is a solved problem for one representation of a document. It stops being solved when two fundamentally different views, linear text and a hierarchical graph, are edited at the same time by different people and both have to stay correct. The data layer is built on Yjs CRDTs and on a projection model designed for exactly that case.
The problem
When a user edits text in the document view, the change must appear immediately and correctly in the mind map, and a node moved in the mind map must restructure the text. Under concurrent edits, offline sessions and undo, the two views drift apart unless consistency is designed in at the data model, not patched in the interface.
What we built
- A dual projection model. Text and mind map are not two documents kept in sync; they are two projections of one canonical structure that captures both the linear order of the text and the hierarchical nesting of concepts. Every user action, typing or dragging a node, is expressed as an operation on the canonical model first and then projected to both views through commutative projection functions, so concurrent edits converge.
- Stable ID anchoring for reliable cross-references between the representations.
- A semantic merge layer above the CRDT. Yjs resolves concurrent character insertions and deletions. Structural conflicts, one user moving a section in the text while another rearranges the same content in the map, go through intent analysis: compatible intents merge with a deterministic priority rule, incompatible ones preserve both changes and show a visual conflict marker the users resolve.
- Selective multi-user undo. Each operation records enough to compute its inverse, undo applies the inverse through the same merge mechanism, and per-user operation stacks are kept in canonical terms, so undo is view-independent and never undoes a collaborator's concurrent work.
- Offline-first operation with conflict-free merges on reconnect, preserving intent and keeping synchronization latency low across all connected clients.
- Performance work: incremental projection that computes only the delta for the affected region, lazy materialization that fully computes only visible mind-map nodes and their neighbors, and a 16 ms coalescing window that batches rapid keystrokes into one CRDT operation.
- An awareness protocol extension showing cursors, selections and activity across both views with under 50 ms latency.
Design decisions
One canonical model, two projections. Synchronizing two documents is a losing game; projecting one structure is a mathematical one. The commutativity of the projection functions is what makes convergence provable rather than hoped for.
Merge by intent, not by position. Two people reorganizing the same content for clarity should not produce a conflict; one promoting a section while another deletes it should. The merge layer decides which is which and only bothers people with the second kind.
Undo in the user's terms. A text edit undone may appear as a node deletion in the map. Keeping the stacks in canonical terms means the result is consistent whichever view the user, or their collaborator, is looking at.
In use
A writer restructures a chapter in the text while a colleague rearranges the same ideas in the map; both see the same result. Someone edits on a flight and reconnects with no lost work and no conflicts they did not cause. A user undoes their own last three changes while two collaborators keep typing.
Where it fits
Collaborative tools in which one body of work has more than one faithful view, such as a document and an outline, a script and a storyboard, or a specification and a diagram, and in which people edit at the same time, including offline.
What we learned
The hardest edge cases are structural: a text edit that creates a heading creates a node, and deciding whether the user meant a new structural element or a line of text requires intent analysis at the point of the edit. Incremental projection and lazy materialization decided whether the system felt instant or sluggish. And the 16 ms coalescing window did as much for network traffic as any optimization of the merge itself.
Technology
Yjs CRDTs with Y.Text, Y.Map and Y.Array. A canonical model with commutative projection functions. Stable ID anchoring. A semantic merge layer with intent analysis. Selective undo by operation inversion. Incremental projection. Lazy materialization. A 16 ms operation coalescing window. An awareness protocol extension.

