πŸš€ CodeSync β€” Real-Time Collaborative Coding Platform

TypeScript Next.js Socket.io Redis Docker WebRTC

A production-grade multiplayer code editor with AI assistance, video collaboration, and sandboxed execution.

Live Demo β€’ Documentation β€’ Deployment Guide


✨ Features

πŸ”„ Real-Time Collaboration

  • CRDT-based sync (Yjs) β€” conflict-free concurrent editing
  • Cursor presence β€” see where teammates are typing
  • Typing indicators β€” know when someone is active
  • Optimistic updates β€” instant local feedback, async server sync

πŸ“ Monaco Editor

  • VS Code-grade editing experience
  • Multi-language syntax highlighting
  • IntelliSense auto-completion
  • File explorer + tab system
  • Customizable themes (Dark, Light, High Contrast)
  • Keyboard shortcuts (Ctrl+S, Ctrl+Z, etc.)

🏠 Rooms System

  • Create/join coding rooms
  • Shareable invite links
  • Role-based access control (Owner / Editor / Viewer)
  • Persistent room state across sessions

πŸ’¬ Real-Time Chat

  • Room messaging with typing indicators
  • Code snippet sharing
  • Emoji support
  • Message persistence

⚑ Code Execution

  • Docker sandbox isolation β€” secure execution
  • Multi-language: JavaScript, Python, C++, Java
  • Resource limits (CPU, memory, time)
  • Real-time output streaming
  • Network isolation (prevents malicious code)

πŸ“Ή Video/Audio Calls

  • WebRTC peer-to-peer connections
  • Screen sharing
  • Mute/unmute controls
  • Connection quality indicators

πŸ€– AI Assistant

  • Powered by OpenRouter (Gemini, GPT-4, Claude)
  • Explain code / errors
  • Suggest fixes
  • Optimize performance
  • Generate documentation
  • Context-aware debugging

πŸ” Authentication

  • JWT-based auth (access + refresh tokens)
  • Google OAuth integration
  • Protected routes
  • Session persistence

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Client (Next.js 14)                        β”‚
β”‚  Monaco Editor β”‚ Socket.io β”‚ WebRTC β”‚ Zustand β”‚ Tailwind    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚ WebSocket + REST
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                Backend (Express + Socket.io)                   β”‚
β”‚  REST API β”‚ CRDT Engine β”‚ WebRTC Signaling β”‚ Execution Queue β”‚
β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β”‚              β”‚                            β”‚
β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ PostgreSQL β”‚ β”‚  Upstash  β”‚            β”‚ Docker Sandboxes β”‚
β”‚ (Supabase) β”‚ β”‚  Redis    β”‚            β”‚ (Isolated)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Design Decisions

Decision Rationale
Yjs (CRDT) over OT No central authority needed; guaranteed convergence; used by Notion & JupyterLab
Redis Pub/Sub Enables horizontal scaling without sticky sessions
Zustand over Redux Less boilerplate, better TS support, sufficient for our needs
Docker Isolation Security-first execution with resource limits and network isolation
Upstash Redis Serverless-friendly, free tier, REST + pub/sub support

πŸš€ Quick Start

Prerequisites

  • Node.js β‰₯ 20
  • pnpm β‰₯ 9
  • Docker (for code execution)
  • PostgreSQL (or Docker)

Setup

# Clone the repository
git clone https://github.com/yourusername/codesync.git
cd codesync

# Install dependencies
pnpm install

# Set up environment variables
cp apps/server/.env.example apps/server/.env
# Edit .env with your values

# Start database
docker compose -f docker/docker-compose.yml up postgres redis -d

# Run database migrations
cd apps/server && npx prisma migrate dev

# Build sandbox images (for code execution)
cd ../../docker/sandboxes
docker build -t codesync-sandbox-js ./javascript
docker build -t codesync-sandbox-python ./python

# Start development servers
cd ../..
pnpm dev

Access


πŸ“ Project Structure

codesync/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ web/              # Next.js 14 frontend
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ app/      # App Router pages
β”‚   β”‚   β”‚   β”œβ”€β”€ components/ # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ hooks/    # Custom hooks (useSocket, useWebRTC, etc.)
β”‚   β”‚   β”‚   β”œβ”€β”€ stores/   # Zustand state management
β”‚   β”‚   β”‚   β”œβ”€β”€ lib/      # Utilities (CRDT, API, WebRTC)
β”‚   β”‚   β”‚   └── types/    # TypeScript definitions
β”‚   β”‚   └── ...
β”‚   └── server/           # Express backend
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ config/   # Environment, Redis, Database
β”‚       β”‚   β”œβ”€β”€ middleware/ # Auth, rate limiting, security
β”‚       β”‚   β”œβ”€β”€ routes/   # REST API endpoints
β”‚       β”‚   β”œβ”€β”€ services/ # Business logic
β”‚       β”‚   β”œβ”€β”€ socket/   # WebSocket handlers
β”‚       β”‚   └── utils/    # Helpers (JWT, logger, errors)
β”‚       └── prisma/       # Database schema + migrations
β”œβ”€β”€ packages/
β”‚   └── shared/           # Shared types & constants
β”œβ”€β”€ docker/               # Docker configs + sandboxes
└── docs/                 # Architecture & deployment docs

πŸ”Œ WebSocket Events

Event Direction Description
room:join Client β†’ Server Join a coding room
room:joined Server β†’ Client Room data + initial state
doc:update Client β†’ Server CRDT document delta
doc:sync Server β†’ Client Broadcast delta to others
cursor:move Client β†’ Server Cursor position update
cursor:update Server β†’ Client Remote cursor positions
chat:send Client β†’ Server Send chat message
chat:message Server β†’ Client Broadcast message
exec:run Client β†’ Server Execute code
exec:output Server β†’ Client Streaming execution output
webrtc:offer Client β†’ Server WebRTC SDP offer relay
webrtc:answer Server β†’ Client WebRTC SDP answer relay
webrtc:ice-candidate Both ICE candidate exchange

πŸ”’ Security

  • Docker Sandbox: Network-disabled containers with CPU/memory limits
  • JWT Authentication: Short-lived access tokens + refresh rotation
  • Rate Limiting: Redis-backed distributed rate limiting
  • XSS Protection: Input sanitization + Helmet headers
  • CORS: Strict origin validation
  • Non-root Execution: Sandbox containers run as unprivileged users

πŸ“Š Performance

  • CRDT Sync: ~5ms latency for character-level updates
  • WebSocket: Binary protocol for minimal overhead
  • Debounced Sync: Batches rapid keystrokes before broadcast
  • Redis Caching: Room metadata + recent messages cached
  • Optimistic UI: Local changes applied instantly

πŸ› οΈ Tech Stack

Layer Technology
Frontend Next.js 14, TypeScript, Tailwind CSS
Editor Monaco Editor (VS Code engine)
State Zustand
Real-time Socket.io, Yjs (CRDT)
Video WebRTC
Backend Node.js, Express
Database PostgreSQL (Prisma ORM)
Cache Upstash Redis
Execution Docker containers
AI OpenRouter (multi-model)
Auth JWT + Google OAuth
Deploy Vercel + Railway

πŸ“ˆ Scalability

The architecture supports horizontal scaling out of the box:

  1. Multiple server instances share state via Redis pub/sub
  2. No sticky sessions required β€” any instance can handle any request
  3. CRDT convergence guarantees consistency without coordination
  4. Connection pooling via PgBouncer for database efficiency
  5. Queue-based execution prevents overload during high traffic

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

MIT License β€” see LICENSE for details.


Built with ❀️ demonstrating distributed systems, real-time sync, and collaborative architecture.

Generated by ML Intern

This model repository was generated by ML Intern, an agent for machine learning research and development on the Hugging Face Hub.

Usage

from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = 'myagent10101/codesync-collaborative-platform'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)

For non-causal architectures, replace AutoModelForCausalLM with the appropriate AutoModel class.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support