Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coderoom

Coderoom is a collaborative coding platform built with Rust that allows multiple users to edit code together in real time, execute programs inside isolated Docker containers, and collaborate in shared coding rooms. It is designed as a systems programming project to explore networking, concurrency, process management, and real-time synchronization.


Features

  • JWT-based authentication
  • Create and join collaborative coding rooms
  • Real-time collaborative editing using CRDTs (Yrs)
  • Live cursor and participant awareness
  • Run code inside isolated Docker containers
  • Stream stdout and stderr back to every participant in real time
  • Live participant list
  • Automatic JWT refresh using refresh tokens
  • Multiple rooms with isolated execution environments

Note: Real-time chat is currently under development.


Tech Stack

Backend

  • Rust
  • Tokio
  • Axum
  • SQLx
  • PostgreSQL
  • Yrs (Rust CRDT)
  • Docker

Frontend

  • Next.js
  • React
  • Monaco Editor
  • TypeScript

Installation

Prerequisites

  • Rust
  • Docker Desktop
  • PostgreSQL

Clone the repository

git clone https://github.com/yourusername/coderoom
cd coderoom

Install dependencies

cargo build

Start Docker Desktop.

Create a .env file

DATABASE_URL=postgres://...
JWT_SECRET=your_secret

Run the server

cargo run

Run the frontend

cd frontend
npm install
npm run dev

Current Features

Authentication

Users can

  • Sign up
  • Log in
  • Automatically refresh expired access tokens
  • Log out

Authentication is handled using JWT access and refresh tokens stored as HTTP-only cookies.


Collaborative Rooms

Users can

  • Create rooms
  • Join existing rooms
  • View connected participants
  • Invite others using the room ID

Each room maintains its own

  • Shared document
  • Connected participants
  • Running execution process

Real-Time Editing

Coderoom uses Yrs, the Rust implementation of Yjs CRDTs.

Every edit made by one participant is immediately synchronized with everyone else without merge conflicts.

Features include

  • Character-level synchronization
  • Conflict-free merging
  • Shared document state
  • Cursor awareness

Code Execution

Each room can execute the current document.

Execution happens inside an isolated Docker container.

Current implementation supports

  • Python

Execution provides

  • Live stdout
  • Live stderr
  • Exit status
  • One running process per room

Process Isolation

Every execution

  • runs inside its own Docker container
  • has no access to the host filesystem
  • is isolated from other rooms
  • streams output through WebSockets

Architecture

image

Project Structure

src/
│
├── auth/
├── errors/
├── helpers/
├── websocket/
├── room/
├── state.rs
├── models.rs
├── messages.rs
└── main.rs

Example Workflow

User joins room
        │
        ▼
Edits shared document
        │
        ▼
CRDT updates broadcast
        │
        ▼
Everyone sees changes
        │
        ▼
User clicks Run
        │
        ▼
Rust writes temporary file
        │
        ▼
Docker starts container
        │
        ▼
Program executes
        │
        ▼
stdout/stderr streamed
        │
        ▼
All participants see output

Roadmap

Planned features include

  • Real-time chat
  • Support for more programming languages
  • Process timeouts
  • Memory limits
  • CPU limits
  • Docker sandbox improvements
  • Supervisor-based process management
  • Dashboard for active rooms
  • Execution history
  • Syntax diagnostics
  • File explorer

Notes

  • Each room maintains an independent CRDT document.
  • Only one execution can run per room at a time.
  • Access tokens refresh automatically using refresh tokens.
  • Code execution currently supports Python.
  • Chat functionality is not yet implemented.

License

MIT

About

a collaborative code editor in rust. webSockets, CRDTs, docker... the usual weekend activities

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages