A modern real-time collaborative coding platform where developers can create rooms, write code together, manage files, chat in real time, and use an AI coding assistant.
| Feature | Description |
|---|---|
| ⚡ Real-Time Collaboration | Multiple users can work on the same workspace in real time |
| 🧠 AI Coding Assistant | Ask coding-related questions directly inside the workspace |
| 💻 Monaco Editor | VS Code-like code editing experience |
| 📁 File Explorer | Create and manage nested files and folders |
| 🔄 Yjs Synchronization | CRDT-based collaborative document synchronization |
| 🔌 Socket.IO | Real-time communication between clients and server |
| 💬 Real-Time Chat | Communicate with other workspace members |
| 👥 User Awareness | Track collaborators and their presence |
| 🔐 Authentication | Secure authentication using Better Auth |
| 🔑 Google OAuth | Sign in using Google |
| ✉️ Email Verification | Email verification using Resend |
| 🗄️ MongoDB | Persistent storage for application data |
| ⚡ Optimistic UI | Faster interactions through optimistic updates |
| 💾 Cached Explorer | Reduces unnecessary file explorer requests |
| Run supported code from the workspace | |
| 🎨 Responsive UI | Modern responsive developer-focused interface |
flowchart LR
UserA["👨💻 User A"]
UserB["👩💻 User B"]
subgraph CLIENT["Next.js Client"]
UI["React UI"]
Monaco["Monaco Editor"]
Zustand["Zustand Stores"]
YClient["Yjs Client"]
Awareness["Yjs Awareness"]
end
subgraph REALTIME["Real-Time Layer"]
Socket["Socket.IO"]
YProtocol["Y Protocol"]
end
subgraph SERVER["Backend"]
API["Next.js API Routes"]
SocketServer["Socket.IO Server"]
YServer["Yjs Collaboration"]
Auth["Better Auth"]
end
subgraph DATA["Data Layer"]
Mongo["MongoDB"]
Mongoose["Mongoose"]
end
subgraph AI["AI Layer"]
Groq["Groq API"]
end
UserA --> UI
UserB --> UI
UI --> Monaco
UI --> Zustand
Monaco <--> YClient
YClient <--> Awareness
YClient <--> YProtocol
YProtocol <--> Socket
Socket <--> SocketServer
SocketServer <--> YServer
UI --> API
API --> Mongoose
Mongoose --> Mongo
UI --> Auth
Auth --> Mongo
UI --> Groq
SocketServer --> Mongo
CodeSync uses Yjs + Socket.IO to synchronize code changes between users.
USER A
│
▼
Monaco Editor
│
▼
Yjs
│
Yjs Update
│
▼
Socket.IO
│
▼
Socket.IO Server
│
Broadcast
│
┌───────────┴───────────┐
│ │
▼ ▼
USER A USER B
│ │
▼ ▼
Yjs Doc Yjs Doc
│ │
▼ ▼
Editor Editor
- User edits a file.
- Monaco Editor produces the change.
- Yjs converts the change into a CRDT update.
- The update is sent through Socket.IO.
- The server broadcasts the update.
- Other connected clients receive the update.
- Yjs applies the update to their local document.
- Monaco reflects the synchronized content.
CodeSync/
│
├── app/
│ ├── api/
│ │ ├── auth/
│ │ └── playground/
│ │
│ ├── auth/
│ │ ├── login/
│ │ ├── signup/
│ │ └── verify/
│ │
│ ├── dashboard/
│ │ └── page.tsx
│ │
│ ├── playground/
│ │ ├── page.tsx
│ │ └── [roomId]/
│ │
│ ├── globals.css
│ ├── layout.tsx
│ ├── page.tsx
│ ├── not-found.tsx
│ └── global-error.tsx
│
├── components/
│ ├── constant/
│ ├── dashboard/
│ ├── editor/
│ │ ├── Module/
│ │ ├── Skeleton/
│ │ ├── ui/
│ │ ├── chat.tsx
│ │ ├── CodeWindow.tsx
│ │ ├── FileExplore.tsx
│ │ ├── MonacoEditor.tsx
│ │ ├── Terminal.tsx
│ │ ├── StatusBar.tsx
│ │ └── playHeader.tsx
│ │
│ ├── home/
│ │ ├── ui/
│ │ ├── Demo.tsx
│ │ ├── Footer.tsx
│ │ ├── Header.tsx
│ │ ├── Sidbar.tsx
│ │ ├── features.tsx
│ │ ├── hero.tsx
│ │ ├── howWorks.tsx
│ │ └── testimonial.tsx
│ │
│ ├── ui/
│ ├── login-form.tsx
│ └── signup-form.tsx
│
├── context/
│ ├── layout-context.tsx
│ ├── socketProvider.tsx
│ └── types.ts
│
├── lib/
│ ├── api/
│ ├── hooks/
│ ├── schema/
│ ├── store/
│ │ ├── actions/
│ │ ├── types/
│ │ ├── Codestore.ts
│ │ ├── Explorerstore.ts
│ │ └── Roomstore.ts
│ │
│ ├── awareness.ts
│ ├── auth.ts
│ ├── auth-client.ts
│ ├── db.ts
│ ├── email.ts
│ ├── features.ts
│ ├── getUserId.ts
│ ├── rateLimiter.ts
│ ├── socket.ts
│ ├── utils.ts
│ └── yjs.ts
│
├── model/
│ ├── directory.ts
│ ├── file.ts
│ └── room.ts
│
├── server/
│ ├── src/
│ ├── dist/
│ ├── package.json
│ └── tsconfig.json
│
├── public/
│ ├── architecture.gif
│ ├── logo.svg
│ ├── notFound.gif
│ ├── pixel-heart.gif
│ ├── super-saiyan-goku.gif
│ └── screenshots
│
├── next.config.ts
├── proxy.ts
├── package.json
├── tsconfig.json
└── readme.md
git clone https://github.com/your-username/codesync.git
cd codesyncnpm installcd server
npm install
cd ..Create:
.env.local
in the project root.
| Variable | Required | Used For | Example |
|---|---|---|---|
NEXT_PUBLIC_API_URL |
✅ | Frontend API base URL | http://localhost:3000 |
NEXT_PUBLIC_SOCKET_URL |
✅ | Socket.IO server URL | http://localhost:4000 |
MONGODB_URI |
✅ | MongoDB connection | mongodb+srv://... |
BETTER_AUTH_SECRET |
✅ | Better Auth session/security secret | your-secret |
GOOGLE_CLIENT_ID |
✅ | Google OAuth client ID | your-client-id |
GOOGLE_CLIENT_SECRET |
✅ | Google OAuth client secret | your-client-secret |
RESEND_API_KEY |
✅ | Email verification | re_... |
NEXT_PUBLIC_API_URL=http://localhost:3000
NEXT_PUBLIC_SOCKET_URL=http://localhost:4000
MONGODB_URI=your_mongodb_connection_string
BETTER_AUTH_SECRET=your_better_auth_secret
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
RESEND_API_KEY=your_resend_api_keyNever commit
.env.localto Git. Keep API keys, OAuth secrets, authentication secrets, and database credentials private.
CodeSync has two processes during development:
┌──────────────────────┐
│ Next.js App │
│ localhost:3000 │
└──────────┬───────────┘
│
│ Socket.IO
▼
┌──────────────────────┐
│ Socket.IO Server │
│ localhost:4000 │
└──────────────────────┘
npm run devOpen:
http://localhost:3000
cd server
npm run devThe server/ directory contains the dedicated real-time backend.
server/
│
├── src/
│
├── dist/
│
├── package.json
│
└── tsconfig.json
The server handles real-time communication through Socket.IO and collaboration-related events.
CodeSync supports nested project structures.
giga/
│
├── index.html
├── index.js
│
└── snakeGame/
└── snakeGame.html
Users can:
- Create files
- Create folders
- Create nested folders
- Open files
- Edit files
- Synchronize changes
- Manage project structure
The workspace includes a coding-focused AI assistant powered by Groq.
Example:
@bot explain this JavaScript function
The assistant can help with:
- Code explanations
- Debugging
- Programming concepts
- Code suggestions
- Technical questions
The assistant is intentionally focused on software-development-related requests.
CodeSync uses Better Auth for authentication.
Supported features:
- Email/password authentication
- Google OAuth
- Email verification
- Session management
- Protected routes
Resend is used to send verification emails.
The Next.js application can be deployed to Vercel.
Configure the production environment variables:
NEXT_PUBLIC_API_URL=https://your-domain.com
NEXT_PUBLIC_SOCKET_URL=https://your-socket-server.com
MONGODB_URI=your_production_mongodb_uri
BETTER_AUTH_SECRET=your_production_secret
GOOGLE_CLIENT_ID=your_production_google_client_id
GOOGLE_CLIENT_SECRET=your_production_google_client_secret
RESEND_API_KEY=your_production_resend_keyThe Socket.IO server should be deployed separately on a platform that supports:
- Persistent Node.js processes
- WebSocket connections
- Long-running server processes
After deployment, update:
NEXT_PUBLIC_SOCKET_URL=https://your-production-socket-server.com- Drag-and-drop file explorer
- File version history
- Collaborative cursors
- Voice/video communication
- Collaborative whiteboard
- Multiple chat channels
- Improved code execution
- Code autocomplete
- Workspace activity history
- Advanced room permissions
Code together. Build together. 🚀
A real-time collaborative coding workspace built with Next.js, Yjs, Socket.IO, MongoDB, and Groq.
⭐ If you find CodeSync useful, consider giving the repository a star!
Made with ❤️ for developers



