A real-time collaborative whiteboard application built with React, Fabric.js, and WebSockets. Draw, sketch, and brainstorm together with your team β seamlessly and instantly.
- ποΈ Freehand Drawing β Smooth pen tool with pressure support
- π¦ Shapes & Objects β Rectangles, circles, lines, arrows, and text
- π§½ Eraser Tool β Precision erasing with adjustable size
- π¨ Color Palette β Custom colors, opacity control, and stroke width
- π₯ Real-Time Collaboration β See cursors and edits live with WebSockets
- β©οΈ Undo / Redo β Full history stack with keyboard shortcuts (
Ctrl+Z/Ctrl+Y) - πΌοΈ Image Upload β Drag & drop images onto the canvas
- π Zoom & Pan β Navigate large boards with ease
- πΎ Auto-Save β Persistent storage with MongoDB
- π Shareable Rooms β Unique room IDs for instant collaboration
- π± Responsive Design β Works on desktop and tablet
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT LAYER β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β React App βββββΊβ Fabric.js βββββΊβ Socket.io β β
β β (UI/State) β β (Canvas API)β β Client β β
β βββββββββββββββ βββββββββββββββ ββββββββ¬βββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββΌββββββββββββ
β
βΌ WebSocket
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SERVER LAYER β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Node.js βββββΊβ Socket.io βββββΊβ Redis β β
β β (Express) β β (WS Hub) β β (Pub/Sub) β β
β βββββββββββββββ βββββββββββββββ ββββββββ¬βββββββ β
β β β
β βββββββββββββββ βββββββββββββββ β β
β β MongoDB βββββΊβ AWS S3 / ββββββββββββ β
β β (Metadata) β β Cloudinary β (Session State) β
β βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | React 18 | UI framework |
| State | Zustand | Lightweight global state |
| Canvas | Fabric.js | 2D drawing & object manipulation |
| Styling | CSS Modules / Tailwind | Component styling |
| Real-Time | Socket.io Client | WebSocket communication |
| Backend | Node.js + Express | API & WebSocket server |
| Real-Time | Socket.io | Bidirectional event handling |
| Database | MongoDB | Whiteboard data persistence |
| Cache | Redis | Session state & pub/sub |
| Storage | AWS S3 / Cloudinary | Image asset storage |
- Node.js
>= 18.0.0 - npm
>= 9.0.0or yarn - MongoDB
>= 6.0(local or Atlas) - Redis
>= 7.0(local or cloud)
git clone https://github.com/yourusername/visual-whiteboard.git
cd visual-whiteboard# Install server dependencies
npm install
# Install client dependencies
cd client
npm install
cd ..Create .env files for both client and server:
Server (server/.env):
PORT=5000
MONGODB_URI=mongodb://localhost:27017/visual-whiteboard
REDIS_URL=redis://localhost:6379
JWT_SECRET=your-super-secret-jwt-key
CORS_ORIGIN=http://localhost:3000
AWS_S3_BUCKET=your-s3-bucket
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-keyClient (client/.env):
REACT_APP_API_URL=http://localhost:5000
REACT_APP_SOCKET_URL=http://localhost:5000# Start MongoDB & Redis (if running locally)
# macOS (using Homebrew)
brew services start mongodb-community
brew services start redis
# Linux
sudo systemctl start mongod
sudo systemctl start redis
# Start the backend server
npm run dev
# In a new terminal, start the React client
cd client
npm startThe app will be available at http://localhost:3000.
visual-whiteboard/
βββ client/ # React Frontend
β βββ public/
β βββ src/
β β βββ components/ # React components
β β β βββ Canvas/ # Fabric.js canvas wrapper
β β β βββ Toolbar/ # Drawing tools & controls
β β β βββ Collaboration/ # User cursors & presence
β β β βββ UI/ # Layout components
β β βββ hooks/ # Custom React hooks
β β β βββ useFabric.js # Fabric.js initialization
β β β βββ useWebSocket.js # Socket connection
β β β βββ useWhiteboardState.js # Global state
β β β βββ useHistory.js # Undo/redo logic
β β βββ store/ # Zustand stores
β β βββ utils/ # Helpers & serializers
β β βββ App.jsx
β βββ package.json
β
βββ server/ # Node.js Backend
β βββ config/ # DB & Socket config
β βββ handlers/ # Socket event handlers
β β βββ drawHandler.js
β β βββ objectHandler.js
β β βββ cursorHandler.js
β β βββ historyHandler.js
β βββ middleware/ # Auth & rate limiting
β βββ models/ # Mongoose schemas
β βββ rooms/ # Room management
β βββ routes/ # REST API routes
β βββ index.js # Entry point
β
βββ shared/ # Shared types & constants
βββ docker-compose.yml # Docker setup
βββ README.md
| Event | Direction | Description |
|---|---|---|
room:join |
Client β Server | Join a whiteboard room |
room:leave |
Client β Server | Leave current room |
draw:start |
Client β Server | Begin drawing stroke |
draw:move |
Client β Server | Drawing in progress (throttled) |
draw:end |
Client β Server | Complete drawing stroke |
object:modify |
Client β Server | Move, resize, or rotate object |
object:delete |
Client β Server | Delete selected objects |
cursor:move |
Client β Server | Mouse position update |
user:draw:start |
Server β Client | Another user started drawing |
user:draw:move |
Server β Client | Another user is drawing |
object:created |
Server β Client | New object added to canvas |
object:modified |
Server β Client | Object was modified |
objects:deleted |
Server β Client | Objects were removed |
user:joined |
Server β Client | New user entered room |
user:left |
Server β Client | User disconnected |
user:cursor |
Server β Client | Remote cursor position |
# Client tests
cd client
npm test
# Server tests
cd server
npm test# Build React app
cd client
npm run build
# Start production server
cd ../server
npm start# Start all services with Docker Compose
docker-compose up -d
# Services:
# - App: http://localhost:3000
# - API: http://localhost:5000
# - MongoDB: localhost:27017
# - Redis: localhost:6379- Basic drawing tools (pen, shapes, text)
- Real-time collaboration with WebSockets
- Undo / Redo functionality
- Image upload & drag-drop
- Zoom & pan navigation
- Sticky Notes β Add and edit sticky notes
- Templates β Pre-made board templates
- Comments β Add comments to specific areas
- Version History β Time-travel through board states
- Export β PDF, PNG, SVG export
- Auth & Teams β OAuth login and team workspaces
- Mobile App β React Native companion app
- Offline Support β Service worker & local sync
Contributions are welcome! Please follow these steps:
- 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
Please read our Contributing Guide for details on code style, testing, and commit conventions.
This project is licensed under the MIT License β see the LICENSE file for details.
- Fabric.js β Powerful canvas library
- Socket.io β Real-time bidirectional communication
- React β UI library
- Zustand β State management
Made with β€οΈ by Kunal Yelgate