Real-Time Collaborative Code Editor Ships the Pipeline and Skips the Conflict Engine

WebSocket rooms, Redis Pub/Sub, a job queue, and a Docker worker cluster. A small Turborepo project shows the full shape of a browser IDE, minus the one problem that makes collaboration hard.

7 min read • View on GitHub • More from KishanVyas308

An overhead editorial illustration of a long drafting table split down the middle by a thin seam. Two pairs of hands edit the same sheet of paper from opposite sides, mirrored. A numbered placard with a six-digit code is pinned to the wall above, and a single pipe runs from below the table toward a sealed box at the edge of the frame.
Two people, one shared surface, one room, and a system reaching offstage. The hero image holds both planes of the architecture in a single frame: the collaboration surface above, the execution pipe below.
Key Takeaways

Four Services, One Room

Most collaborative editor repos are Monaco wrapped in a WebSocket. This one is a small distributed system, and you can read every wire. Four services run side by side, and one Redis 7 instance sits behind all of them, doing two jobs at once.

Rooms are simple by design. A user creates a six-digit code, others join with it, and the room server holds membership in its own memory. Presence, the shared language selection, and the shared stdin all live there. When someone types, the edit relays to everyone in the room.

The project is a solo portfolio build, published in October 2024 by KishanVyas308. Its purpose is to demonstrate an end-to-end architecture, not to ship a product, and that framing matters for everything that follows.

A real-time collaborative code editor that allows multiple users to edit and execute code simultaneously.

KishanVyas308, Project author · KishanVyas308/Real-Time-Collaborative-Code-Editor

Where the Code Actually Runs

A Run click is the most interesting thing in the repo, because it leaves the browser entirely. The editor POSTs to the Express server with the source, the language, and the room id. Express does almost nothing with it: it pushes the job onto a Redis list and returns.

On the other side, three worker processes are blocked on BRPOP. When a job lands, one of them wakes up, reads the language, and spins a fresh Docker container for it. The container runs the code, the worker captures stdout and stderr, tears the container down, and publishes the result to a Redis Pub/Sub channel.

Every browser in the room is subscribed to that channel. The output lands on all of them at once, not just the person who clicked Run. That fanout is what makes shared execution feel shared.

One Run click becomes a queued job, a Docker container, and a broadcast to every browser in the room. Step through the stages to follow the packet, or hover a node to see what it does.

The language support is a plain switch. Six branches, each one a different way to get code into a container.

switch (language) {
  case "javascript":
    cmd = ["node", "-e", code];
    break;
  case "python":
    cmd = ["python3", "-c", code];
    break;
  case "cpp":
    // write source, compile with g++, then run the binary
    break;
  case "rust":
    // write source, compile with rustc, then run the binary
    break;
  case "java":
    // write source, javac, then java
    break;
  case "go":
    cmd = ["go", "run", "main.go"];
    break;
}

The queue is doing real work here. Execution is slow and unbounded, so it does not belong in the request path. Pushing it onto a list and letting workers pull means the API stays fast and adding capacity is a matter of starting another worker. BRPOP is a pull, not a push, so no coordinator has to decide who gets the next job.

The Collaboration Plane

The room server is the part that looks like every other collaborative editor, and mostly is. It keeps a map of rooms to sockets in memory, relays edits, and tracks who is present. Redis Pub/Sub is what lets more than one server instance stay in sync: a message published by one instance reaches subscribers on all of them.

The honest limitation is durability. Room state lives in RAM. Restart the server and the room is gone. Run two instances and a user's socket is pinned to one of them. There is no persistence layer for documents, because there is no document model to persist.

That is fine for a demo and a real constraint for anything else.

The Sync Problem Nobody Solved

Here is the twist. Two people editing a document at the same time is not one problem. It is two, and they are very different sizes.

The first is transport: getting bytes from one browser to the others quickly. This repo solves that. The second is convergence: making sure that when two people type on the same line at the same moment, every browser ends up with the same text. That one is hard, and as far as the sources establish, this repo does not address it.

A naive shared document applies edits in the order they arrive. If two edits target the same position, the later one overwrites the earlier one. The first person's keystrokes vanish. This is a lost update, and it is the exact failure a collaborative editor exists to prevent.

An extreme close-up editorial illustration of a single line of handwritten text. Two pen nibs hover over the same word, one caught mid-stroke and the other having just laid a stroke directly over it, half-erasing the first. Faint crosshatched ghost letters show an earlier version of the word bleeding through the page.
The lost-update problem rendered physically. When two edits target the same position, the later one overwrites the earlier one, and the first person's keystrokes disappear.

The standard fixes are operational transformation, which rewrites concurrent edits so they commute, and CRDTs, which make edits merge automatically by construction. Neither is documented in this project. The editor relays text; it does not reconcile it.

Framed fairly, that is a scope choice. For a portfolio project whose point is the execution pipeline, skipping the conflict engine is defensible. It is also the most useful thing the repo teaches, because it shows where the difficulty actually lives. The plumbing is a weekend. The convergence is the product.

How It Compares

ProjectSync modelShared executionHostingBest for
This repoNone documented (no OT or CRDT)Yes, Docker workersSelf-hostedStudying an end-to-end architecture
CodeSyncServer-authoritative state, versions, presenceNot claimedSelf-hostedSync correctness
Replit / CodeSandboxProprietary multiplayerYes, shared runtimeHostedReal work, fast
VS Code Live ShareRelay plus peer document deltasNo (the developer's own machine)Hosted relayPairing in your real editor
CoderPad / HackerRankInterview-orientedYesHostedHiring loops

The target repo is the only row that exposes the full queue-and-worker execution architecture in open source. That is exactly why it is worth reading, and exactly why it is not production-ready.

What to Steal, What to Fix

The architecture is worth copying in three places.

A fork that wanted to become a product would need three things first.