Build, share, and collaborate on code with instant synchronization, live activity monitoring, and enterprise-grade performance.
CodeSync is a full-stack, real-time collaborative IDE that enables multiple developers to write, edit, and manage code simultaneously within shared workspaces. It features a professional-grade Monaco Editor, role-based access control (RBAC), live cursor tracking, version history, activity feeds, and instant file synchronization β all wrapped in a premium dark-theme UI inspired by Linear, Vercel, and Render.
| Login (Split-Screen Auth) | Dashboard & Workspace Management | Collaborative IDE |
|---|---|---|
![]() |
![]() |
![]() |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT (Browser) β
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββββββββ β
β β React 18 β β Monaco β β Socket.IO Client β β
β β + Vite β β Editor β β (Real-time events) β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββββββββ¬ββββββββββββββ β
β β β β β
β βββββββββββββββββββΌβββββββββββββββββββββββββ β
β β β
βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ
β HTTP REST + WebSocket (wss://)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SERVER (Node.js) β
β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββββββββ β
β β Express β β Socket.IO β β Middleware Layer β β
β β REST API β β Server β β (Auth, RBAC, FileAccess)β β
β ββββββββ¬ββββββββ ββββββββ¬ββββββββ ββββββββββββββββββββββββββββ β
β β β β
β βββββββββββ¬ββββββββ β
β β β
β ββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββ β
β β Controllers: Auth | Workspace | File | Member | Version β β
β β Activity | Session | Ownership β β
β ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
β β β
ββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β MongoDB Atlas β
β β
β Users β
β Workspaces β
β WorkspaceMembers β
β Files β
β FileVersions β
β ActivityLogs β
βββββββββββββββββββββββ
ββββββββββββ POST /api/auth/signup ββββββββββββ
β β βββββββββββββββββββββββββββΆ β β
β Client β { username, email, pwd } β Server β
β β β β
β β POST /api/auth/login β β
β β βββββββββββββββββββββββββββΆ β β
β β { email, password } β β
β β β β
β β βββββββββββββββββββββββββββ β β
β β { token, user } β β
β β β β
β β βββ All subsequent reqs βββΆ β β
β β Authorization: Bearer JWT β β
ββββββββββββ ββββββββββββ
β
βΌ
ββββββββββββββββ
β bcrypt hash β
β + JWT sign β
ββββββββββββββββ
User A (Editor) Server User B (Editor)
β β β
β join_workspace β β
β βββββββββββββββββββββββββββββΆβ β
β β user_joined (broadcast) β
β βββββββββββββββββββββββββββββββΆβ
β β β
β join_file (fileId) β β
β βββββββββββββββββββββββββββββΆβ β
β β β
β code_change (content) β β
β βββββββββββββββββββββββββββββΆβ β
β β code_update (debounced) β
β βββββββββββββββββββββββββββββββΆβ
β β β
β cursor_position β β
β βββββββββββββββββββββββββββββΆβ β
β β cursor_update (throttled) β
β βββββββββββββββββββββββββββββββΆβ
β β β
β β file_created / deleted β
β βββββββββββββββββββββββββββββββΆβ
β β (synced to all clients) β
β β β
β disconnect β β
β βββββββββββββββββββββββββββββΆβ β
β β user_left (broadcast) β
β βββββββββββββββββββββββββββββββΆβ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ROLE HIERARCHY β
ββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β β
β OWNER β β
All permissions β
β β β
Delete workspace β
β β β
Invite / remove members β
β β β
Change member roles β
β β β
Transfer ownership β
β β β
Update workspace settings β
β β β
Create / edit / rename / delete files β
β β β
Save & restore version history β
β β β
View all files & activity β
β β β
ββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β β
β EDITOR β β Cannot manage members or settings β
β β β
Create / edit / rename / delete files β
β β β
Save & restore version history β
β β β
Real-time code editing & cursor sync β
β β β
View all files & activity β
β β β
ββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β β
β VIEWER β β Cannot edit or create files β
β β β Code changes are blocked at socket level β
β β β
View all files (read-only) β
β β β
View activity feed β
β β β
ββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββ
β File Explorer β
β (Frontend) β
ββββββββββ¬ββββββββββ
β
ββββββββββββββββΌβββββββββββββββ
βΌ βΌ βΌ
ββββββββββββββ βββββββββββββ ββββββββββββββ
β Create Fileβ β Rename β β Delete β
β /Folder β β File/Fold β β File/Fold β
ββββββββ¬ββββββ βββββββ¬ββββββ ββββββββ¬ββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β REST API (Express) β
β POST /api/files β
β PATCH /api/files/rename/:id β
β DELETE /api/files/:id β
ββββββββββββββββββ¬βββββββββββββββββββββββββ
β
βββββββββββΌββββββββββ
βΌ βΌ βΌ
βββββββββββββ ββββββββ ββββββββββββ
β Name β β RBAC β β Activity β
β Normalize β βCheck β β Logging β
βββββββββββββ ββββββββ ββββββββββββ
β
βΌ
ββββββββββββββββββββ
β Socket.IO emit β
β file_created / β
β file_renamed / β
β file_deleted β
β (all clients) β
ββββββββββββββββββββ
| Category | Feature | Status |
|---|---|---|
| Authentication | User Registration (signup) | β Done |
| Authentication | User Login (JWT-based) | β Done |
| Authentication | Protected Routes (frontend guard) | β Done |
| Authentication | Token verification middleware | β Done |
| Workspace | Create workspace with language template | β Done |
| Workspace | List userβs workspaces (with roles) | β Done |
| Workspace | View workspace details (files, members) | β Done |
| Workspace | Delete workspace (owner only, cascading) | β Done |
| Workspace | Update workspace settings (name, language) | β Done |
| Collaboration | Real-time code sync via Socket.IO | β Done |
| Collaboration | Live cursor position tracking | β Done |
| Collaboration | User presence indicators (join/leave) | β Done |
| Collaboration | Debounced auto-save to MongoDB | β Done |
| File Management | Create files & folders | β Done |
| File Management | Rename files & folders (with child path update) | β Done |
| File Management | Delete files & folders (recursive) | β Done |
| File Management | Case-insensitive duplicate name prevention | β Done |
| File Management | File name normalization (sanitize specials) | β Done |
| File Management | Multi-level nested folder structure | β Done |
| Version History | Save file version snapshots | β Done |
| Version History | View version history per file | β Done |
| Version History | Restore to a previous version | β Done |
| Members | Invite member by email | β Done |
| Members | Join workspace via Room ID | β Done |
| Members | Change member roles (owner action) | β Done |
| Members | Remove member from workspace | β Done |
| Members | Transfer workspace ownership | β Done |
| Members | Members panel with live online status | β Done |
| RBAC | Owner / Editor / Viewer role enforcement | β Done |
| RBAC | Socket-level viewer write blocking | β Done |
| RBAC | Route-level role middleware | β Done |
| Activity | Activity logging (joins, edits, role changes) | β Done |
| Activity | Real-time activity feed sidebar | β Done |
| Session | Leave workspace session (manual) | β Done |
| Session | Auto-cleanup on socket disconnect | β Done |
| UI/UX | Premium dark theme (Linear/Vercel inspired) | β Done |
| UI/UX | Split-screen auth pages | β Done |
| UI/UX | Shimmer skeleton loaders | β Done |
| UI/UX | Route-based lazy loading | β Done |
| UI/UX | Hover prefetch navigation | β Done |
| Performance | HTTP gzip compression | β Done |
| Performance | .lean() Mongoose queries |
β Done |
| Performance | Compound indexes on MongoDB | β Done |
| Multi-Language | JS, TS, Python, C++, Java, Go, Rust templates | β Done |
| Services | User cascade delete (files, members, logs) | β Done |
| Category | Feature | Status |
|---|---|---|
| Auth | OAuth2 (GitHub/Google SSO) | π Planned |
| Auth | Password reset / forgot password | π Planned |
| Auth | Email verification on signup | π Planned |
| Collaboration | Integrated terminal (run code in-browser) | π Planned |
| Collaboration | In-editor chat / comments | π Planned |
| Collaboration | Conflict resolution (OT / CRDT) | π Planned |
| File Management | Drag-and-drop file/folder reorder | π Planned |
| File Management | File upload / download | π Planned |
| File Management | File search across workspace | π Planned |
| Workspace | Workspace templates / cloning | π Planned |
| Workspace | Workspace privacy (public/private toggle) | π Planned |
| Notifications | In-app notification system | π Planned |
| Notifications | Email notifications for invites | π Planned |
| DevOps | Docker containerization | π Planned |
| DevOps | CI/CD pipeline | π Planned |
| Testing | Unit & integration test suite | π Planned |
| UI | Light theme / theme toggle | π Planned |
| UI | Mobile responsive layout | π Planned |
The in-browser IDE is powered by Monaco Editor (the same engine behind VS Code), providing:
Full support for nested directory structures:
/ root-level files/src/, /src/components/, etc.Any editor can snapshot the current state of a file. The full history of snapshots is viewable, and any past version can be restored β effectively a manual βgitβ within the IDE.
Workspace owners can transfer ownership to any existing member. The previous owner is demoted to editor, and the new owner gets full admin privileges.
| Layer | Technology | Purpose |
|---|---|---|
| Frontend Framework | React 18 + Vite | SPA with fast HMR and lazy loading |
| Code Editor | Monaco Editor | VS Code-grade in-browser editing |
| Styling | CSS3 + Tailwind CSS 4 | Dark theme, glassmorphism, animations |
| Routing | React Router v6 | Client-side navigation with protected routes |
| HTTP Client | Axios | REST API communication |
| Notifications | React Hot Toast | In-app toast notifications |
| Backend Runtime | Node.js (ES Modules) | Server runtime |
| API Framework | Express.js | REST endpoint handling |
| Real-Time Engine | Socket.IO | WebSocket bidirectional events |
| Database | MongoDB (Mongoose 8) | Document store with indexing |
| Auth | JWT + bcrypt | Stateless token auth with hashed passwords |
| Compression | compression (gzip) | Response payload optimization |
| Dev Server | Nodemon | Auto-restart on backend file changes |
CodeSync/
β
βββ assets/ # Screenshots for README
β βββ login.png
β βββ dashboard.png
β βββ workspace.png
β
βββ backend/
β βββ controllers/
β β βββ activityController.js # GET activity logs
β β βββ authController.js # Signup / Login (JWT)
β β βββ fileController.js # CRUD files & folders
β β βββ memberController.js # Invite, join, role change, remove
β β βββ ownershipController.js # Transfer workspace ownership
β β βββ sessionController.js # Leave workspace session
β β βββ versionController.js # Save / view / restore versions
β β βββ workspaceController.js # CRUD workspaces + settings
β β
β βββ middleware/
β β βββ authMiddleware.js # JWT token verification
β β βββ filePermission.js # Verify user access to file's workspace
β β βββ permissionMiddleware.js # RBAC role checks (isOwner, isEditor, requireRole)
β β βββ workspaceAuth.js # Workspace membership verification
β β
β βββ models/
β β βββ ActivityLog.js # Action audit trail (indexed)
β β βββ File.js # Files & folders (compound unique index)
β β βββ FileVersion.js # Version snapshots
β β βββ User.js # User accounts (bcrypt hashed)
β β βββ Workspace.js # Workspace metadata
β β βββ WorkspaceMember.js # User-workspace membership & role
β β
β βββ routes/
β β βββ authRoutes.js # /api/auth/*
β β βββ fileRoutes.js # /api/files/*
β β βββ workspaceRoutes.js # /api/workspaces/*
β β
β βββ services/
β β βββ deleteUserCascade.js # Cascade-delete user data
β β
β βββ utils/
β β βββ logger.js # Activity logging utility
β β
β βββ server.js # Express + Socket.IO entry point
β βββ .env.example # Environment template
β βββ package.json
β
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ ActivityFeed.jsx # Live activity sidebar
β β β βββ CreateWorkspaceModal.jsx # Create workspace dialog
β β β βββ FileExplorer.jsx # Tree-view file browser
β β β βββ InviteModal.jsx # Email invite dialog
β β β βββ JoinWorkspaceModal.jsx # Join via Room ID
β β β βββ MembersPanel.jsx # Online members list with roles
β β β βββ ShareWorkspaceModal.jsx # Share workspace dialog
β β β βββ VersionHistory.jsx # File version timeline
β β β
β β βββ context/
β β β βββ AuthContext.jsx # Auth state provider
β β β
β β βββ pages/
β β β βββ Dashboard.jsx # Workspace listing & management
β β β βββ Login.jsx # Split-screen login
β β β βββ Signup.jsx # Split-screen signup
β β β βββ Workspace.jsx # Collaborative IDE view
β β β
β β βββ routes/
β β β βββ ProtectedRoute.jsx # Auth guard wrapper
β β β
β β βββ services/
β β β βββ api.js # Axios instance (base URL + token)
β β β βββ fileApi.js # File CRUD API calls
β β β βββ memberApi.js # Member management API calls
β β β βββ workspaceApi.js # Workspace API calls
β β β
β β βββ App.jsx # Root router + lazy loader
β β βββ main.jsx # React DOM entry point
β β βββ index.css # Global styles & design system
β β
β βββ index.html # HTML shell
β βββ vite.config.js # Vite config
β βββ tailwind.config.js # Tailwind CSS 4 config
β βββ postcss.config.js # PostCSS config
β βββ package.json
β
βββ Readme.md # Original README (legacy)
βββ README.md # β You are here
βββ .gitignore
/api/auth| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/signup |
Register a new user | β |
POST |
/login |
Login and receive JWT | β |
/api/workspaces| Method | Endpoint | Description | Min. Role |
|---|---|---|---|
POST |
/ |
Create a new workspace | Authenticated |
GET |
/ |
List userβs workspaces | Authenticated |
GET |
/:id |
Get workspace details (files, members) | Viewer |
DELETE |
/:id |
Delete workspace + cascade | Owner |
PATCH |
/:id/settings |
Update name & language | Owner |
GET |
/:id/activity |
Get activity log | Viewer |
DELETE |
/:id/session |
Leave workspace session | Authenticated |
POST |
/:id/invite |
Invite user by email | Owner |
POST |
/:id/join |
Join workspace via Room ID | Authenticated |
PATCH |
/:id/role |
Change member role | Owner |
DELETE |
/:id/member/:userId |
Remove a member | Owner |
POST |
/:id/transfer |
Transfer ownership | Owner |
/api/files| Method | Endpoint | Description | Min. Role |
|---|---|---|---|
POST |
/ |
Create file or folder | Editor |
GET |
/open/:id |
Get file content | Viewer |
PUT |
/:id |
Update file content | Editor |
PATCH |
/rename/:id |
Rename file or folder | Editor |
DELETE |
/:id |
Delete file or folder (recursive) | Editor |
POST |
/:fileId/version |
Save version snapshot | Editor |
GET |
/:fileId/history |
Get version history | Viewer |
POST |
/restore/:versionId |
Restore a file version | Editor |
| Event | Payload | Description |
|---|---|---|
join_workspace |
{ workspaceId, userId, username, color } |
Join a workspace room |
join_file |
{ fileId, username, color } |
Join a file editing room |
leave_file |
{ fileId } |
Leave a file editing room |
code_change |
{ fileId, code, userId } |
Send code changes (debounced save) |
cursor_position |
{ fileId, position, username, color } |
Broadcast cursor location |
| Event | Payload | Description |
|---|---|---|
user_joined |
{ userId, profileId, username, color, role } |
A user joined the workspace |
user_left |
{ userId, username } |
A user left the workspace |
code_update |
{ fileId, code } |
Code was changed by another user |
cursor_update |
{ userId, position, username, color } |
Cursor moved by another user |
file_created |
{ file } |
A new file/folder was created |
file_renamed |
{ fileId, name, oldName, path } |
A file/folder was renamed |
file_deleted |
{ fileId } |
A file/folder was deleted |
folder_children_deleted |
{ parentPath } |
Children of a folder were deleted |
member_updated |
{ userId, role, oldRole } |
A memberβs role was changed |
member_removed |
{ userId } |
A member was removed |
member_joined |
{ _id, user, role } |
A new member joined |
activity_update |
β | Refresh activity feed |
| Field | Type | Details |
|ββ-|ββ|βββ|
| username | String | Required, trimmed |
| email | String | Required, unique, lowercase |
| password | String | bcrypt-hashed |
| timestamps | Auto | createdAt, updatedAt |
| Field | Type | Details |
|ββ-|ββ|βββ|
| name | String | Required, max 80 chars |
| owner | ObjectId β User | Required |
| language | Enum | javascript, typescript, python, java, cpp, go, rust, html, css, json, txt |
| Field | Type | Details |
|ββ-|ββ|βββ|
| workspaceId | ObjectId β Workspace | Required |
| userId | ObjectId β User | Required |
| role | Enum | owner / editor / viewer |
| invitedBy | ObjectId β User | Optional |
| Field | Type | Details |
|ββ-|ββ|βββ|
| workspaceId | ObjectId β Workspace | Required |
| name | String | Required, trimmed |
| nameLower | String | Auto (pre-save hook) |
| path | String | Directory path, default / |
| type | Enum | file / folder |
| content | String | File contents |
| language | String | Auto-detected from extension |
| createdBy | ObjectId β User | β |
| lastEditedBy | ObjectId β User | β |
| Index | Compound Unique | (workspaceId, path, nameLower) |
| Field | Type | Details |
|ββ-|ββ|βββ|
| fileId | ObjectId β File | Required |
| content | String | Snapshot content |
| editedBy | ObjectId β User | Required |
| Field | Type | Details |
|ββ-|ββ|βββ|
| workspaceId | ObjectId β Workspace | Required |
| userId | ObjectId β User | Required |
| actionType | String | e.g. USER_JOINED, FILE_CREATED, ROLE_CHANGED |
| targetId | ObjectId | Optional target entity |
| metadata | Mixed | Additional context |
User clicks "Create Workspace" on Dashboard
β
βΌ
βββββββββββββββββββββββββββ
β CreateWorkspaceModal β
β - Enter workspace name β
β - Select language β
βββββββββββββ¬βββββββββββββββ
β POST /api/workspaces
βΌ
βββββββββββββββββββββββββββββββ
β Server creates: β
β 1. Workspace document β
β 2. WorkspaceMember (owner) β
β 3. Starter file (template) β
βββββββββββββ¬βββββββββββββββββββ
β
βΌ
Redirect to /workspace/:id
(Monaco Editor opens with starter file)
Owner clicks "Share" β ShareWorkspaceModal
β
ββββ Option A: Invite by Email
β β POST /api/workspaces/:id/invite
β β { email, role: 'editor' | 'viewer' }
β βΌ
β Server adds WorkspaceMember + emits member_joined
β
ββββ Option B: Share Room ID
β Invitee uses JoinWorkspaceModal
β POST /api/workspaces/:id/join
βΌ
Server adds WorkspaceMember (editor) + emits member_joined
1. Navigate to /workspace/:id
2. Socket connects β join_workspace event
3. Server broadcasts user_joined to all
4. User clicks a file β join_file event
5. User types β code_change events
6. Server broadcasts code_update to others viewing same file
7. Server debounces (5s) and saves to MongoDB
8. Cursor movements broadcast via cursor_position β cursor_update
9. On disconnect β user_left broadcast + active user cleanup
Editor clicks "Save Version" icon
β POST /api/files/:fileId/version
βΌ
FileVersion snapshot created (content + editedBy + timestamp)
β
βΌ
VersionHistory panel shows all snapshots for this file
β
βΌ
User clicks "Restore" on a past version
β POST /api/files/restore/:versionId
βΌ
File.content overwritten with snapshot content
(Socket will pick up and sync to all clients)
Owner opens MembersPanel β clicks "Transfer Ownership"
β POST /api/workspaces/:id/transfer
β { targetUserId }
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β 1. Current owner β demoted to editor β
β 2. Target user β promoted to owner β
β 3. Workspace.owner ref updated β
β 4. Activity logged β
βββββββββββββββββββββββββββββββββββββββββ
git clone https://github.com/your-username/CodeSync.git
cd CodeSync
cd backend
npm install
Create a .env file (use .env.example as reference):
PORT=3001
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
FRONTEND_URL=http://localhost:5173
Start the backend:
npm run dev # Development (with nodemon)
npm start # Production
cd frontend
npm install
Create a .env.development file:
VITE_BACKEND_URL=http://localhost:3001
Start the frontend:
npm run dev
Navigate to http://localhost:5173 in your browser.
.env)| Variable | Description | Example |
|---|---|---|
PORT |
Server port | 3001 |
MONGO_URI |
MongoDB connection string | mongodb+srv://... |
JWT_SECRET |
Secret key for JWT signing | your-secret-key |
FRONTEND_URL |
Frontend origin for CORS | http://localhost:5173 |
.env.development)| Variable | Description | Example |
|---|---|---|
VITE_BACKEND_URL |
Backend API base URL | http://localhost:3001 |
| Metric | Value | How |
|---|---|---|
| Auth page initial focus | ~0ms | Instant render, no blocking |
| Workspace navigation (prefetched) | < 150ms | Route-based lazy loading + hover prefetch |
| Database query latency reduction | ~40% | .lean() on all read queries |
| Real-time message latency | < 50ms | Throttled Socket.IO broadcasting |
| API response size reduction | ~60% | Gzip compression middleware |
| Auto-save debounce interval | 5 seconds | Prevents excessive MongoDB writes |
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License β see the LICENSE file for details.
Built with β€οΈ by the CodeSync team