04/05#phli-0004/052026Sole engineer
Philoi: Editing without locks
Real-time collaborative editor where concurrent edits converge without a lock.
- clients converging
- 10
- cold document open
- ~350 ms
- permission layers
- 3
How it works, in 4 steps
- Three replicas edit one paragraph at once. Type, and you are the third.
- Every keystroke is a CRDT operation: no lock, and no server deciding who wins.
- The network delays and reorders delivery; every replica still ends up identical.
- The same holds at 10 clients, three dropping off and rejoining; a cold open takes ~350 ms.
Notes
Philoi is a collaborative document editor. Several people edit the same document at once, see each other’s cursors, and leave comments anchored to the text — plus sharing with roles, version history, search, folders and export.
Concurrent edits converge without locking and without a server deciding who wins. Edits are CRDTs, so two people typing in the same paragraph both end up with the same document and nobody’s keystrokes are discarded. A test rig starts the sync server with its shipping config, connects 10 headless clients to one document, drives randomized concurrent edits, takes three of them offline to keep editing and brings them back, then asserts that every client holds byte-identical state.
Permissions are enforced at three layers, because hiding the UI is not enforcement: the REST handlers check the caller’s role, the WebSocket handshake checks a short-lived, document-scoped token, and a viewer’s or commenter’s connection is read-only, so its edits reach neither the other clients nor Postgres.
Measured on a production build, a document opens cold in ~350 ms and warm in ~330 ms. Documents soft-warn at ~1 MB and are refused at ~10 MB.
Next.js 15 and TipTap on the front, Yjs and Hocuspocus for sync, Postgres via Prisma, NextAuth with Argon2id, and Cloudflare R2 for storage. Running on a DigitalOcean droplet behind Caddy at philoi.net.
Built with
- Next.js 15
- Yjs
- Hocuspocus
- Postgres
- Cloudflare R2