Problem Statement: A Shared Editor That Must Also Compile and Run
Frames the product as three coupled planes - editing, execution, collaboration - rather than a plain chat or docs clone.
Problem statement
Design a web-based environment where multiple developers edit the same source files at the same time, see each other's cursors instantly, share one execution sandbox with a live console, get syntax highlighting and lint diagnostics while they type, and can rewind or branch the code at any point. The brief adds ephemeral dev containers and concurrent merge as explicit differentiators.
This is not Google Docs with a monospace font. Three properties make code collaboration harder than prose collaboration.
First, text in this system is interpreted by other machines. A half-merged file that is fine for a human reader is a syntax error for the compiler, so every intermediate state produced by concurrent edits must still tokenize, highlight, and ship to a language server without corrupting it. Second, developers do not only read and write text: they execute it. The product therefore needs a shared, isolated execution environment whose stdout, stderr, exit codes, and exposed ports are visible to every participant. Third, code has structure beyond characters - files, directories, imports, branches - so the version model must support checkpoints and forks, not just a linear undo stack.
The three planes
- Editing plane: capture local keystrokes, broadcast operations, order them, and converge every replica to identical text. The two production-proven families are Operational Transformation, used by Google Docs since the Google Wave era, and CRDTs, described publicly by Figma for its multiplayer design files and implemented in libraries such as Yjs and Automerge.
- Execution plane: allocate an isolated sandbox per session, restore it fast, stream console output to all participants, and enforce CPU, memory, network, and lifetime quotas because the code is untrusted.
- Collaboration plane: presence, cursors, selections, permissions, session forking, and audit. Presence traffic is ephemeral and lossy by design; document edits are durable and totally ordered. Mixing the two classes of traffic is the most common early design mistake.
Why the hard problems interact
A run request is only meaningful against a converged document state. If two editors have divergent buffers, the sandbox would compile a file no participant is actually looking at. Therefore the run pipeline must pin a specific, server-ordered document version, execute against that snapshot, and label the console output with the version it ran. This coupling between the editing plane and the execution plane is the single architectural decision that separates a credible answer from a generic real-time chat design.
Public operating baseline
Google disclosed in 2020 that more than two billion Docs files had been created, evidence that server-ordered collaborative text operates at planetary scale. Replit reported tens of millions of registered users running untrusted code in per-user isolated environments. CodeSandbox publicly described moving its cloud dev environments to Firecracker microVMs restored from memory snapshots. StackBlitz demonstrated the opposite pole with WebContainers, a Node.js runtime compiled to WebAssembly that runs entirely inside the browser tab. These are cited company signals, not requirements for our fictional system. Every uncited number later in this answer is an explicit design assumption.
Key Highlights
- •Code collaboration is three planes: ordered editing, isolated execution, and ephemeral presence.
- •Every intermediate merged state must remain parseable for highlighting and language servers.
- •A run must pin a server-ordered document version so all participants share the same compiled reality.
- •Google Docs proves server-ordered OT at billions of files; Figma proves CRDTs for complex shared documents.
- •Presence is lossy and disposable; document operations are durable and totally ordered.
Section Rescue Kit
Buzzwords to use:
Safe statements:
- "Let me separate editing, execution, and presence first, because each has different consistency and failure semantics."
- "Before choosing OT or CRDT, I want to pin down what a run executes and who orders operations."