Skip to content
Β 
Β 

Repository files navigation

Code Canva

Code Canva is a collaborative coding workspace designed for teams to build, review, and run code together in a browser-based environment. The project combines a modern Next.js frontend with AI-powered coding assistance, collaborative editing patterns, and a scalable backend architecture for multi-user workspaces.

Overview

This application aims to provide:

  • Collaborative code editing with real-time workspace awareness
  • Team-based project organization and permission management
  • AI-powered code completion, explanation, and execution support
  • A developer-friendly interface inspired by modern coding platforms
  • Flexible data models for workspaces, files, comments, presence, and version history

System Architecture

                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚       USERS           β”‚
                              β”‚                       β”‚
                              β”‚  Browser A  Browser B β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                          β”‚
                              HTTPS / WebSocket
                                          β”‚
                                          β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚          NEXT.JS FRONTEND            β”‚
                    β”‚                                     β”‚
                    β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
                    β”‚  β”‚Monaco    β”‚  β”‚File Explorer  β”‚   β”‚
                    β”‚  β”‚Editor    β”‚  β”‚Workspace UI   β”‚   β”‚
                    β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
                    β”‚                                     β”‚
                    β”‚  Chat β”‚ Video β”‚ Terminal β”‚ Presence β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                         β”‚                     β”‚
                       REST                  WebSocket
                       HTTP                 Socket.IO
                         β”‚                     β”‚
                         β–Ό                     β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚             Next.JS SERVER            β”‚
              β”‚                                         β”‚
              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
              β”‚  β”‚          MIDDLEWARE LAYER          β”‚ β”‚
              β”‚  β”‚                                    β”‚ β”‚
              β”‚  β”‚ Auth β”‚ CORS β”‚ Rate Limit β”‚ Zod     β”‚ β”‚
              β”‚  β”‚ Error Handler β”‚ Logger β”‚ RBAC       β”‚ β”‚
              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
              β”‚                     β”‚                   β”‚
              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
              β”‚  β”‚             API ROUTES             β”‚ β”‚
              β”‚  β”‚                                    β”‚ β”‚
              β”‚  β”‚ /auth                             β”‚ β”‚
              β”‚  β”‚ /users                            β”‚ β”‚
              β”‚  β”‚ /workspaces                       β”‚ β”‚
              β”‚  β”‚ /files                            β”‚ β”‚
              β”‚  β”‚ /comments                         β”‚ β”‚
              β”‚  β”‚ /versions                         β”‚ β”‚
              β”‚  β”‚ /execution                        β”‚ β”‚
              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
              β”‚                     β”‚                   β”‚
              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
              β”‚  β”‚           CONTROLLERS              β”‚ β”‚
              β”‚  β”‚                                    β”‚ β”‚
              β”‚  β”‚ AuthController                     β”‚ β”‚
              β”‚  β”‚ WorkspaceController                β”‚ β”‚
              β”‚  β”‚ FileController                     β”‚ β”‚
              β”‚  β”‚ ExecutionController                β”‚ β”‚
              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
              β”‚                     β”‚                   β”‚
              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
              β”‚  β”‚             SERVICES               β”‚ β”‚
              β”‚  β”‚                                    β”‚ β”‚
              β”‚  β”‚ AuthService                        β”‚ β”‚
              β”‚  β”‚ WorkspaceService                   β”‚ β”‚
              β”‚  β”‚ FileService                        β”‚ β”‚
              β”‚  β”‚ CollaborationService               β”‚ β”‚
              β”‚  β”‚ ExecutionService                   β”‚ β”‚
              β”‚  β”‚ VersionService                     β”‚ β”‚
              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
              β”‚                  β”‚                       β”‚
              β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
              β”‚  β”‚          SOCKET.IO LAYER            β”‚ β”‚
              β”‚  β”‚                                    β”‚ β”‚
              β”‚  β”‚ workspace:join                    β”‚ β”‚
              β”‚  β”‚ editor:update                     β”‚ β”‚
              β”‚  β”‚ cursor:update                     β”‚ β”‚
              β”‚  β”‚ presence:update                   β”‚ β”‚
              β”‚  β”‚ chat:message                      β”‚ β”‚
              β”‚  β”‚ video:signal                      β”‚ β”‚
              β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                  β”‚                        β”‚
              β–Ό                  β–Ό                        β–Ό
      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      β”‚  PostgreSQL   β”‚  β”‚     Redis      β”‚      β”‚ Object Store  β”‚
      β”‚               β”‚  β”‚                β”‚      β”‚     S3        β”‚
      β”‚ Users         β”‚  β”‚ Presence       β”‚      β”‚               β”‚
      β”‚ Workspaces    β”‚  β”‚ Pub/Sub        β”‚      β”‚ Project files β”‚
      β”‚ Members       β”‚  β”‚ Socket adapter β”‚      β”‚ Assets        β”‚
      β”‚ Files         β”‚  β”‚ Sessions       β”‚      β”‚ Snapshots     β”‚
      β”‚ Versions      β”‚  β”‚ Rate limiting  β”‚      β”‚               β”‚
      β”‚ Messages      β”‚  β”‚                β”‚      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                                 β”‚
                                 β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚   COLLABORATION ENGINE β”‚
                     β”‚                        β”‚
                     β”‚      Yjs / CRDT        β”‚
                     β”‚                        β”‚
                     β”‚ Shared Documents       β”‚
                     β”‚ Conflict Resolution    β”‚
                     β”‚ Document Sync           β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
                                  β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚   EXECUTION SERVICE    β”‚
                     β”‚                        β”‚
                     β”‚ Queue / Worker         β”‚
                     β”‚                        β”‚
                     β”‚      Docker            β”‚
                     β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
                     β”‚   β”‚ Java         β”‚     β”‚
                     β”‚   β”‚ JavaScript   β”‚     β”‚
                     β”‚   β”‚ Python       β”‚     β”‚
                     β”‚   β”‚ C/C++        β”‚     β”‚
                     β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
                     β”‚                        β”‚
                     β”‚ CPU / RAM / Timeout    β”‚
                     β”‚ Isolation              β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Folder Structure

code-canva/
β”œβ”€β”€ README.md                               # Project overview, setup steps, and architecture docs
β”œβ”€β”€ components.json                         # shadcn/ui configuration and component registry
β”œβ”€β”€ docs/                                   # Design notes and product blueprint
β”‚   └── blueprint.md                        # Product/feature blueprint and architecture ideas
β”œβ”€β”€ prisma/                                 # Database and Prisma-related files
β”‚   β”œβ”€β”€ schema.prisma                       # Prisma schema for application data models
β”‚   └── migrations/                         # SQL migration history for the database
β”‚       └── ...
β”œβ”€β”€ public/                                 # Static assets served by Next.js (images, icons, etc.)
β”œβ”€β”€ src/                                    # Main application source code
β”‚   β”œβ”€β”€ ai/                                 # AI assistant features and Genkit flow logic
β”‚   β”‚   β”œβ”€β”€ dev.ts                          # Local AI/dev tooling setup
β”‚   β”‚   β”œβ”€β”€ genkit.ts                       # Genkit configuration and initialization
β”‚   β”‚   └── flows/                          # AI workflows for coding assistance
β”‚   β”‚       β”œβ”€β”€ code-completion-suggestions.ts  # Suggests code completions
β”‚   β”‚       β”œβ”€β”€ code-execution.ts               # Runs or prepares code execution logic
β”‚   β”‚       └── code-explanation-on-hover.ts    # Explains code when hovered over
β”‚   β”œβ”€β”€ app/                                # Next.js App Router pages and API routes
β”‚   β”‚   β”œβ”€β”€ api/                            # Server-side API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ invites/                    # Invite flows and invitations API
β”‚   β”‚   β”‚   β”œβ”€β”€ teams/                      # Team-related API routes
β”‚   β”‚   β”‚   └── webhooks/                   # Webhook handlers for external events
β”‚   β”‚   β”œβ”€β”€ canvas/                         # Collaborative coding workspace page
β”‚   β”‚   β”‚   β”œβ”€β”€ layout.tsx                  # Canvas-specific layout wrapper
β”‚   β”‚   β”‚   └── page.tsx                    # Main editor/canvas experience
β”‚   β”‚   β”œβ”€β”€ contact/                        # Public contact page
β”‚   β”‚   β”‚   └── page.tsx                    # Contact page UI
β”‚   β”‚   β”œβ”€β”€ globals.css                     # Global styling and theme layers
β”‚   β”‚   β”œβ”€β”€ layout.tsx                      # Root app layout and shell
β”‚   β”‚   β”œβ”€β”€ page.tsx                        # Landing/home page
β”‚   β”‚   └── teams/                          # Team management and team pages
β”‚   β”‚       β”œβ”€β”€ create/                     # Team creation flow
β”‚   β”‚       └── [teamId]/                   # Team-specific dashboard/page routes
β”‚   β”œβ”€β”€ components/                         # Reusable UI components for the app
β”‚   β”‚   β”œβ”€β”€ editor/                         # Editor-related UI components
β”‚   β”‚   β”‚   └── code-editor.tsx             # Monaco-based code editor component
β”‚   β”‚   β”œβ”€β”€ Footer/                         # Footer UI section
β”‚   β”‚   β”‚   └── Footer.tsx                  # Website footer markup
β”‚   β”‚   β”œβ”€β”€ HeroSection/                    # Marketing/landing banner section
β”‚   β”‚   β”‚   └── HeroSection.tsx             # Hero section UI
β”‚   β”‚   β”œβ”€β”€ OurServices/                    # Services/features section
β”‚   β”‚   β”‚   └── OurServices.tsx             # Services display component
β”‚   β”‚   β”œβ”€β”€ Roadmap/                        # Product roadmap UI
β”‚   β”‚   β”‚   └── Roadmap.tsx                 # Roadmap timeline section
β”‚   β”‚   β”œβ”€β”€ Testimonals/                    # Testimonial section
β”‚   β”‚   β”‚   └── Testimonials.tsx            # Customer testimonial cards
β”‚   β”‚   β”œβ”€β”€ layout/                         # App shell: header, sidebar, nav
β”‚   β”‚   β”‚   β”œβ”€β”€ app-header-content.tsx      # Header content area logic
β”‚   β”‚   β”‚   β”œβ”€β”€ app-sidebar.tsx             # Main sidebar navigation
β”‚   β”‚   β”‚   β”œβ”€β”€ header.tsx                  # Top header component
β”‚   β”‚   β”‚   β”œβ”€β”€ NavbarWrapper.tsx           # Navbar wrapper for layout behavior
β”‚   β”‚   β”‚   └── user-nav.tsx                # User profile menu and actions
β”‚   β”‚   β”œβ”€β”€ notifications/                  # Notification center UI
β”‚   β”‚   β”‚   └── notification-center.tsx     # In-app notifications panel
β”‚   β”‚   β”œβ”€β”€ ui/                             # Reusable shadcn/ui primitives
β”‚   β”‚   β”‚   └── ...shadcn/ui components     # Buttons, cards, dialogs, inputs, etc.
β”‚   β”‚   β”œβ”€β”€ logo.tsx                        # Brand/logo component
β”‚   β”‚   β”œβ”€β”€ theme-provider.tsx              # Theme context for Dark/Light mode
β”‚   β”‚   └── theme-toggle.tsx                # Theme switch control
β”‚   β”œβ”€β”€ generated/                          # Generated Prisma client files
β”‚   β”‚   └── prisma/                          # Auto-generated Prisma models and types
β”‚   β”‚       └── ...generated Prisma client files
β”‚   β”œβ”€β”€ hooks/                              # Reusable React hooks
β”‚   β”‚   β”œβ”€β”€ use-mobile.tsx                  # Detects mobile viewport state
β”‚   β”‚   └── use-toast.ts                    # Toast notification helper hook
β”‚   β”œβ”€β”€ lib/                                # Shared utilities and app libraries
β”‚   β”‚   β”œβ”€β”€ placeholder-images.json         # Placeholder media dataset
β”‚   β”‚   β”œβ”€β”€ prisma.ts                       # Prisma client singleton
β”‚   β”‚   └── utils.ts                        # Common helper functions
β”‚   β”œβ”€β”€ middleware.ts                       # Next.js middleware logic (auth, routing, security)
β”‚   β”œβ”€β”€ proxy.ts                            # Proxy layer or request forwarding logic
β”‚   └── schemaValidation/                   # Input validation schemas
β”‚       └── authSchemaValidation.ts         # Validation rules for auth-related requests
β”œβ”€β”€ next-env.d.ts                           # Next.js TypeScript environment declarations
β”œβ”€β”€ next.config.ts                          # Next.js framework configuration
β”œβ”€β”€ package.json                            # Project scripts and dependencies
β”œβ”€β”€ postcss.config.mjs                      # PostCSS processing configuration
β”œβ”€β”€ prisma.config.ts                        # Prisma runtime configuration
β”œβ”€β”€ tailwind.config.ts                     # Tailwind CSS configuration
β”œβ”€β”€ tsconfig.json                           # TypeScript compiler settings
β”œβ”€β”€ .gitignore                              # Git ignore rules
└── .env.example or .env.local             # Environment variables (if present in your setup)

Key Technology Stack

  • Next.js with App Router
  • TypeScript
  • Tailwind CSS
  • Prisma ORM
  • PostgreSQL
  • Monaco Editor
  • Genkit AI flows
  • shadcn/ui component library
  • Clerk for authentication workflows
  • Redis for real-time collaboration support

Data Models

The database is designed around shared workspaces, collaborative files, users, presence, messages, and version tracking.

users (
  id UUID PRIMARY KEY,
  username TEXT UNIQUE NOT NULL,
  email TEXT UNIQUE NOT NULL,
  password_hash TEXT,
  avatar_url TEXT,
  created_at TIMESTAMP DEFAULT now()
)

workspaces (
  id UUID PRIMARY KEY,
  name TEXT NOT NULL,
  owner_id UUID REFERENCES users(id),
  is_public BOOLEAN DEFAULT false,
  created_at TIMESTAMP DEFAULT now()
)

workspace_members (
  workspace_id UUID REFERENCES workspaces(id),
  user_id UUID REFERENCES users(id),
  role TEXT CHECK (role IN ('owner', 'editor', 'viewer')),
  joined_at TIMESTAMP DEFAULT now(),
  PRIMARY KEY (workspace_id, user_id)
)

nodes (
  id UUID PRIMARY KEY,
  workspace_id UUID REFERENCES workspaces(id),
  parent_id UUID REFERENCES nodes(id),
  name TEXT NOT NULL,
  type TEXT CHECK (type IN ('file', 'folder')),
  language TEXT,
  created_by UUID REFERENCES users(id),
  created_at TIMESTAMP DEFAULT now()
)

file_documents (
  file_id UUID PRIMARY KEY REFERENCES nodes(id),
  content TEXT,
  crdt_state BYTEA,
  updated_at TIMESTAMP DEFAULT now()
)

file_versions (
  id UUID PRIMARY KEY,
  file_id UUID REFERENCES nodes(id),
  content TEXT,
  created_by UUID REFERENCES users(id),
  created_at TIMESTAMP DEFAULT now()
)

workspace_presence (
  workspace_id UUID,
  user_id UUID,
  status TEXT,
  cursor_position JSONB,
  last_seen TIMESTAMP,
  PRIMARY KEY (workspace_id, user_id)
)

comments (
  id UUID PRIMARY KEY,
  file_id UUID REFERENCES nodes(id),
  user_id UUID REFERENCES users(id),
  content TEXT,
  line_number INT,
  created_at TIMESTAMP DEFAULT now()
)

workspace_messages (
  id UUID PRIMARY KEY,
  workspace_id UUID REFERENCES workspaces(id),
  user_id UUID REFERENCES users(id),
  content TEXT,
  created_at TIMESTAMP DEFAULT now()
)

Data Model Notes

  • users stores account and profile information.
  • workspaces represents a collaborative project space.
  • workspace_members manages access and permissions for each user in a workspace.
  • nodes supports file and folder hierarchy inside a workspace.
  • file_documents keeps the live document state and snapshot content.
  • file_versions stores change history for revisions and auditing.
  • workspace_presence tracks online status and editor cursor state.
  • comments adds contextual feedback tied to a file and line number.
  • workspace_messages stores team chat messages within a workspace.

Getting Started

Install dependencies:

npm install

Generate Prisma client and prepare the database:

npx prisma generate

Run the development server:

npm run dev

The app will be available locally through the configured Next.js port.


Project Goals

Code Canva is intended to become a browser-based collaborative coding platform with features similar to a modern remote IDE, including:

  • multi-user editing
  • workspace-level collaboration
  • AI support for coding tasks
  • version history and file snapshots
  • execution environments for code compilation and testing

Notes

This repository is currently structured as a modern Next.js application foundation for collaborative coding workflows. Additional backend services, real-time collaboration infrastructure, execution workers, and production deployment configuration can be layered on top of the existing front-end and Prisma foundation.

About

Code Canva is a modern, cloud-powered collaborative IDE built with Next.js, AI-driven developer tools, and a sleek shadcn/ui interface. It enables developers to write, understand, and execute code directly in the browser with intelligent AI assistance.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages