Skip to content
srinilaya08Public

About

Browser-based collaborative coding platform with real-time editing, chat, code execution, and authentication.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ CodeLab โ€” Browser-Based Collaborative Coding Platform

CodeLab is a full-stack, browser-based collaborative coding platform where users can create coding rooms, write code together in real time, chat with teammates, and work inside a shared workspace โ€” all without refreshing the page.

๐ŸŽฅ Demo Video

CodeLab Demo

โ–ถ๏ธ Watch the demo: https://youtu.be/2FDSyVD23rQ


๐Ÿ“ธ Screenshots

Home Page

Home Page

Dashboard

Dashboard

Collaborative Coding Room

Coding Room


โœจ Features

Implemented & tested

  • ๐Ÿ” Authentication โ€” registration and login with JWT-based auth and protected routes
  • ๐Ÿ  Dashboard โ€” create rooms and view My Rooms
  • ๐Ÿง‘โ€๐Ÿ’ป Coding rooms โ€” each room is a shared workspace at /room/:roomId
  • ๐Ÿ“ Monaco Editor โ€” the same editor technology that powers VS Code, running in the browser
  • โšก Real-time code sync โ€” edits made by one user appear instantly in other browsers in the same room, no refresh needed
  • ๐Ÿ’ฌ Room chat โ€” real-time messaging with correct per-user attribution
  • ๐Ÿ‘ฅ Multi-user tested โ€” verified with multiple browser sessions and separate accounts
  • โ–ถ๏ธ Code execution โ€” run code from the browser and view the output or errors
  • ๐Ÿณ Isolated execution with Docker โ€” user code runs in a container instead of inside the main Node.js process, keeping the backend safer
  • ๐Ÿ”’ Environment-based config โ€” secrets and URLs kept out of source code

๐Ÿ› ๏ธ Tech Stack

Layer Technologies
Frontend React.js, JavaScript (JSX), React Router, Monaco Editor, Socket.IO Client, HTML, CSS, Vite
Backend Node.js, Express.js, REST APIs, Socket.IO, JWT
Database PostgreSQL 18
Infrastructure / Tools Docker, Docker Desktop, WSL 2, Git, GitHub, VS Code, Thunder Client

The frontend is written in JavaScript/JSX, not TypeScript.


๐Ÿงฑ Architecture

React Frontend
       โ†“
REST API / Socket.IO
       โ†“
Node.js + Express Backend
       โ†“
PostgreSQL

CodeLab uses two communication channels, each for what it does best:

  • REST APIs โ†’ registration, login, creating/retrieving rooms, persistent data
  • Socket.IO โ†’ real-time code synchronization, chat, and room events

The React frontend never talks to the database directly; all data access goes through the Express backend.

Real-time collaboration flow

User A edits code in Monaco
        โ†“
Socket.IO client emits "code-change" (roomCode, fileId, code)
        โ†“
Socket.IO server receives the event
        โ†“
Server broadcasts to other sockets in the same room
        โ†“
User B's Monaco Editor updates instantly

Socket.IO rooms ensure users only receive events from the coding room they have joined.

Code-execution flow

User clicks "Run Code"
        โ†“
Backend
        โ†“
Docker container (isolated environment)
        โ†“
Program output / errors
        โ†“
Frontend

๐Ÿ—บ๏ธ Frontend Routes

Route Description
/ Home page
/login User login
/register User registration
/dashboard Create rooms and view My Rooms
/room/:roomId Collaborative coding room (editor + chat + sync)

๐Ÿ” Authentication

  1. User registers or logs in from the React frontend.
  2. The Express API validates credentials against PostgreSQL.
  3. On success, the server issues a JWT (expires in about 1 hour).
  4. The frontend sends the token with protected requests:
Authorization: Bearer <JWT>
  1. Authentication middleware on the backend verifies the token before allowing access.

The JWT secret is loaded from environment variables and is never hardcoded.


๐Ÿ“ Project Structure

codelab/
โ”œโ”€โ”€ frontend/     # React + Vite app (Monaco Editor, Socket.IO client)
โ””โ”€โ”€ backend/      # Express API + Socket.IO server (server.js)

โš™๏ธ Getting Started

Prerequisites

  • Node.js
  • PostgreSQL 18
  • Git
  • (Optional, for code execution work) Docker Desktop with WSL 2

1. Clone the repository

git clone https://github.com/srinilaya08/CodeLab.git
cd codelab

2. Set up the backend

cd backend
npm install

Create a .env file in backend/:

PORT=5000
DB_HOST=localhost
DB_PORT=5432
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=codelab
JWT_SECRET=your_strong_secret
FRONTEND_URL=http://localhost:5173

Start the server:

node server.js

The backend runs at http://localhost:5000.

3. Set up the frontend

cd frontend
npm install

Create a .env file in frontend/:

VITE_API_URL=http://localhost:5000
VITE_SOCKET_URL=http://localhost:5000

Start the dev server:

npm run dev

4. Try it out

  1. Register two accounts.
  2. Log in as User A in one browser and User B in another (or use an incognito window).
  3. Create a room from the dashboard and open the same room in both sessions.
  4. Edit code and send chat messages โ€” changes appear in real time.

๐Ÿงช Challenges Solved

  • 401 Unauthorized on protected routes โ€” fixed the JWT flow between frontend and backend middleware.
  • My Rooms retrieval โ€” corrected authenticated room fetching.
  • Real-time sync โ€” implemented Monaco โ†” Socket.IO synchronization across browsers.
  • Chat attribution โ€” fixed messages being tied to the wrong account across two sessions.
  • Docker setup โ€” configured Docker Desktop and WSL 2 and verified with hello-world and a Node.js container.

๐Ÿ”ฎ Roadmap

  • Support for more programming languages
  • Additional workspace capabilities (e.g., multi-file support)
  • Execution hardening (time and resource limits)
  • Production hardening and deployment

๐Ÿ“Œ Summary

CodeLab is a full-stack collaborative coding platform built with React, Node.js, Express, PostgreSQL, Socket.IO, JWT authentication, and Monaco Editor, with Docker used for the isolated code-execution architecture. Its standout capability is real-time collaborative coding: multiple users enter the same room, edit code together, and chat, with changes synced instantly and no page refresh.


๐Ÿ‘ค Author

Srinilaya


๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Browser-based collaborative coding platform with real-time editing, chat, code execution, and authentication.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages