A real-time collaborative whiteboard application built with Node.js, Express, Socket.io, and vanilla JavaScript. Multiple users can draw simultaneously on a shared canvas with live cursors, user management, and persistent drawing state.
- Multiple Drawing Tools: Pen, eraser, rectangle, circle, line
- Color Picker: Full color picker with preset colors
- Adjustable Brush Sizes: Small, medium, large, and extra-large sizes
- Clear Canvas: One-click canvas clearing
- Undo/Redo: Last 50 actions with keyboard shortcuts (Ctrl+Z, Ctrl+Y)
- Export: Download canvas as PNG image
- Live Drawing: See other users' drawings in real-time
- Live Cursors: See other users' cursors with their names and colors
- User Management: Automatic user assignment with unique colors
- Join/Leave Notifications: Real-time user activity notifications
- User Counter: Live count of connected users
- WebSocket Communication: Real-time bidirectional communication
- Drawing State Persistence: Automatic saving and restoration of drawing state
- Mobile Support: Touch events for tablets and mobile devices
- Responsive Design: Works on desktop, tablet, and mobile
- Keyboard Shortcuts: Power user features
- Performance Optimized: Efficient canvas rendering and data transmission
- Node.js (version 16 or higher)
- npm or yarn package manager
-
Clone or download the project
# If you have git git clone <repository-url> cd collaborative-whiteboard # Or extract the downloaded files to a folder
-
Install server dependencies
cd server npm install -
Start the server
npm start # Or for development with auto-restart: npm run dev -
Access the application
- Open your browser and navigate to:
http://localhost:3000 - Enter your name to join the collaborative whiteboard
- Start drawing with other users!
- Open your browser and navigate to:
collaborative-whiteboard/
โโโ client/ # Frontend files
โ โโโ index.html # Main HTML file
โ โโโ styles.css # CSS styling
โ โโโ app.js # Main JavaScript application
โ โโโ types.ts # TypeScript type definitions
โโโ server/ # Backend files
โ โโโ server.js # Express server with Socket.io
โ โโโ package.json # Server dependencies
โ โโโ drawingState.json # Persistent drawing data (auto-generated)
โโโ README.md # This file
cd server
npm run dev # Starts server with nodemon for auto-restart- Frontend: Edit
client/app.jsfor new drawing tools or UI features - Backend: Edit
server/server.jsfor new WebSocket events or API endpoints - Styling: Edit
client/styles.cssfor visual changes
The server uses the following default configuration:
- Port: 3000 (can be changed with
PORTenvironment variable) - CORS: Enabled for all origins (configure in
server/server.jsfor production)
- Join: Enter your name when prompted
- Choose Tool: Select pen, eraser, rectangle, circle, or line from the toolbar
- Pick Color: Use the color picker or preset colors
- Adjust Size: Choose brush size or use the slider
- Start Drawing: Click and drag on the canvas
- Ctrl+Z: Undo last action
- Ctrl+Y or Ctrl+Shift+Z: Redo
- Ctrl+S: Export canvas as PNG
- Pen: Free-hand drawing
- Eraser: Remove parts of drawings
- Rectangle: Draw rectangles (click and drag)
- Circle: Draw circles (click and drag from center)
- Line: Draw straight lines (click and drag)
- Clear: Clear entire canvas
- Live Cursors: See other users' mouse positions
- User Colors: Each user gets a unique color for their cursor
- Real-time Sync: All drawings appear instantly for all users
- User List: See all connected users in the right panel
Edit server/server.js to modify:
- Port number
- CORS settings
- Maximum drawing actions stored
- User color palette
- Auto-save frequency
Edit client/app.js to modify:
- Canvas size
- Maximum undo/redo history
- Drawing tool settings
- UI behavior
- Concurrent Users: Tested with 20+ users
- Drawing Actions: Stores last 1000 actions
- History: Last 50 undo/redo actions
- Canvas Size: 1200x800 pixels
- Efficient Data Transmission: Only essential drawing data is sent
- Action Limiting: Automatic cleanup of old drawing actions
- Canvas Optimization: Optimized rendering for smooth drawing
- Memory Management: Proper cleanup of disconnected users
- Install dependencies:
npm install - Start server:
npm start - Access at
http://localhost:3000
-
Environment Setup:
export NODE_ENV=production export PORT=3000
-
Security Configuration:
- Update CORS settings in
server/server.js - Add authentication if needed
- Configure proper error handling
- Update CORS settings in
-
Process Management:
# Using PM2 npm install -g pm2 pm2 start server/server.js --name "whiteboard" # Using systemd (Linux) # Create service file for automatic startup
-
Reverse Proxy (Recommended):
- Use Nginx or Apache to serve static files
- Proxy WebSocket connections to the Node.js server
FROM node:18-alpine
WORKDIR /app
COPY server/package*.json ./
RUN npm install --production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]-
"Cannot connect to server"
- Ensure the server is running on port 3000
- Check firewall settings
- Verify no other application is using port 3000
-
"Drawing not appearing for other users"
- Check browser console for WebSocket errors
- Ensure server is running and accessible
- Try refreshing the page
-
"Canvas not responding to touch on mobile"
- Ensure you're using a modern browser
- Try using a different browser
- Check if touch events are being blocked
-
"High memory usage with many users"
- The server automatically limits stored actions
- Restart the server periodically for large groups
- Consider implementing user limits
Enable debug logging by setting:
export DEBUG=socket.io:*
npm start- Text Tool: Add text labels to drawings
- Zoom/Pan: Navigate large canvases
- Layers: Organize drawings in layers
- Room System: Multiple separate whiteboards
- User Authentication: Secure user management
- Export Options: PDF, SVG, and other formats
- Drawing Templates: Pre-made shapes and templates
- Voice Chat: Integrated audio communication
- Screen Sharing: Share screen while drawing
- Drawing Recognition: Convert handwriting to text
- Version History: Track changes over time
- Collaborative Tools: Voting, commenting, etc.
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Test thoroughly
- Commit your changes:
git commit -m 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Socket.io for real-time communication
- Express.js for the web server
- HTML5 Canvas API for drawing functionality
- Modern CSS for responsive design
If you encounter any issues or have questions:
- Check the troubleshooting section above
- Search existing issues in the repository
- Create a new issue with detailed information
- Include browser version, operating system, and error messages
Happy Collaborating! ๐จโจ
Built with โค๏ธ for seamless real-time collaboration