A real-time collaborative canvas application built with React, Konva, and Firebase. Create and manipulate shapes with multiple users simultaneously, featuring live cursor tracking and presence indicators.
Deployed URL: [Your Netlify URL will appear here after deployment]
After deploying to Netlify, update this section with your live URL.
- 🎨 Real-time collaborative canvas (5,000 x 5,000 pixels)
- 🖱️ Multi-user cursor tracking with <50ms perceived latency
- 👥 Live presence system showing online users
- 🔒 Google Sign-In authentication
- 📦 Shape creation (rectangles, circles, text)
- 🔄 Real-time synchronization across all connected users
- 🎯 Pan and zoom controls
- 💾 State persistence across sessions
- Frontend: React + Vite
- Canvas: Konva.js + React-Konva
- Backend:
- FastAPI (Python) with LangChain for AI agent
- Firebase (Authentication + Firestore + Realtime Database)
- AI Integration: LangChain + OpenAI with Server-Sent Events streaming
- Styling: Tailwind CSS
- Node.js (v16 or higher)
- Python 3.11+ (for AI backend)
- npm or yarn
- Firebase account
- OpenAI API key (for AI features)
-
Clone the repository
git clone <repository-url> cd collabcanvas
-
Install dependencies
npm install
-
Set up Firebase
- Create a new Firebase project at Firebase Console
- Enable Firestore Database
- Enable Realtime Database (for presence tracking)
- Enable Firebase Authentication (Google Sign-In provider)
- Copy your Firebase configuration
-
Configure frontend environment variables
Create a
.env.localfile in thewebapp/directory:VITE_FIREBASE_API_KEY=your_api_key VITE_FIREBASE_AUTH_DOMAIN=your_auth_domain VITE_FIREBASE_PROJECT_ID=your_project_id VITE_FIREBASE_STORAGE_BUCKET=your_storage_bucket VITE_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id VITE_FIREBASE_APP_ID=your_app_id VITE_FIREBASE_MEASUREMENT_ID=your_measurement_id VITE_FIREBASE_DATABASE_URL=your_database_url VITE_API_BASE_URL=http://localhost:8000
-
Set up AI backend
cd api python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
Create
.envfile inapi/directory:OPENAI_API_KEY=your_openai_api_key FIREBASE_CREDENTIALS_PATH=./serviceAccountKey.json
Download Firebase service account key and save as
serviceAccountKey.jsoninapi/directory. -
Run the development servers
Terminal 1 - Backend:
cd api source venv/bin/activate python scripts/run_local.py
Terminal 2 - Frontend:
cd webapp npm run dev- Frontend:
http://localhost:5173 - Backend API:
http://localhost:8000 - API Docs:
http://localhost:8000/docs
- Frontend:
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production build locallynpm run lint- Run ESLintnpm test- Run tests with Vitestnpm run test:ui- Run tests with UInpm run test:coverage- Run tests with coverage report
python scripts/run_local.py- Start FastAPI development serverpytest- Run backend testspytest --cov- Run tests with coverage
- A GitHub repository with this project
- A Netlify account (free tier works fine)
- Firebase project with credentials
-
Prepare your repository
Ensure all changes are committed and pushed to GitHub:
git add . git commit -m "Prepare for Netlify deployment" git push origin main
-
Connect to Netlify
- Go to Netlify
- Click "Add new site" → "Import an existing project"
- Select "GitHub" and authorize Netlify to access your repository
- Select your repository
-
Configure build settings
Netlify should auto-detect the settings from
netlify.toml, but verify:- Build command:
npm run build - Publish directory:
dist - Node version: 18
- Build command:
-
Add environment variables
In Netlify dashboard, go to Site settings → Environment variables and add:
VITE_FIREBASE_API_KEY=your_api_key VITE_FIREBASE_AUTH_DOMAIN=your_auth_domain VITE_FIREBASE_PROJECT_ID=your_project_id VITE_FIREBASE_STORAGE_BUCKET=your_storage_bucket VITE_FIREBASE_MESSAGING_SENDER_ID=your_messaging_sender_id VITE_FIREBASE_APP_ID=your_app_id VITE_FIREBASE_MEASUREMENT_ID=your_measurement_id VITE_FIREBASE_DATABASE_URL=your_database_url -
Configure Firebase for production
- In Firebase Console, go to Authentication → Settings → Authorized domains
- Add your Netlify domain (e.g.,
your-app.netlify.app)
-
Deploy
- Click "Deploy site" in Netlify
- Wait for the build to complete (usually 1-2 minutes)
- Your site will be live at
https://your-app.netlify.app
-
Test the deployment
- Open the deployed URL
- Test Google Sign-In authentication
- Open the app in 2 different browsers/devices
- Verify multiplayer cursor tracking works
- Test creating and moving shapes
- Verify state persists across page reloads
Once set up, Netlify automatically deploys whenever you push to your main branch:
git add .
git commit -m "Your changes"
git push origin mainBuild fails:
- Check the build logs in Netlify dashboard
- Ensure all environment variables are set correctly
- Verify
npm run buildworks locally
Authentication doesn't work:
- Verify Firebase authorized domains includes your Netlify domain
- Check that all Firebase environment variables are set in Netlify
Blank page after deployment:
- Check browser console for errors
- Verify the
_redirectsfile exists in thepublicfolder - Ensure environment variables start with
VITE_prefix
The following environment variables are required:
| Variable | Description |
|---|---|
VITE_FIREBASE_API_KEY |
Firebase API key |
VITE_FIREBASE_AUTH_DOMAIN |
Firebase auth domain |
VITE_FIREBASE_PROJECT_ID |
Firebase project ID |
VITE_FIREBASE_STORAGE_BUCKET |
Firebase storage bucket |
VITE_FIREBASE_MESSAGING_SENDER_ID |
Firebase messaging sender ID |
VITE_FIREBASE_APP_ID |
Firebase app ID |
VITE_FIREBASE_MEASUREMENT_ID |
Firebase measurement ID (optional) |
VITE_FIREBASE_DATABASE_URL |
Firebase Realtime Database URL |
src/
├── components/
│ ├── auth/ # Authentication components
│ ├── canvas/ # Canvas and shape components
│ └── ui/ # UI components (header, toolbar, etc.)
├── contexts/ # React contexts (Auth, Canvas)
├── hooks/ # Custom React hooks
├── lib/
│ └── firebase.js # Firebase configuration
├── utils/ # Utility functions
├── App.jsx # Main app component
└── main.jsx # App entry point
Make sure to configure Firestore security rules in the Firebase Console:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /projects/shared-canvas/{document=**} {
allow read, write: if request.auth != null;
}
}
}- 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
This project is licensed under the MIT License.
For issues and questions, please open an issue on GitHub.