Skip to content

Real-Time and Collaborative Systems

Building systems where multiple users interact simultaneously. WebSocket patterns, Server-Sent Events, CRDTs, operational transformation, presence, and offline-first collaborative editing.

1
WebSocket Protocol and Implementation
advanced

The HTTP upgrade handshake, WebSocket frame anatomy, binary vs text modes, heartbeat patterns, and building a production-grade WebSocket client in TypeScript. Plus: where WebTransport fits in the future.

18 min read
2
Server-Sent Events and Long Polling
advanced

SSE is the most underrated real-time API in the browser. One-way server-to-client streaming with automatic reconnection, event IDs for resume, and zero client libraries. Plus: long polling as the battle-tested fallback, and when each approach beats WebSocket.

16 min read
3
Message Deduplication and Ordering
advanced

Networks lie, packets arrive out of order, and messages get delivered twice. Idempotency keys, sequence numbers, vector clocks, Lamport timestamps, and the myth of exactly-once delivery — the hard truths of distributed messaging.

17 min read
4
Reconnection and Offline Queueing
advanced

Exponential backoff with jitter, detecting real connection state (navigator.onLine lies), building an offline message queue with IndexedDB, replaying queued messages on reconnect, and handling stale data. Everything you need for a resilient connection manager.

17 min read
5
The Collaborative Editing Problem
advanced

The fundamental challenge of concurrent edits to shared state. Why locking fails, what intention preservation means, the convergence requirement, and the three approaches (locking, OT, CRDTs) compared through the lens of Google Docs, Figma, and Notion.

16 min read
6
Operational Transformation
advanced

The algorithm behind Google Docs. Transform functions for insert and delete, the TP1 and TP2 correctness properties, the nightmare of N-client OT, Google's simplified approach, and why the industry is migrating toward CRDTs.

18 min read
7
CRDTs: Theory and Types
advanced

Conflict-free Replicated Data Types from first principles. The mathematical properties (commutativity, associativity, idempotence), state-based vs operation-based CRDTs, and the complete taxonomy: G-Counter, PN-Counter, G-Set, 2P-Set, OR-Set, LWW-Register, MV-Register, and RGA for text.

20 min read
8
Yjs and Practical CRDTs
advanced

From theory to production. Yjs architecture (Y.Doc, Y.Text, Y.Array, Y.Map), providers for WebSocket/WebRTC/IndexedDB, building a collaborative editor with Tiptap, Yjs encoding and performance, and when to choose Automerge instead.

18 min read
9
Presence and Awareness
advanced

Who's online, where they are, what they're doing. Cursor broadcasting, selection highlighting, the Yjs awareness protocol, throttling presence updates, and building presence UX with Liveblocks and PartyKit. Plus: privacy considerations you can't ignore.

15 min read
10
Offline-First with Conflict Resolution
advanced

Local-first architecture where the device is the source of truth. IndexedDB as primary datastore, sync protocols (full state vs delta), conflict resolution beyond last-writer-wins, three-way merge for structured data, and lessons from Linear and Notion's offline modes.

18 min read