A real-time collaborative design tool with multiplayer synchronization, built with React, TypeScript, and Firebase.
- Real-time Collaboration: Multiple users can work on the same canvas simultaneously
- Optimistic Updates: Instant local feedback with "last write wins" conflict resolution
- Rectangle Creation: Create, move, resize, recolor, and delete rectangles
- Z-Index System: Automatic layering (most recent to front) with manual override
- Multiplayer Cursors: See other users' cursors with color labels at 60 FPS
- Presence Awareness: See who's online in the top header
- Pan & Zoom: Navigate the 5000x5000px canvas (10%-800% zoom)
- 3-Column UI: Left toolbar, center canvas, right properties panel
- Frontend: React + TypeScript, Konva.js, Tailwind CSS
- Backend: Firebase (Firestore + Realtime Database + Authentication + Hosting)
- State Management: React Context API
- Testing: Jest + React Testing Library
- Firestore: Persistent data (shapes with z-index, metadata)
- Realtime Database: Ephemeral data (cursors, selections, presence, activeEdits)
- Hybrid Approach: 97% cheaper for high-frequency updates, 3x lower latency
- Node.js 16+ and npm
- Firebase account (free tier works)
- Firebase CLI:
npm install -g firebase-tools
-
Clone the repository
git clone https://github.com/mlx93/Collab-Canvas.git cd Collab-Canvas/collabcanvas -
Install dependencies
npm install
-
Set up environment variables
Create a
.env.localfile in the root directory:REACT_APP_FIREBASE_API_KEY=your_api_key REACT_APP_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com REACT_APP_FIREBASE_DATABASE_URL=https://your_project.firebaseio.com REACT_APP_FIREBASE_PROJECT_ID=your_project_id REACT_APP_FIREBASE_STORAGE_BUCKET=your_project.appspot.com REACT_APP_FIREBASE_MESSAGING_SENDER_ID=your_sender_id REACT_APP_FIREBASE_APP_ID=your_app_id REACT_APP_FIREBASE_MEASUREMENT_ID=your_measurement_id
-
Start the development server
npm start
Open http://localhost:3000 to view it in the browser.
Run tests and develop locally without hitting production Firebase:
# Start all emulators
npm run emulators
# Emulator ports:
# - Auth: localhost:9099
# - Firestore: localhost:8080
# - Realtime Database: localhost:9000
# - Emulator UI: localhost:4000npm start- Run development servernpm test- Run test suitenpm run build- Build for productionnpm run emulators- Start Firebase emulators (add this to package.json)
src/
├── components/
│ ├── Auth/ # Login, Signup, AuthLayout
│ ├── Canvas/ # Canvas, LeftToolbar, PropertiesPanel, Rectangle, FPSCounter
│ ├── Collaboration/ # CursorOverlay, EditingIndicator, ActiveUsers
│ └── Layout/ # Header, MainLayout
├── context/ # AuthContext, CanvasContext
├── hooks/ # useAuth, useCanvas, useCursors, usePresence, useFPS
├── services/ # firebase, auth, canvas, cursor, presence, selection, activeEdits, zIndex
├── types/ # user.types, canvas.types, cursor.types
├── utils/ # constants, helpers, colors, throttle
└── __tests__/ # Integration tests
- Canvas ID:
default-canvas(single shared canvas) - Canvas Size: 5000x5000px
- Canvas Background: Off-white (#FAFAFA)
- Rectangle Default: 100x100px at viewport center
- Colors: Blue, Green, Red, Orange, Black (Material Design)
- Zoom Limits: 10% - 800%
# Run all tests
npm test
# Run specific test file
npm test auth.service.test.ts
# Run with coverage
npm test -- --coverageDeploy to Firebase Hosting:
# Build production bundle
npm run build
# Deploy
firebase deploy --only hosting
# Your app will be live at:
# https://your-project-id.web.appFollow the PR-by-PR approach outlined in tasks.md:
- PR #1: Project Setup ✅ (Current)
- PR #2: Authentication
- PR #3: UI Layout & Canvas
- PR #4: Rectangle Operations
- PR #5: Firestore Integration
- PR #6: Optimistic Updates & Conflict Resolution
- PR #7: Multiplayer Cursors
- PR #8: Presence Awareness
- PR #9: Deployment & Polish
This is an MVP project. Follow the tasks.md file for implementation order.
MIT
For questions or issues, please open a GitHub issue.