Skip to content

jjjorgenson/gauntlet-colabcanvas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

76 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CanvasCollab

A real-time collaborative canvas application with AI-powered design assistance, built with React, Supabase, and Konva.js.

๐ŸŽฏ Project Overview

CanvasCollab is a modern, real-time collaborative design tool that allows multiple users to work together on a shared canvas. Users can create shapes, add text, and use natural language commands to generate complex layouts with the help of AI.

โœจ Key Features

Core Collaborative Infrastructure

  • Real-time synchronization - Sub-100ms object sync with zero visible lag
  • Conflict resolution - Handles simultaneous edits with last-write-wins strategy
  • Persistence & reconnection - Auto-reconnects with complete state preservation
  • User presence - Live user list with cursor tracking and idle detection

Canvas Features & Performance

  • Multi-shape support - Rectangles, circles, and text elements
  • Smooth interactions - Pan, zoom, drag, resize, and rotate
  • Multi-select - Shift-click and drag selection
  • Layer management - Z-index control with bring to front/send to back
  • Keyboard shortcuts - Delete, duplicate, arrow keys, and more
  • High performance - Handles 500+ objects with 5+ concurrent users

AI Canvas Agent

  • Natural language commands - "Create a red circle", "Make a login form"
  • 8+ command types - Creation, manipulation, layout, and complex commands
  • Complex layouts - Multi-element forms, navigation bars, and arrangements
  • Context awareness - References like "move that rectangle" work correctly
  • Sub-2 second responses - Fast AI processing with 90%+ accuracy

Advanced Features

  • Theme system - Light, Dark, and Darker themes with user preferences
  • Idle detection - Automatic cleanup of inactive users (5min idle, 10min removal)
  • Ownership system - Prevents conflicts during simultaneous edits
  • Real-time cursors - See other users' cursors and selections
  • Export capabilities - Save canvas as PNG/SVG

๐Ÿ› ๏ธ Tech Stack

Frontend

  • React 18 - Modern React with hooks and context
  • Vite - Fast build tool and dev server
  • Konva.js - High-performance 2D canvas library
  • CSS Variables - Dynamic theming system

Backend & Database

  • Supabase - Backend-as-a-Service with PostgreSQL
  • Real-time subscriptions - Live data synchronization
  • Row Level Security (RLS) - Secure data access
  • Edge Functions - Serverless API endpoints

AI Integration

  • OpenAI GPT-4 Turbo - Natural language processing
  • Function calling - Structured AI responses
  • Vercel Serverless - Secure API key handling

Development & Deployment

  • Vercel - Frontend and API deployment
  • GitHub - Version control and CI/CD
  • ESLint - Code quality and consistency

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Git for version control
  • Supabase account (free tier available)
  • OpenAI API key (for AI features)

1. Clone the Repository

git clone https://github.com/jjjorgenson/gauntlet-colabcanvas.git
cd gauntlet-colabcanvas

2. Install Dependencies

npm install

3. Environment Setup

Create a .env.local file in the root directory:

# Supabase Configuration
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key

# OpenAI API (for AI features)
OPENAI_API_KEY=your_openai_api_key

4. Database Setup

  1. Go to your Supabase Dashboard
  2. Navigate to SQL Editor
  3. Run the migration script from database/complete-migration.sql
  4. Run the idle detection setup from database/add-idle-detection.sql

5. Run Locally

npm run dev

The application will be available at http://localhost:5173

6. Deploy to Vercel

# Install Vercel CLI
npm i -g vercel

# Deploy
vercel

# Set environment variables in Vercel dashboard
# - OPENAI_API_KEY
# - VITE_SUPABASE_URL
# - VITE_SUPABASE_ANON_KEY

๐Ÿ“ Project Structure

CanvasCollab/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/          # React components
โ”‚   โ”‚   โ”œโ”€โ”€ AI/             # AI command bar
โ”‚   โ”‚   โ”œโ”€โ”€ Auth/           # Authentication
โ”‚   โ”‚   โ”œโ”€โ”€ Canvas/         # Canvas and shapes
โ”‚   โ”‚   โ”œโ”€โ”€ Presence/       # User presence
โ”‚   โ”‚   โ””โ”€โ”€ Settings/       # Theme settings
โ”‚   โ”œโ”€โ”€ hooks/              # Custom React hooks
โ”‚   โ”œโ”€โ”€ lib/                # Core utilities
โ”‚   โ””โ”€โ”€ utils/              # Helper functions
โ”œโ”€โ”€ api/                    # Vercel serverless functions
โ”œโ”€โ”€ database/               # SQL migrations
โ”œโ”€โ”€ docs/                   # Documentation
โ””โ”€โ”€ tasks/                  # Development tasks

๐Ÿ—๏ธ Architecture Overview

Real-time Collaboration

  • Optimistic updates - Immediate UI feedback
  • Conflict resolution - Last-write-wins with ownership locks
  • Interpolation - Smooth animations between states
  • Debounced sync - Efficient database updates

State Management

  • React Context - Global application state
  • Custom hooks - Encapsulated business logic
  • ObjectStore - External state management for canvas objects
  • Supabase subscriptions - Real-time data synchronization

AI Integration

  • Function calling - Structured AI responses
  • Context awareness - Command history and references
  • Error handling - Graceful fallbacks for AI failures
  • Security - Server-side API key management

๐ŸŽฎ Usage Examples

Basic Commands

"Create a red circle"
"Add a blue rectangle at center"
"Make a text box saying 'Hello World'"

Complex Commands

"Create a login form"
"Make a navigation bar with 4 menu items"
"Arrange all shapes in a horizontal row"

References

"Create a purple rectangle"
"Move that rectangle to the right"
"Make it bigger"

๐Ÿ”ง Development

Available Scripts

npm run dev          # Start development server
npm run build        # Build for production
npm run preview      # Preview production build
npm run lint         # Run ESLint

Code Style

  • ESLint configuration for consistent code style
  • Functional components with hooks
  • TypeScript-ready structure
  • Modular architecture with clear separation of concerns

๐Ÿ“Š Performance

  • Sub-100ms real-time synchronization
  • 500+ objects supported with smooth performance
  • 5+ concurrent users with minimal lag
  • Optimized rendering with Konva.js
  • Efficient database queries with proper indexing

๐Ÿ”’ Security

  • Row Level Security (RLS) on all database tables
  • Server-side API keys - Never exposed to client
  • Input validation - Sanitized user inputs
  • CORS configuration - Proper cross-origin setup
  • Environment variables - Secure configuration management

๐Ÿ“ˆ Monitoring & Analytics

  • Real-time presence - Track active users
  • Idle detection - Automatic cleanup of inactive sessions
  • Error logging - Comprehensive error tracking
  • Performance metrics - Built-in performance monitoring

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐ŸŽฅ Demo

[Demo Video Coming Soon] - Watch the collaborative features in action!

๐Ÿ†˜ Support

๐Ÿ™ Acknowledgments

  • Konva.js - Amazing 2D canvas library
  • Supabase - Excellent backend-as-a-service platform
  • OpenAI - Powerful AI capabilities
  • Vercel - Seamless deployment experience

Built with โค๏ธ for collaborative design

About

An AI-first Figma-like multi-user canvas application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •