Projects

Real-time Collaborative Notes

WebSockets · Operational Transforms

source codevisit

A from-scratch implementation of Operational Transforms — the algorithm behind Google Docs-style collaboration — because the only way to really understand OT is to write the transform functions yourself and watch the edge cases bite.

The problem

When two people edit the same character offset at the same instant, whose edit wins, and how does everyone converge on the same final document? OT answers this by transforming concurrent operations against each other. Getting it subtly wrong means silent divergence.

What I built

  • Core insert/delete transform functions over a shared text buffer.
  • A WebSocket transport that broadcasts operations and rebases local edits.
  • A full unit-test suite encoding the OT correctness properties (TP1) and the nasty concurrent-edit edge cases.

Outcome

Two clients could hammer the same document and always converge. The test suite was the real deliverable: it made an invisible correctness property something I could prove on every commit.