A real-time collaborative whiteboard web application. Users can create or join rooms and draw together, with live cursor sharing and persistent drawing data.
- Create or join a room with a unique code
- Real-time collaborative drawing (multiple users)
- Live user cursor indicators
- Room list and browsing
- Responsive design for both desktop and tablet use
- Display cursors with different colors for each user
- Hide cursor when user is inactive
- Clean up old room data (rooms inactive for 24+ hours)
- Connection status indicator
- User count display
- Export whiteboard as image(.png)
- Frontend: React.js
- Backend: Node.js/Express.js
- Database: MongoDB
- Real-time Communication: Socket.io
- Node.js (v18+ recommended)
- MongoDB (local or remote)
-
Clone the repository:
git clone <your-repo-url> cd board
-
Install server dependencies:
cd server npm install -
Install client dependencies:
cd ../client npm install
-
Start MongoDB (if not already running):
mongod
-
Start the backend server:
cd server node server.jsThe server runs on
http://localhost:5100. -
Start the frontend:
cd ../client npm startThe app runs on
http://localhost:3000.
- Open the app in your browser.
- Create a new room or join an existing one using a 6-8 character code.
- Share the room code with others to collaborate in real-time.
- Export whiteboard as image(.png).
The application follows a client-server architecture:
- Frontend (React): Handles the user interface, drawing canvas, room management, and real-time updates via Socket.IO. Deployed as a static site (e.g., on Vercel).
- Backend (Node.js/Express/Socket.IO): Provides REST API endpoints for room management and real-time collaboration using WebSockets. Persists drawing data and room info in MongoDB. Deployed on a cloud platform (e.g., Render, Railway, Heroku).
- Database (MongoDB): Stores room and drawing data with TTL for automatic cleanup.
Data Flow:
- Users interact with the React frontend, which communicates with the backend via REST API and Socket.IO for real-time features.
- The backend manages room state, drawing data, and broadcasts updates to all connected clients in a room.
board/
client/ # React frontend
public/
src/
components/
DrawingCanvas.js
RoomJoin.js
Toolbar.js
UserCursors.js
Whiteboard.js
App.js
index.js
server/ # Node.js backend
models/
Room.js # Mongoose schema
routes/
rooms.js # Room-related API routes
socket/
whiteboard.js # Socket.IO handlers
server.js # Entry point
README.md
package.json
POST /api/rooms/create— Create a new roomPOST /api/rooms/join— Join (or create) a roomGET /api/rooms— List active rooms (last 24h)GET /api/rooms/:roomId— Get room info
- The backend connects to
mongodb://localhost:27017/whiteboard. - To change the port or MongoDB URI, set
PORTandMONGODB_URIin your environment.
- Push the
server/folder to a GitHub repository. - Create a new project on your chosen platform and connect your repo.
- Set environment variables:
MONGODB_URI(your MongoDB connection string)CLIENT_ORIGIN(your Vercel frontend URL, e.g.,https://your-app.vercel.app)PORT(usually set automatically by the platform)
- Deploy and note the backend URL (e.g.,
https://your-backend.onrender.com).
- Push the
client/folder to a GitHub repository. - Import the repo into Vercel and deploy.
- In your React app, update all API and Socket.IO URLs to use your backend’s public URL (e.g.,
https://your-backend.onrender.com). - Redeploy if you make changes to the backend URL.
MIT