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