coschema.
Public repository
A real-time collaborative diagram editor with offline editing support, per-user undo, live cursors and a network simulator that checks all clients end up with the same, valid diagram.
Two editors side by side. Ada goes offline, both edit, the link comes back and the copies merge. Then live cursors and follow mode.
The demo opens the /demo page. The room runs inside your browser, so nothing is sent to a server. Recording from the repository, no sound.
Why I built it.
I work on a diagram editor as part of my day job. My tool creates single-line diagrams for high-voltage electrical substations. The user interface uses Angular and diagram rendering, while the backend is built on Quarkus and Java. In real teams diagrams are often edited simultaneously by multiple users.
I wanted the hard parts of collaboration: keeping a graph valid when two people change it at once, undoing only your own edits, and merging offline work cleanly. The editor is also keyboard operable and announces remote changes to screen readers since collaborative canvases rarely are.
Try it in the demo.
The demo page has two editors, Ada and Bruno, each behind its own simulated link with latency, jitter, packet loss and an offline switch.
- Offline work
- Tick Network offline for Ada, edit on both sides and untick it. The copies merge and end up identical.
- A bad network
- Use the sliders to raise latency, jitter or packet loss for one editor, or select Slow, Lossy or Chaotic for both. When Make a mess is triggered the links are disabled, the same nodes on both ends are edited then the links are re-enabled, giving actual conflict.
- Undo only your own
- Move a node as Ada, change its label as Bruno, then undo as Ada. The position goes back and the label stays.
- Cursors and follow mode
- Click the other person’s badge above the canvas to follow their view. Moving your own view stops following.
- Keyboard
- Click a node. Using N and P, traverse the nodes. Use the arrow keys to move them. Press Enter to edit the label. Press question mark for a list of all shortcuts.
- Export
- The SVG and PNG buttons in the toolbar save the whole diagram.
Three hard parts.
Each decision has its ADR in the repository, with the alternatives that lost.
Validity at read time.
One user adds an edge to a node and a second user deletes the node. The shared document is allowed to hold this invalid state and a derived view that never writes hides this. No clients attempt to fix the issue and therefore there is no storming.
The cost: hidden edges stay in the document until the node comes back or someone deletes them.
Two potential problems with repair writes: 1) Repair writes on every client - each repair can fight with an undo and N clients all delete the same dangling edge 2) Repair writes only on the server - the server acts as a second author. Restored nodes will find their edges deleted.
ADR 0007 on GitHubUndo means my undo.
Each client has its own undo manager that tracks only local changes. A drag consists of one step but may generate many pointer moves. The label and position keys are stored separately, so undoing my move will not undo a subsequent label change by another user.
The problem is that if someone moves the same node after me, then my undo of that move will do nothing, since my change will have been superseded. There is a test for that behavior.
We lost the shared undo stack (undoing other people’s work) and hand-written inverse operations: more code, and wrong under concurrency in exactly the cases the tests cover.
ADR 0008 on GitHubSVG over canvas.
60 fps with 5,000 SVG nodes: one world transform, a grid index providing a stable visible window, three levels of detail and an overview of the entire scene at zoom levels under 0.25. A benchmark was created initially and the first renderer failed on the whole-scene view at the corresponding zoom level, so the renderer was modified.
The trade-off here is that elements outside of the window are not in the DOM and therefore are not visible during browse mode in screen readers or find-in-page. The keyboard model works from the store, rather than the DOM, and brings the focused node into view.
What lost? SVG is accessible by construction with focusable elements and ARIA and only content-visibility (layout is assisted, but not a reduction in the number of Angular views). Canvas or WebGL, faster at scale.
ADR 0014 on GitHub
Numbers.
Only what the scripts in the repository measured.
- 5,000
- Convergence simulator seeds: 0 failed, 90.9 s. 1,756,564 messages carried by the simulated network, 12,715 lost, 6,418 duplicated. Once the network recovers, all documents are byte-exact compared.
- 18 ms
- p95 from the writer's pointer release to pixel change in reader. Two browser contexts in the same room. 200 edits. Memory store. 15 ms using PostgreSQL. Aim < 200 ms.
- 60 fps
- Panning a scene of 5,000 nodes: worst and median of three runs at 8 levels of zoom, from 1 to 0.05.
- 3,987
- Sustained Node operations per second using PostgreSQL in a single process with a 15.77 ms p95 delivery. At 8,000 offered the p95 passed 200 ms. This is for one process.
- 1,012
- Unit tests: 661 in packages, server and scripts, 351 in the editor. 40 integration tests against PostgreSQL, and 41 Playwright tests. Line coverage: 98.75% in packages and server, 96.85% in the editor.
- 100
- Lighthouse accessibility on /, /r/test and /demo, on the desktop and the mobile setting, with no failed audit.
On my laptop: Intel Core i7-12700H, 20 logical cores, 15.5 GiB of RAM, PostgreSQL 18.6, Node 24.21, headless Chromium 153, running Linux under WSL2. Test was run with browser running on localhost, so these are numbers for this machine.
The result files in bench/resultsWhat is not built.
From the stretch list I built only SVG and PNG export. Tests were never what got cut.
- Versions with restore
- There is no ‘go back to this state’ for all in a Yjs document. So a restore would be a diff that would be applied as new edits. This is the difficult part.
- Comments on nodes
- A second shared structure, with its own validity rules when the node is deleted and its own accessibility story.
- A Quarkus auth service
- The sync server uses a dev key to validate the JWT. A Java service that would issue the tokens would be a separate repository's worth of work. It does not add anything new to collaboration.
- Resize and waypoint handles
- The data model and the simulator already cover both. The editor has no handles to drive them.
- Several servers per room
- One server process owns a room. Several instances would need sticky routing by room or a pub/sub layer between them.
- Firefox, WebKit and a screen reader
- The end-to-end suite and every browser number come from Chromium. Nobody has listened to the editor with NVDA or VoiceOver yet.
What comes next.
Pub/sub for multiple servers to share rooms, version snapshots, missing editing handles, and then tests with NVDA and VoiceOver. Within the editor proper, live dragging would be my first feature addition - currently other people see a node jump when you let go, but not while you drag.
ADR 0025: what I did not buildTech
- Angular
- TypeScript
- Signals
- Node.js
- WebSockets
- Docker
- GitHub Actions
- Keyboard support
- Focus management
Blog article: How I test that collaborative edits converge
Let's talk about the role.
Tell me about the team, the product and the stack.