Skip to content
All work

Case study Realtime 2026

SyncSpace

Real-time collaborative study & coding workspace.

Role
Full-stack engineer
Timeline
MDG Space, IIT Roorkee · May–June 2026
Status
Demo
Links
Live demo Source
syncspace / architecture4 layers
  1. 01

    Client

  2. 02

    Sync

  3. 03

    Persistence

  4. 04

    Execution

01Problem

The problem

Studying and building together remotely usually means juggling a call, a shared doc that lags or conflicts, and a separate place to run code. Real-time editing tools either lock documents, force turn-taking, or drop edits under concurrency — and none of them let you safely execute untrusted code in the same space.

Built with MDG Space at IIT Roorkee — a multiplayer workspace where people study and code together in real time, with in-browser execution of untrusted code.

02Architecture

How it's built

SyncSpace is a single multiplayer surface: shared documents, live presence and cursors, and an in-browser IDE that executes code inside isolated Docker containers. Collaboration state is conflict-free by construction using Yjs CRDTs synced over a custom Hocuspocus WebSocket server, with Postgres snapshot persistence so a room survives restarts. Multi-tenant isolation is enforced with Postgres row-level security, and each code run is dispatched to a per-run sandbox so untrusted user code can never touch the host.

  1. 01

    Client

    Next.js + React app with Monaco editor and live-cursor overlays

  2. 02

    Sync

    Yjs CRDTs over a custom Hocuspocus WebSocket server merge concurrent edits

  3. 03

    Persistence

    Postgres snapshots + row-level security for multi-tenant isolation

  4. 04

    Execution

    Per-run Docker sandbox: network isolation, read-only FS, memory/PID limits, wall-clock timeout

editor.ts

import * as Y from "yjs";

const doc = new Y.Doc();
const text = doc.getText("editor");

// Edits from anywhere merge automatically — no transform step,
// no central authority deciding order.
text.insert(3, "s");
The client barely knows collaboration is happening: edits from anywhere merge automatically, with no transform step and no central authority deciding order.

Stack

Frontend
Next.jsReactMonaco Editor
Backend
Hocuspocus (WebSocket)Postgres
Infra
Yjs / CRDTsDocker sandboxVercel + Railway

03Key decisions

Decisions that shaped it

  • Yjs CRDTs over Operational Transform

    Adopted Yjs CRDTs for the shared document layer.

    OT requires a central authority to transform and order every operation, which is complex to implement correctly and a single point of failure. CRDTs converge automatically from any edit order, so the client stays simple, offline edits merge cleanly, and there's no server-side transform to get wrong.

  • Docker isolation over a language sandbox

    Ran each execution in its own Docker container.

    Language-level sandboxes are notoriously leaky. Full container isolation gives a hard security boundary and lets the same pipeline support multiple languages and resource limits.

Hard parts

  • Keeping concurrent edits consistent

    Naive shared-state broadcasting drops or clobbers edits under concurrency. Modeling documents as CRDTs made consistency a property of the data structure rather than something to enforce with locks.

  • Executing untrusted code safely

    Running arbitrary user code is a security minefield. Isolating each run in a Docker container with constrained resources contained the blast radius without sacrificing the interactive feel.

  • Surviving restarts without losing work

    CRDT state lives in memory on the WebSocket server. Persisting periodic Postgres snapshots meant a room could restart or a client could rejoin without losing the document.

04Result

What shipped

Concurrent editors
Unbounded (CRDT)
Merge conflicts
0 by design
Execution isolation
Per-run container
  • Conflict-free realtime editing

    Yjs CRDTs let everyone edit the same document at once — no lock-step, no turn-taking, no merge conflicts.

  • Live cursors & presence

    See who's in the room and exactly where their cursor is, synced in real time over the Hocuspocus WebSocket layer.

  • Sandboxed code execution

    Untrusted Python runs in a per-run Docker sandbox — network-isolated, read-only filesystem, memory/PID limits, and a wall-clock timeout — so nothing escapes to the host.

  • Real IDE in the browser

    Monaco editor integration brings syntax highlighting, multi-cursor, and a genuine editor feel to the web.

Lessons

  1. 01CRDTs move correctness into the data model — leaning on them early removed a whole class of sync bugs.
  2. 02Security boundaries are easier to reason about when they're infrastructural (containers) rather than in application code.
  3. 03Presence UX is disproportionately important: live cursors are what make a collaborative tool feel alive.