Skip to content

Davaakhatan/collabcanva

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

134 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CollabCanvas

A real-time collaborative canvas application where multiple users can create, edit, and manipulate shapes together in real-time. Built with React, TypeScript, Konva.js, and Firebase.

๐Ÿ”— Live Demo: https://collabcanva-d9e10.web.app


โœจ Features

Core Functionality

  • ๐ŸŽจ Interactive Canvas - 5000x5000px workspace with pan and zoom controls
  • ๐Ÿ“ฆ Multi-Shape Support - Create, move, resize, rotate, and delete rectangles, circles, triangles, text, ellipses, stars, polygons, paths, and images
  • ๐Ÿ”„ Real-time Synchronization - Changes sync instantly across all connected users (<100ms latency)
  • ๐Ÿ”’ Object Locking - Automatic locking when users interact with shapes to prevent conflicts
  • ๐Ÿ‘ฅ User Presence - See who's online and actively working on the canvas
  • ๐Ÿ–ฑ๏ธ Multiplayer Cursors - Track other users' cursor positions in real-time (when Realtime Database is enabled)
  • ๐ŸŽฏ Multi-Select - Select multiple shapes with Cmd/Ctrl+Click or box selection
  • ๐Ÿ“ Text Editing - Rich text formatting with font size, family, style (bold, italic, underline), and color
  • ๐Ÿ–ผ๏ธ Image Upload - Upload and embed images directly on the canvas
  • ๐ŸŽจ Color Picker - Change shape colors with recent colors and saved palettes
  • โ†ฉ๏ธ Undo/Redo - Full history system with keyboard shortcuts (Cmd+Z/Cmd+Shift+Z)
  • โŒจ๏ธ Keyboard Shortcuts - Comprehensive shortcuts for all operations
  • ๐Ÿ“ค Export - Export canvas as PNG or SVG
  • ๐Ÿค– AI Assistant - Natural language commands to create and manipulate shapes
  • ๐Ÿข Multi-Project System - Create and manage multiple projects with separate canvases
  • ๐Ÿ‘ค User Management - Profile, settings, and signout functionality
  • ๐ŸŒ™ Dark/Light Mode - Complete theme switching with proper canvas backgrounds

Authentication

  • ๐Ÿ“ง Email/Password Authentication - Secure user registration and login
  • ๐Ÿ’พ Persistent Sessions - Stay logged in across browser sessions

User Experience

  • ๐ŸŽฏ Modern UI/UX - Beautiful gradient design with glassmorphism effects
  • ๐Ÿ“ฑ Responsive Design - Works on desktop and tablet devices
  • โ“ Help System - Interactive tutorial overlay for new users
  • ๐ŸŽญ Empty State - Helpful onboarding when canvas is empty
  • โšก Performance - 60 FPS rendering with 500+ shapes
  • ๐Ÿ“Š Performance Monitor - Built-in FPS counter and stress testing tools
  • ๐ŸŒ™ Dark/Light Mode - Complete theme switching with proper canvas backgrounds
  • ๐ŸŽ›๏ธ Flexible Toolbar - Movable toolbar (sidebar or bottom docked)
  • ๐Ÿ“ Alignment Tools - Align and distribute shapes
  • ๐Ÿ“š Z-Index Management - Bring to front, send to back, layer management
  • ๐Ÿ”” Notifications - Real-time notification system
  • ๐Ÿ” Search - Search projects and canvases
  • ๐Ÿ‘ค User Profile - Profile management with settings and signout

๐Ÿ› ๏ธ Technology Stack

Frontend

  • React 18 - UI framework
  • TypeScript - Type-safe development
  • Vite - Lightning-fast build tool
  • Tailwind CSS - Utility-first CSS framework
  • Konva.js - HTML5 Canvas library for shape rendering
  • React Konva - React bindings for Konva

Backend & Services

  • Firebase Authentication - User management
  • Cloud Firestore - Real-time database for canvas state
  • Firebase Realtime Database - High-frequency updates for cursors (optional)
  • Firebase Hosting - Static site deployment
  • OpenAI API - AI-powered natural language commands

Developer Tools

  • ESLint - Code linting
  • PostCSS - CSS processing
  • Firebase CLI - Deployment management

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Firebase account
  • Git

Installation

  1. Clone the repository
git clone https://github.com/Davaakhatan/collabcanva.git
cd collabcanva
  1. Install dependencies
npm install
  1. Set up Firebase

    • Create a new Firebase project at Firebase Console
    • Enable Authentication (Email/Password only)
    • Create a Firestore database
    • (Optional) Create a Realtime Database for multiplayer cursors
    • Copy your Firebase configuration
  2. Configure environment variables

cp env.example .env

Edit .env with your Firebase credentials:

VITE_FIREBASE_API_KEY=your-api-key
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_DATABASE_URL=https://your-project-default-rtdb.firebaseio.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.firebasestorage.app
VITE_FIREBASE_MESSAGING_SENDER_ID=your-sender-id
VITE_FIREBASE_APP_ID=your-app-id
VITE_FIREBASE_MEASUREMENT_ID=your-measurement-id
VITE_OPENAI_API_KEY=your-openai-api-key

โš ๏ธ Security Note: Never commit your .env file to version control. It's already in .gitignore for your protection.

  1. Run development server
npm run dev

Open http://localhost:5173 in your browser.


๐Ÿ“ฆ Building for Production

  1. Build the application
npm run build
  1. Preview the production build locally
npm run preview

๐Ÿšข Deployment

Deploy to Firebase Hosting

  1. Install Firebase CLI (if not already installed)
npm install -g firebase-tools
  1. Login to Firebase
firebase login
  1. Initialize Firebase (first time only)
firebase init

Select:

  • Hosting
  • Firestore
  • Use existing project
  • Public directory: dist
  • Single-page app: Yes
  1. Deploy
npm run build
firebase deploy

Your app will be live at: https://your-project-id.web.app


๐ŸŽฎ How to Use

  1. Sign Up / Login

    • Create an account with email/password
    • Sign in with your registered credentials
  2. Canvas Controls

    • Pan: Click and drag on empty space
    • Zoom: Scroll with mouse wheel or use zoom controls
    • Add Shape: Click the "Add Shape" button (+ icon)
    • Move Shape: Click and drag a shape
    • Resize: Click a shape to select, then drag corner handles
    • Rotate: Click a shape to select, then drag rotation handle
    • Delete: Select a shape and press Delete or Backspace
    • Multi-Select: Hold Cmd/Ctrl and click multiple shapes, or drag to box select
    • Text Editing: Double-click text shapes to edit content
    • Color Change: Select shapes and use the color picker
    • Upload Images: Click the upload button to add images
    • Export: Click export button to download as PNG/SVG
  3. AI Assistant

    • Click the AI Assistant button to open the command panel
    • Try commands like:
      • "Create a red circle at 500, 300"
      • "Make a 3x3 grid of blue squares"
      • "Add a text box with 'Hello World'"
      • "Create 5 green triangles in a row"
  4. Keyboard Shortcuts

    • Cmd+Z / Ctrl+Z: Undo
    • Cmd+Shift+Z / Ctrl+Shift+Z: Redo
    • Delete / Backspace: Delete selected shapes
    • Arrow Keys: Move selected shapes
    • Cmd+D / Ctrl+D: Duplicate selected shapes
    • Esc: Deselect all shapes
    • ?: Show help overlay
  5. Collaboration

    • Multiple users can work simultaneously
    • Shapes are automatically locked when being edited
    • See other users' presence in the top-right panel

๐Ÿ“ Project Structure

collabcanvas/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ Auth/           # Login & Signup components
โ”‚   โ”‚   โ”œโ”€โ”€ AI/             # AI Command Panel
โ”‚   โ”‚   โ”œโ”€โ”€ Canvas/         # Canvas, Shape, Controls, TextFormatting
โ”‚   โ”‚   โ”œโ”€โ”€ Collaboration/  # Cursors, Presence
โ”‚   โ”‚   โ””โ”€โ”€ Layout/         # Navbar
โ”‚   โ”œโ”€โ”€ contexts/
โ”‚   โ”‚   โ”œโ”€โ”€ AuthContext.tsx      # Authentication state
โ”‚   โ”‚   โ”œโ”€โ”€ CanvasContext.tsx    # Canvas state management
โ”‚   โ”‚   โ””โ”€โ”€ ThemeContext.tsx     # Dark/Light mode
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ”œโ”€โ”€ useCanvasSync.ts     # Firestore sync
โ”‚   โ”‚   โ”œโ”€โ”€ useCursors.ts        # Cursor tracking
โ”‚   โ”‚   โ”œโ”€โ”€ useHistory.ts        # Undo/Redo system
โ”‚   โ”‚   โ””โ”€โ”€ usePresence.ts       # User presence
โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”œโ”€โ”€ firebase.ts          # Firebase initialization
โ”‚   โ”‚   โ”œโ”€โ”€ canvas.ts            # Canvas CRUD operations
โ”‚   โ”‚   โ”œโ”€โ”€ cursor.ts            # Cursor/presence operations
โ”‚   โ”‚   โ””โ”€โ”€ ai.ts                # AI command processing
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ constants.ts         # App constants
โ”‚   โ”‚   โ”œโ”€โ”€ helpers.ts           # Utility functions
โ”‚   โ”‚   โ””โ”€โ”€ performance.ts       # FPS monitoring
โ”‚   โ”œโ”€โ”€ App.tsx                  # Main app component
โ”‚   โ””โ”€โ”€ main.tsx                 # Entry point
โ”œโ”€โ”€ public/                      # Static assets
โ”œโ”€โ”€ firebase.json               # Firebase configuration
โ”œโ”€โ”€ firestore.rules             # Firestore security rules
โ”œโ”€โ”€ firestore.indexes.json      # Firestore indexes
โ””โ”€โ”€ .env                        # Environment variables (not in git)

๐Ÿ”’ Security

  • Environment Variables - API keys stored in .env file (not committed to git)
  • Firestore Rules - Database access controlled by authentication
  • Authentication - Firebase Authentication with secure session management
  • HTTPS - All traffic encrypted via Firebase Hosting

๐ŸŽฏ MVP Requirements Met

โœ… Basic canvas with pan/zoom - 5000x5000px bounded canvas
โœ… Multiple shape types - Rectangles, circles, triangles, text, ellipses, stars, polygons, paths, images
โœ… Object locking - Automatic locking during interactions
โœ… Real-time sync - <100ms shape synchronization via Firestore
โœ… Multiplayer cursors - Real-time cursor tracking (optional RTDB)
โœ… Presence awareness - See online users
โœ… User authentication - Email/Password authentication
โœ… Performance - 60 FPS with 500+ shapes
โœ… Deployed - Live on Firebase Hosting
โœ… Multi-select - Select and manipulate multiple shapes
โœ… Undo/Redo - Full history system with keyboard shortcuts
โœ… Export functionality - PNG and SVG export
โœ… AI Assistant - Natural language commands
โœ… Image upload - Upload and embed images
โœ… Text formatting - Rich text editing with fonts and styles
โœ… Color picker - Change shape colors
โœ… Keyboard shortcuts - Comprehensive shortcut system
โœ… Dark/Light mode - Complete theme switching with proper canvas backgrounds
โœ… Alignment tools - Align and distribute shapes
โœ… Z-index management - Layer management
โœ… Multi-Project System - Create and manage multiple projects
โœ… User Management - Profile, settings, and signout functionality
โœ… Notifications - Real-time notification system
โœ… Search - Search projects and canvases


๐Ÿš€ Performance

  • 60 FPS rendering during all interactions
  • <100ms shape change synchronization
  • <50ms cursor position updates (when Realtime Database enabled)
  • 500+ shapes supported without FPS drops
  • 5+ concurrent users tested successfully

๐Ÿ”ฎ Future Enhancements

  • Advanced shape editing (bezier curves, custom paths)
  • Shape grouping and ungrouping
  • Layer management panel
  • Custom shape libraries
  • Animation and transitions
  • Touch/mobile optimizations
  • Voice chat integration
  • Advanced AI features (auto-layout, design suggestions)
  • Plugin system for custom tools
  • Version history and branching
  • Collaborative comments and annotations

๐Ÿ› Known Issues

  • Multiplayer cursors require Realtime Database to be manually created in Firebase Console
  • Mobile touch gestures need optimization
  • Some complex multi-select operations may have minor performance impacts with 100+ shapes

๐Ÿ“ License

This project is built as an assessment project for educational purposes.


๐Ÿ™ Acknowledgments

  • React - Facebook Open Source
  • Konva.js - Anton Lavrenov
  • Firebase - Google
  • Tailwind CSS - Tailwind Labs

๐Ÿ‘จโ€๐Ÿ’ป Developer

Built with โค๏ธ by Davaakhatan

Live Demo: https://collabcanva-d9e10.web.app
Repository: https://github.com/Davaakhatan/collabcanva


๐Ÿ“ง Support

For questions or issues, please open an issue on GitHub or contact the developer.


Last Updated: January 2025

๐Ÿ”„ Recent Updates

Latest Fixes (January 2025)

  • โœ… Fixed Profile Dropdown - Sign out functionality now works correctly across all pages
  • โœ… Removed Legacy Canvas Button - Cleaned up home page interface
  • โœ… Fixed Project Counters - Active Projects and Canvases Created now show real data instead of static zeros
  • โœ… Improved User Experience - Dynamic messages based on actual project/canvas counts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages