Skip to content
Aayush Swami
Menu

Engineering

Real-time collaborative editing engine

A Yjs-style sync engine built from scratch, with no existing CRDT library.

Status
In progress
Stack
TypeScript, WebSockets, Custom binary protocol

Why I built it

Google Docs-style editing feels like magic: many people type at once and nobody's work gets lost. Most apps get this from a library like Yjs. I wanted to understand how it actually works, so I built the sync engine myself.

The rule I set: no Yjs, Automerge, ShareDB, Liveblocks, Replicache, or any other existing CRDT/OT library. Only standard networking and utility code.

What it does

  • Many people can edit the same text at the same time; edits always merge the same way on every device (a CRDT — conflict-free replicated data type).
  • After the first load, only small changes are sent — never the whole document.
  • Changes travel in a compact custom binary format over WebSockets.
  • Shows other people's cursors and selections live.
  • Works with TipTap / ProseMirror through an editor-agnostic TypeScript API.
Collaborative editing engine architectureA TipTap editor and a ProseMirror editor each talk to their own CRDT core through an adapter; the two cores exchange small binary updates in both directions through a WebSocket relay, which also carries presence data for cursors and selections.binary updatesbinary updatesEditor ATipTapAdapterCRDT coreEditor BProseMirrorAdapterCRDT coreWebSocket relayPresencecursors and selections
Fig. 1 — Each editor talks to its own CRDT core through an adapter; the cores exchange binary updates through a WebSocket relay that also carries presence.

How I tested it

Unit tests, concurrency tests with many simulated users typing at once, stress tests, and performance benchmarks.

Targets

These are the targets the engine is built against. Measured numbers replace them once the benchmarks are published.

  • Local edit appliedunder 5 ms
  • Remote edit shows upunder 100 ms
  • People editing at once100+
  • Operations handledmillions

All selected work