A real-time collaborative drawing application built with React, Node.js, and Socket.IO. Draw together with up to 2 users simultaneously, featuring multiple drawing tools, voice notes, and seamless collaboration.
- Pen Tool: Free-form drawing with customizable stroke width and color
- Shape Tools: Rectangle, Circle, Diamond, Line, and Arrow
- Text Tool: Add text annotations anywhere on the canvas
- Eraser: Remove drawings with animated eraser trail
- Hand Tool: Pan and navigate around the canvas
- Color Palette: 10 predefined stroke colors and 10 background colors
- Stroke Width: 3 different stroke widths (1px, 2px, 4px)
- Opacity Control: Adjustable opacity from 0-100%
- Background Colors: Change canvas background in real-time
- Record: Click and hold to record voice messages
- Playback: Click voice note indicators to play back
- Positioning: Voice notes appear at cursor location
- Drag & Drop: Move voice notes around the canvas
- Zoom: Zoom in/out with mouse wheel or controls (25%-300%)
- Pan: Hand tool or drag to navigate large canvases
- Grid: Visual grid dots for precise positioning
- Reset: One-click zoom and pan reset
- 2-User Limit: Maximum 2 users per session
- Live Drawing: See drawings appear in real-time
- Synchronized State: All drawing data synchronized across users
- Room Management: Automatic room full detection
- Modular Architecture: Clean component-based structure
- Custom Hooks: Reusable logic for drawing, events, and socket handling
- TypeScript Support: Type definitions included
- Hot Module Replacement: Fast development experience
- Responsive Design: Works on different screen sizes
- Node.js 18+
- npm or yarn
-
Clone the repository
git clone <repository-url> cd collaborative-drawing-board
-
Install backend dependencies
cd backend npm install
-
Install frontend dependencies
cd frontend npm install
-
Start the backend server
cd backend npm start
Server will start on
http://localhost:3001
-
Start the frontend development server
cd frontend npm run dev
Frontend will be available on
http://localhost:5173
-
Open multiple browser tabs to test collaboration features
collaborative-drawing-board/
โโโ backend/
โ โโโ server.js # Express + Socket.IO server
โ โโโ package.json
โโโ frontend/
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โ โโโ Canvas.jsx # Main canvas container
โ โ โ โโโ Toolbar.jsx # Top toolbar with tools
โ โ โ โโโ Sidebar.jsx # Color and stroke controls
โ โ โ โโโ ZoomControls.jsx # Zoom and pan controls
โ โ โ โโโ VoiceNotes.jsx # Voice note indicators
โ โ โ โโโ EraserCursor.jsx # Custom eraser cursor
โ โ โ โโโ TextInput.jsx # Text input overlay
โ โ โ โโโ DrawingCanvas.jsx # Main drawing area
โ โ โ โโโ RoomFull.jsx # Room full error screen
โ โ โโโ hooks/ # Custom React hooks
โ โ โ โโโ useCanvasDrawing.js # Canvas drawing logic
โ โ โ โโโ useCanvasEvents.js # Mouse/drawing events
โ โ โ โโโ useEraserCursor.js # Eraser cursor management
โ โ โ โโโ useSocketHandler.js # Socket.IO communication
โ โ โ โโโ useVoiceRecording.js # Voice recording functionality
โ โ โโโ utils/
โ โ โ โโโ canvasUtils.js # Canvas utility functions
โ โ โโโ styles/
โ โ โ โโโ Canvas.css # Component styles
โ โ โโโ App.jsx
โ โ โโโ main.jsx
โ โโโ package.json
โ โโโ vite.config.js
โโโ README.md
- Framework: React 19.1.1
- Build Tool: Vite 7.1.2
- Icons: Lucide React 0.544.0
- Real-time: Socket.IO Client 4.8.1
- Styling: CSS3 with CSS Variables
- Development: ESLint, Hot Module Replacement
- Runtime: Node.js
- Framework: Express 5.1.0
- Real-time: Socket.IO 4.8.1
- CORS: Enabled for cross-origin requests
- Select a tool from the top toolbar
- Choose colors from the left sidebar
- Adjust stroke width and opacity as needed
- Start drawing on the canvas
- Click the microphone icon in the toolbar
- Allow microphone access when prompted
- Click and hold to record (up to ~30 seconds)
- Voice note appears at cursor location
- Click to play back or drag to reposition
- Share the URL with another person
- Both users can draw simultaneously
- All actions sync in real-time
- Maximum 2 users per session
Backend:
npm start # Start production server
npm run dev # Start development server
Frontend:
npm run dev # Start development server with HMR
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint
The project follows a modular architecture with clear separation of concerns:
- Components: Focused, single-responsibility React components
- Hooks: Reusable logic for state management and side effects
- Utils: Pure utility functions for canvas operations
- Styles: Centralized CSS with component-specific styles
- Custom Hooks Pattern: Logic extraction into reusable hooks
- Component Composition: Small, composable components
- Event-Driven Architecture: Socket.IO for real-time communication
- Separation of Concerns: Clear boundaries between UI, logic, and data
Port Already in Use
# Backend (3001)
lsof -ti:3001 | xargs kill -9
# Frontend (5173)
lsof -ti:5173 | xargs kill -9
Voice Notes Not Working
- Ensure microphone permissions are granted
- Check if browser supports MediaRecorder API
- Works best in Chrome/Edge/Firefox
Drawing Not Syncing
- Check if both frontend and backend are running
- Verify network connectivity
- Check browser console for Socket.IO errors
Canvas Not Responsive
- Try refreshing the page
- Check if WebGL is supported
- Clear browser cache if needed
- User Authentication: Login and user profiles
- Room Management: Create/join specific rooms
- Drawing History: Undo/redo functionality
- Export Options: Save as PNG/SVG/PDF
- More Tools: Brush, spray paint, text formatting
- Layer Support: Multiple drawing layers
- Mobile Support: Touch-friendly interface
- Persistence: Save drawings to database
- Real-time Chat: Text chat alongside drawing
- Screen Sharing: Share screen while drawing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Follow existing code style and patterns
- Add comments for complex logic
- Test new features thoroughly
- Update README if needed
- Keep commits atomic and well-described
This project is licensed under the MIT License - see the LICENSE file for details.
- Lucide React for beautiful icons
- Socket.IO for real-time communication
- Vite for fast development experience
- React Team for the amazing framework
If you encounter any issues or have questions:
- Check the Troubleshooting section
- Search existing issues
- Create a new issue with detailed description
- Include browser version and error messages
Made with โค๏ธ by the Collaborative Drawing Board Team
Happy Drawing! ๐จ