CodeSync is a production, real-time collaborative coding platform: many people edit one file at once with conflict-free CRDT sync, run code in 7 languages, practice DSA against a hidden-test judge, and run timed technical interviews.
π Try it now β code-sync-chi-lemon.vercel.app
CodeSyncDemoVideoo.mp4
Most "collab editor" apps break the moment two people type at once, or quietly disable code execution in the cloud. CodeSync solves both:
| π§ Conflict-free editing | A server-authoritative Yjs CRDT per room β concurrent edits merge with zero conflicts, survive reconnects, and resync offline changes automatically. |
| βοΈ Execution that deploys anywhere | A pluggable engine runs untrusted code in a hardened Docker sandbox or a remote Judge0 API β switchable with one env var, so the same code ships to a free PaaS or a self-hosted VM. |
| π― Built for real use | Interview mode with hidden tests + timer, a LeetCode-style practice judge with streaks and a leaderboard, session replay, and role-based rooms. |
| πΈ Card Free | Vercel + Render + MongoDB Atlas + Upstash + keyless Judge0 β a public, full-featured deploy that needs no credit card. |
| π Live | π§© Languages | π Engine | ποΈ Data | β‘ Realtime |
|---|---|---|---|---|
| Vercel | 7 | Docker Β· Judge0 | Mongo Β· Redis | Socket.IO + Yjs |
|
|
|
|
This is CodeSync's signature design. Running untrusted code is the only Docker/VM-bound part of the system β so it's isolated behind one env var,
EXEC_ENGINE. Every caller uses the samerunCode()contract and never knows which engine is live.
π³ EXEC_ENGINE=docker (default) |
βοΈ EXEC_ENGINE=judge0 |
|
|---|---|---|
| How it runs | One throwaway, network-isolated container per run | A base64 HTTPS call to a Judge0 API |
| Isolation | Strongest β full OS sandbox | Off-box (no Docker socket exposed) |
| Needs a Docker host? | β Yes | β No |
| Best for | Local dev Β· self-hosted VM | Card-free PaaS (Vercel + Render) |
flowchart LR
A["callers<br/>/api/execute Β· practice judge Β· interview judge"] --> D{"executionService.js<br/>reads EXEC_ENGINE"}
D -->|docker| E["runCodeDocker()<br/>dockerode β sandbox container"]
D -->|judge0| J["judge0Service.js<br/>fetch β ce.judge0.com"]
E --> R["unified result<br/>stdout Β· stderr Β· status Β· time"]
J --> R
The shared contract & language matrix
runCode({ language, code, stdin = '' }) β {
stdout, stderr, exitCode, executionTimeMs,
status // success | error | timeout | oom | compile_error | runtime_error
}
| Language | Docker image | Judge0 ID |
|---|---|---|
| JavaScript | node:20-alpine |
63 |
| TypeScript | codesync-ts (built) |
74 |
| Python | python:3.12-alpine |
71 |
| C++ | gcc:13 |
54 |
| Java | eclipse-temurin:21-jdk |
62 |
| Go | golang:1.22-alpine |
60 |
| Rust | rust:1.78-slim |
73 |
flowchart TB
subgraph C["π₯οΈ Client Β· React + Vite"]
MON["Monaco Editor"] <--> YJS["Yjs CRDT"]
RDX["Redux Toolkit"]
end
subgraph S["βοΈ Server Β· Express + Socket.IO"]
REST["REST API<br/>auth Β· rooms Β· execute Β· problems Β· users"]
WS["Socket handlers<br/>room Β· yjs Β· cursor"]
DOC["In-process Y.Doc<br/>server authority"]
WS --> DOC
end
subgraph X["πΎ State & Execution"]
M[("MongoDB Atlas")]
RE[("Upstash Redis")]
ENG{{"EXEC_ENGINE"}}
DK["π³ Docker sandbox"]
J0["βοΈ Judge0 API"]
ENG -->|docker| DK
ENG -->|judge0| J0
end
YJS -.->|"WSS Β· binary updates"| WS
RDX -.->|"HTTPS Β· JWT"| REST
REST --> ENG
S --> M
S --> RE
MongoDB collections:
UserΒ·RoomΒ·ProblemΒ·SnapshotΒ·ExecutionΒ·SessionEvent(30-day TTL) Β·Submission(90-day TTL). Redis: presence sets, heartbeats (90 s TTL), cursors, and the Socket.IO pub/sub adapter for horizontal scaling.
π Deep dive: docs/ARCHITECTURE.md
sequenceDiagram
participant A as User A
participant S as Server (Y.Doc)
participant B as User B
A->>A: type β Yjs binary update
A->>S: emit yjs-update (base64)
Note over S: assertCanEdit Β· throttle 50/s<br/>Y.applyUpdate(serverDoc)
S-->>B: broadcast yjs-update
B->>B: Y.applyUpdate β Monaco patches, no flicker
Note over A,B: a new joiner gets the full encoded state β zero round-trips
The Docker engine hardens every run in five layers:
| Layer | Control |
|---|---|
| π Network | NetworkMode: none β no outbound connections |
| π Resources | 256 MB RAM (swap off) Β· 50% CPU Β· PidsLimit: 64 (fork-bomb safe) |
| π Filesystem | source via in-memory putArchive Β· writable only on tmpfs /tmp (noexec) + /build (exec) Β· container removed after run |
| π Privilege | non-root uid 1000 Β· no-new-privileges |
| β±οΈ Application | 10 s wall-clock TLE Β· stdout 1 MB / stderr 256 KB caps Β· 100 KB code limit |
Plus, platform-wide: JWT access (15 m) + refresh (7 d), bcrypt hashing, Helmet, strict CORS, and rate limits on API / auth / execution / room creation.
Tip
The Judge0 engine sidesteps the one known Docker trade-off (the mounted
docker.sock) entirely by running code off-box β which is exactly what makes the
card-free cloud deploy safe and simple.
Frontend β React 18 Β· Vite 5 Β· Redux Toolkit Β· React Router 6 Β· Monaco Editor Β· Yjs + y-monaco Β· Socket.IO-client Β· TailwindCSS Β· Axios
Backend β Node 20 (ESM) Β· Express 4 Β· Socket.IO 4 + Redis adapter Β· Mongoose 8 Β· ioredis Β· dockerode Β· jsonwebtoken Β· bcryptjs Β· zod Β· winston
Data & infra β MongoDB Atlas Β· Upstash Redis Β· Docker Β· Judge0 Β· Vercel Β· Render Β· nginx (VM route) Β· Let's Encrypt
Testing β Jest Β· Supertest Β· mongodb-memory-server
Prerequisites: Node 20+, and Docker (only needed for the local Docker execution engine). Mongo + Redis can be local or free cloud (Atlas + Upstash).
git clone https://github.com/MsParadox/CodeSync.git
cd CodeSync
docker compose up -d
# Frontend (via nginx) β http://localhost Backend β http://localhost:4000
# Terminal 1 β backend
cd server && cp .env.example .env # fill MONGODB_URI, REDIS_URL, secrets
npm install && npm run dev # β http://localhost:4000
# Terminal 2 β frontend
cd client && cp .env.example .env # see the env note below
npm install && npm run dev # β http://localhost:5173
Two gotchas that only bite in production β already handled, don't undo them:
VITE_API_URLmust end in/api(routes are mounted under/api);VITE_SOCKET_URLmust not (Socket.IO connects to the origin).- SPA deep links rely on
client/vercel.json(rewrite all βindex.html), so refreshing/problemsdoesn't 404 on Vercel.
server/.env
NODE_ENV=development
PORT=4000 # Render injects this in prod β don't hardcode there
MONGODB_URI=mongodb+srv://user:pass@cluster.mongodb.net/codesync
REDIS_URL=rediss://default:pass@host.upstash.io:6380 # rediss:// (TLS)
JWT_SECRET=<openssl rand -hex 32>
REFRESH_TOKEN_SECRET=<openssl rand -hex 32>
JWT_EXPIRES_IN=15m
REFRESH_TOKEN_EXPIRES_IN=7d
CLIENT_URL=http://localhost:5173 # the browser origin (CORS)
# Execution engine
EXEC_ENGINE=docker # docker | judge0
JUDGE0_API_URL=https://ce.judge0.com # used when EXEC_ENGINE=judge0
EXECUTION_TIMEOUT_MS=10000
EXEC_MEMORY_MB=256
client/.env
VITE_API_URL=http://localhost:4000/api # MUST end in /api
VITE_SOCKET_URL=http://localhost:4000 # origin, NO /api
CodeSync ships two first-class routes from the same codebase:
| Route | Engine | Hosts | Card? | Guide |
|---|---|---|---|---|
| βοΈ Card-free PaaS | judge0 |
Vercel + Render + Atlas + Upstash + Judge0 | β none | DEPLOY_JUDGE0.md |
| π³ Self-hosted VM | docker |
Droplet + docker-compose + nginx + Let's Encrypt | π³ Student Pack | PRODUCTION_DEPLOYMENT.md |
The live demo runs the card-free PaaS route β code-sync-chi-lemon.vercel.app
cd server && npm test # Jest + Supertest, in-memory MongoDB (no external DB)
Suites cover auth (register/login/refresh), rooms (CRUD/join/archive), sockets (join/leave/chat/cursor/yjs), and execution across all 7 languages.
Auth Β· /api/auth
| Method | Endpoint | Description |
|---|---|---|
| POST | /register |
Create account β access + refresh tokens |
| POST | /login |
Email/password β tokens |
| GET | /me |
Current user |
| POST | /refresh |
Exchange refresh token |
| POST | /logout |
Stateless logout |
Rooms Β· /api/rooms
| Method | Endpoint | Description |
|---|---|---|
| GET | / Β· /my/rooms |
List public / owned rooms |
| POST | / |
Create room |
| GETΒ·PUTΒ·DELETE | /:roomId |
Read / update / archive |
| GET·POST·DELETE | /:roomId/members⦠|
Manage roster & roles |
| GET | /:roomId/snapshots Β· /replay |
History & session replay |
| GETΒ·PUT | /:roomId/testcases |
Hidden tests (owner only) |
| POST | /:roomId/submit |
Run against hidden tests |
| GET | /:roomId/submissions |
Interview submissions |
Execute & Problems Β· /api/execute Β· /api/problems
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/execute |
Run code in the active engine |
| GET | /api/execute/history Β· /stats |
Run history & aggregates |
| GET | /api/problems Β· /:slug |
List / read problems |
| POST | /api/problems/:slug/run Β· /submit |
Samples / hidden-test judge |
| GET | /api/problems/meta/leaderboard |
Weighted leaderboard |
Client β Server
join-room Β· leave-room Β· yjs-update Β· yjs-awareness Β· request-sync Β·
cursor-update Β· selection-update Β· typing-start / typing-stop Β·
chat-message Β· language-change Β· set-interview-mode Β· interview-submit Β·
heartbeat
Server β Client
room-joined Β· user-joined / user-left Β· participant-list Β· yjs-update Β·
yjs-sync Β· yjs-awareness Β· cursor-update Β· selection-update Β·
user-typing / user-stopped-typing Β· chat-message Β· language-changed Β·
interview-mode-changed Β· interview-submitted Β· execution-started /
execution-result Β· your-role-changed
CodeSync/
βββ client/ # React + Vite SPA
β βββ src/
β βββ components/{Editor,Room}/ # Monaco, panels, modals
β βββ hooks/ # useYjs Β· useSocket
β βββ pages/ # Home Β· Room Β· Problems Β· Leaderboard Β· Learn Β· β¦
β βββ store/ # Redux slices (auth Β· room Β· problems)
β βββ services/api.js # Axios + JWT refresh
β βββ data/learn.js # Learn hub content
β
βββ server/ # Node + Express + Socket.IO
β βββ src/
β βββ routes/ # auth Β· rooms Β· execute Β· users Β· problems
β βββ socket/ # room Β· yjs Β· cursor handlers + auth
β βββ services/ # executionService Β· judge0Service Β· snapshotService
β βββ models/ # User Β· Room Β· Problem Β· Snapshot Β· Submission Β· β¦
β βββ seed/problems.js # idempotent practice-problem seed
β βββ utils/judge.js # engine-agnostic judge
β
βββ docs/ # ARCHITECTURE Β· DEPLOY_JUDGE0 Β· PRODUCTION_DEPLOYMENT
βββ docker-compose.yml # local stack
βββ docker-compose.prod.yml # VM stack (nginx + TLS)
Mohit Sharma β Full-Stack Developer Β· Competitive Programmer
If CodeSync helped or impressed you, consider leaving a β β it genuinely helps.