A real-time collaborative coding platform built with MERN stack. Code together, chat live, and build amazing things as a team.
A full-stack MERN application that enables multiple developers to code together in real-time, featuring live chat, syntax highlighting, and seamless collaboration.
Ctrl/Cmd + S - Save codeCtrl/Cmd + Enter - Run codeCtrl/Cmd + F - FindCtrl/Cmd + H - ReplaceAlt + Up/Down - Move linecode-with-co/
├── server/ # Backend
│ ├── config/
│ │ └── db.js # Database configuration
│ ├── models/
│ │ ├── User.js # User schema
│ │ ├── Room.js # Room schema
│ │ └── Code.js # Code & Message schemas
│ ├── routes/
│ │ ├── auth.js # Authentication routes
│ │ ├── room.js # Room management routes
│ │ ├── code.js # Code operations routes
│ │ └── user.js # User routes
│ ├── controllers/
│ │ ├── authController.js # Auth logic
│ │ ├── roomController.js # Room logic
│ │ ├── codeController.js # Code logic
│ │ └── userController.js # User logic
│ ├── middleware/
│ │ └── auth.js # JWT authentication
│ ├── socket/
│ │ └── socketHandler.js # Socket.IO events
│ ├── server.js # Entry point
│ ├── package.json
│ └── .env
│
├── client/ # Frontend
│ ├── public/
│ │ └── index.html
│ ├── src/
│ │ ├── components/
│ │ │ ├── Auth/ # Login, Register
│ │ │ ├── Editor/ # Code editor
│ │ │ ├── Chat/ # Chat components
│ │ │ ├── Room/ # Room settings
│ │ │ └── Shared/ # Navbar, etc.
│ │ ├── pages/
│ │ │ ├── Home.jsx
│ │ │ ├── DashboardPage.jsx
│ │ │ ├── EditorPage.jsx
│ │ │ └── NotFound.jsx
│ │ ├── context/
│ │ │ ├── AuthContext.jsx # Auth state
│ │ │ └── SocketContext.jsx # Socket state
│ │ ├── services/
│ │ │ └── api.js # API configuration
│ │ ├── App.jsx
│ │ ├── App.css
│ │ └── index.js
│ ├── package.json
│ └── .env
│
└── README.md
Clone the repository
git clone https://github.com/yourusername/code-with-co.git
cd code-with-co
Setup Backend
cd server
npm install
Create .env file in server/ directory:
PORT=5000
MONGO_URI=mongodb://localhost:27017/code-with-co
# Or use MongoDB Atlas:
# MONGO_URI=mongodb+srv://username:[email protected]/code-with-co
JWT_SECRET=your_super_secret_jwt_key_here_change_in_production
NODE_ENV=development
CLIENT_URL=http://localhost:3000
Setup Frontend
cd ../client
npm install
Create .env file in client/ directory:
REACT_APP_API_URL=http://localhost:5000
REACT_APP_SOCKET_URL=http://localhost:5000
Setup MongoDB
Option A: Local MongoDB
# Windows
net start MongoDB
# Mac
brew services start mongodb-community
# Linux
sudo systemctl start mongod
Option B: MongoDB Atlas (Recommended)
MONGO_URI in server/.envTerminal 1 - Backend:
cd server
npm run dev
Terminal 2 - Frontend:
cd client
npm start
The application will open at http://localhost:3000
Build Frontend:
cd client
npm run build
Run Backend:
cd server
npm start
Register/Login
Dashboard
Create Room
Collaborative Coding
Room Management
Server (server/.env):
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
NODE_ENV=development
CLIENT_URL=http://localhost:3000
Client (client/.env):
REACT_APP_API_URL=http://localhost:5000
REACT_APP_SOCKET_URL=http://localhost:5000
POST /api/auth/register - Register new userPOST /api/auth/login - Login userGET /api/auth/me - Get current userPUT /api/auth/profile - Update profileGET /api/rooms - Get all public roomsGET /api/rooms/:roomId - Get room by IDPOST /api/rooms - Create new roomPUT /api/rooms/:roomId - Update roomDELETE /api/rooms/:roomId - Delete roomPOST /api/rooms/:roomId/join - Join roomPOST /api/rooms/:roomId/leave - Leave roomPOST /api/code/save - Save code versionGET /api/code/history/:roomId - Get code historyGET /api/users/:username - Get user profileGET /api/users/search - Search usersjoin-room - Join a coding roomleave-room - Leave a roomcode-change - Send code updateslanguage-change - Change programming languagesend-message - Send chat messagetyping-start - Start typing indicatortyping-stop - Stop typing indicatorroom-joined - Confirmation of room joinuser-joined - New user joined notificationuser-left - User left notificationcode-update - Receive code changeslanguage-updated - Language change notificationnew-message - Receive chat messageuser-typing - User typing notificationerror - Error messagesEditorPage.jsxEdit CSS variables in App.css:
:root {
--primary: #6366f1;
--secondary: #8b5cf6;
/* Add your colors */
}
MONGO_URI in .envPORT in server/.envserver.jsclient/.envcd client
npm run build
# Deploy build/ folder
cd server
# Push to platform
# Set environment variables
MONGO_URI with production credentialsContributions are welcome! Please follow these steps:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
For support, email [email protected] or open an issue on GitHub.




If you like this project, please give it a ⭐ on GitHub!
Built with ❤️ using MERN Stack