CodeCollab is a feature-rich, real-time collaborative coding platform that enables developers to write, run, and review code together β from anywhere. Built with Next.js 15, it combines live presence tracking, multi-language code execution, integrated AI assistance, and video calling into a single seamless environment.
- Live multi-cursor presence β see exactly where teammates are typing
- Conflict-free collaborative state powered by Liveblocks
- Per-user colour-coded cursor overlays and selection highlights
- Full folder/file tree with drag-and-drop-style management
- Create, rename, delete, cut, copy, and paste files and folders
- Upload local files or entire folder structures from your machine
- Download the entire workspace as a
.ziparchive
- Web languages (HTML/CSS/JS, React, Vue, Svelte) β live Sandpack preview with hot reload
- Server-side languages (Python, TypeScript, Java, C, C++, C#, Go, Ruby, Rust, PHP) β executed via the Wandbox API
- Integrated terminal (xterm.js) with
runcommand support - Split Preview + Console panel layout
- Powered by Google Gemini 1.5 Pro
- Context-aware: automatically reads the file you're currently editing
- Streamed responses with syntax-highlighted Markdown and code blocks
- Copy-to-clipboard for every code snippet
- Floating, draggable, resizable video call window
- Built on ZegoCloud UIKit Prebuilt
- Start/end call synced across all session participants via Liveblocks events
- Camera and mic toggles, screen sharing, participant list
- Room-scoped chat persisted in Liveblocks storage
- Read receipts β "Sent", "Read by N of M", "Read by all"
- Unread message badge on the chat toggle button
- Create a private GitHub repository directly from a session
- Commit selected files with a custom commit message
- View repository info and full sync operation history
- Requires the
repoOAuth scope β prompted automatically on sign-in
- Public and password-protected private sessions
- Shareable session link β join by entering the session ID
- Persistent session metadata stored in MongoDB
- Session owner can delete sessions; collaborators can leave
- Per-file change log (create, modify, rename, delete) in the sidebar
- GitHub commit history alongside file-change events
- Light / Dark mode toggle, applied both to the UI and Monaco Editor
- Persists per-user within the session
| Layer | Technology |
|---|---|
| Framework | Next.js 15 (App Router) |
| Language | TypeScript 5 |
| Styling | Tailwind CSS + shadcn/ui + Framer Motion |
| Database | MongoDB via Mongoose |
| Auth | NextAuth.js β GitHub OAuth + Credentials |
| Real-time | Liveblocks (presence, storage, events) |
| Code Editor | Monaco Editor (@monaco-editor/react) |
| Web Preview | Sandpack (@codesandbox/sandpack-react) |
| Code Execution | Wandbox REST API |
| Terminal | xterm.js (@xterm/xterm) |
| AI | Google Gemini 1.5 Pro (@google/generative-ai) |
| Video Calls | ZegoCloud UIKit Prebuilt |
| GitHub API | Octokit REST (@octokit/rest) |
| Deployment | Vercel |
- Node.js β₯ 18
- pnpm (recommended) β
npm install -g pnpm - A MongoDB instance (local or Atlas)
git clone https://github.com/your-username/code-collab.git
cd code-collabpnpm installCreate a .env file in the project root:
# MongoDB
MONGODB_URL=mongodb+srv://<user>:<password>@cluster.mongodb.net/codecollab
# NextAuth
NEXTAUTH_SECRET=your-random-secret-here
NEXTAUTH_URL=http://localhost:3000
# GitHub OAuth App (https://github.com/settings/developers)
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
# Liveblocks (https://liveblocks.io/dashboard)
NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY=pk_dev_xxxxxxxxxxxxxxxxxxxx
# Google Gemini AI (https://aistudio.google.com/app/apikey)
GEMINI_API_KEY=your-gemini-api-key
# ZegoCloud (https://console.zegocloud.com/)
NEXT_PUBLIC_ZEGO_APP_ID=123456789
NEXT_PUBLIC_ZEGO_SERVER_SECRET=your-zego-server-secretpnpm devOpen http://localhost:3000 in your browser.
βββ app/
β βββ api/
β β βββ auth/ # NextAuth handlers + signup endpoint
β β βββ chat/ # Gemini AI streaming endpoint
β β βββ execute/ # Wandbox code execution proxy
β β βββ github/ # Create repo + commit endpoints
β β βββ sessions/ # Session CRUD + file management
β βββ auth/ # Login / register pages
β βββ editor/ # Dashboard + [sessionid] editor page
β βββ page.tsx # Landing page
β
βββ components/
β βββ collab-editor/ # Core editor components
β β βββ editor.tsx # Monaco editor + live cursors
β β βββ sidebar.tsx # File tree + timeline
β β βββ toolbar.tsx # Session controls
β β βββ chat-panel.tsx # Real-time chat
β β βββ chat-interface.tsx # AI assistant
β β βββ code-execution.tsx # Run panel + terminal
β β βββ sandpack-preview.tsx # Web preview
β β βββ video-call.tsx # ZegoCloud wrapper
β βββ editor/dashboard/ # Session dashboard UI
β βββ ui/ # shadcn/ui primitives
β
βββ lib/
β βββ auth-opt.ts # NextAuth config
β βββ github-sync.ts # GitHub operation queue
β βββ monogdb.ts # Mongoose connection
β
βββ models/ # Mongoose schemas
β βββ User.ts
β βββ EditorSession.ts
β βββ SyncOperation.ts
β βββ SyncQueue.ts
β
βββ types/ # Global type declarations
β βββ next-auth.d.ts
β βββ types.d.ts
β
βββ liveblocks.config.ts # Presence + Storage type definitions
A session is the top-level collaboration unit. Each session has:
- A unique
roomIdused as both the URL slug and the Liveblocks room identifier - A list of participants with roles (
ownerorcollaborator) - Optional password protection for private sessions
- Optional linked GitHub repository
type Storage = {
document: LiveObject<{ content: string }>
files: LiveMap<string, FileData> // key = file path
messages: LiveList<Message>
timeline: LiveList<TimelineEntry>
roomSettings: LiveObject<RoomSettings>
executionResults: LiveMap<string, ExecutionResult>
}User clicks Run
β
βΌ
Language detected from file extension
β
ββ Web (HTML/JSX/TSX/Vue/Svelte) βββΊ Sandpack in-browser bundler
β
ββ Server-side βββΊ POST /api/execute βββΊ Wandbox API βββΊ stdout/stderr
| Language | Execution | Live Preview |
|---|---|---|
| HTML / CSS / JS | β | β Sandpack |
| React (JSX/TSX) | β | β Sandpack |
| Vue | β | β Sandpack |
| Svelte | β | β Sandpack |
| Python | β Wandbox | β |
| TypeScript (Node) | β Wandbox | β |
| JavaScript (Node) | β Wandbox | β |
| Java | β Wandbox | β |
| C / C++ | β Wandbox | β |
| C# | β Wandbox | β |
| Go | β Wandbox | β |
| Ruby | β Wandbox | β |
| Rust | β Wandbox | β |
| PHP | β Wandbox | β |
| Variable | Required | Description |
|---|---|---|
MONGODB_URL |
β | MongoDB connection string |
NEXTAUTH_SECRET |
β | Random string for JWT signing |
NEXTAUTH_URL |
β | Base URL of your deployment |
GITHUB_CLIENT_ID |
β | GitHub OAuth App client ID |
GITHUB_CLIENT_SECRET |
β | GitHub OAuth App client secret |
NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_KEY |
β | Liveblocks public API key |
GEMINI_API_KEY |
β | Google Generative AI key |
NEXT_PUBLIC_ZEGO_APP_ID |
β | ZegoCloud App ID |
NEXT_PUBLIC_ZEGO_SERVER_SECRET |
β | ZegoCloud server secret |
The project is pre-configured for Vercel.
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prodAdd all environment variables listed above in your Vercel project settings under Settings β Environment Variables.
Note: For GitHub OAuth, set your GitHub App's callback URL to
https://your-domain.vercel.app/api/auth/callback/github.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is for educational and demonstration purposes. See individual dependency licences for third-party terms.
- Liveblocks β real-time collaboration infrastructure
- Monaco Editor β the VS Code editor engine
- Sandpack β in-browser code bundler by CodeSandbox
- ZegoCloud β video call SDK
- Wandbox β online compiler API
- shadcn/ui β accessible component primitives
Built by Team BitMasters