# sp201004/collabcanvas architecture

> Architecture diagram of the GitHub repository sp201004/collabcanvas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sp201004/collabcanvas
- Repository: https://github.com/sp201004/collabcanvas

## Overview

CollabCanvas takes users from room selection or a shared room link into a drawing canvas, then synchronizes drawing, cursor, presence, and shared history through Socket.IO. Room state is held by the server and persisted to files; the browser also saves locally. The README documents the product capabilities, while source excerpts directly confirm key routing, event-handler, room-manager, and persistence calls. Some client wiring and feature implementations were not excerpted, so those relationships are documented rather than source-verified.

Main entry points: [`client/src/pages/canvas-page.tsx`](https://github.com/sp201004/collabcanvas/blob/main/client/src/pages/canvas-page.tsx) (Canvas page), [`server/routes.ts`](https://github.com/sp201004/collabcanvas/blob/main/server/routes.ts) (Socket event handlers), [`client/src/components/drawing-canvas.tsx`](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/drawing-canvas.tsx) (Drawing canvas), [`client/src/components/room-header.tsx`](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/room-header.tsx) (Room controls)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App routing<br/>[App.tsx]"]
  node_landing["Room entry<br/>[landing-page.tsx]"]
  node_canvas_page["Canvas page<br/>[canvas-page.tsx]"]
  node_room_header["Room controls<br/>[room-header.tsx]"]
end

subgraph group_drawing["Drawing workspace"]
  node_drawing_canvas["Drawing canvas<br/>[drawing-canvas.tsx]"]
  node_tool_panel["Tool selection<br/>[tool-panel.tsx]"]
  node_tool_settings["Tool settings"]
  node_color_picker["Color picker"]
  node_local_storage[("Browser persistence<br/>[persistence.ts]")]
end

subgraph group_realtime["Collaboration"]
  node_socket_hook["Socket handling<br/>[use-socket.ts]"]
  node_socket_client["Socket client<br/>[socket.ts]"]
  node_cursor_overlay["Cursor tracking<br/>[cursor-overlay.tsx]"]
  node_user_presence["User presence<br/>[user-presence.tsx]"]
  node_connection_status["Connection status"]
  node_performance["Performance metrics"]
end

subgraph group_server["Server state"]
  node_socket_routes["Socket event handlers<br/>[routes.ts]"]
  node_room_manager["Room state and history<br/>[rooms.ts]"]
  node_file_persistence[("Room file storage<br/>[persistence.ts]")]
  node_schema["Shared data schema<br/>[schema.ts]"]
end

node_participants(("Participants"))

node_participants -->|"choose room"| node_landing
node_participants -->|"draw together"| node_canvas_page
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_canvas_page
node_landing -->|"joins room"| node_canvas_page
node_canvas_page -->|"presents"| node_drawing_canvas
node_drawing_canvas -->|"uses tools"| node_tool_panel
node_drawing_canvas -->|"uses settings"| node_tool_settings
node_tool_settings -->|"offers color input"| node_color_picker
node_drawing_canvas -->|"saves canvas"| node_local_storage
node_canvas_page -->|"shows controls"| node_room_header
node_canvas_page -->|"syncs room"| node_socket_hook
node_socket_hook -->|"uses connection"| node_socket_client
node_socket_hook -->|"exchanges events"| node_socket_routes
node_socket_routes -->|"updates room"| node_room_manager
node_room_manager -->|"loads and saves"| node_file_persistence
node_socket_routes -->|"broadcasts cursors"| node_cursor_overlay
node_socket_routes -->|"broadcasts presence"| node_user_presence
node_room_header -->|"shows status"| node_connection_status
node_room_header -->|"shows metrics"| node_performance
node_socket_routes -->|"uses shared types"| node_schema
node_room_manager -->|"uses shared types"| node_schema

click node_app "https://github.com/sp201004/collabcanvas/blob/main/client/src/App.tsx"
click node_landing "https://github.com/sp201004/collabcanvas/blob/main/client/src/pages/landing-page.tsx"
click node_canvas_page "https://github.com/sp201004/collabcanvas/blob/main/client/src/pages/canvas-page.tsx"
click node_room_header "https://github.com/sp201004/collabcanvas/blob/main/client/src/components/room-header.tsx"
click node_drawing_canvas "https://github.com/sp201004/collabcanvas/blob/main/client/src/components/drawing-canvas.tsx"
click node_tool_panel "https://github.com/sp201004/collabcanvas/blob/main/client/src/components/tool-panel.tsx"
click node_tool_settings "https://github.com/sp201004/collabcanvas/blob/main/client/src/components/tool-settings-bar.tsx"
click node_color_picker "https://github.com/sp201004/collabcanvas/blob/main/client/src/components/ColorPicker/AdvancedColorPicker.tsx"
click node_local_storage "https://github.com/sp201004/collabcanvas/blob/main/client/src/lib/persistence.ts"
click node_socket_hook "https://github.com/sp201004/collabcanvas/blob/main/client/src/hooks/use-socket.ts"
click node_socket_client "https://github.com/sp201004/collabcanvas/blob/main/client/src/lib/socket.ts"
click node_cursor_overlay "https://github.com/sp201004/collabcanvas/blob/main/client/src/components/cursor-overlay.tsx"
click node_user_presence "https://github.com/sp201004/collabcanvas/blob/main/client/src/components/user-presence.tsx"
click node_connection_status "https://github.com/sp201004/collabcanvas/blob/main/client/src/components/connection-status.tsx"
click node_performance "https://github.com/sp201004/collabcanvas/blob/main/client/src/components/performance-metrics.tsx"
click node_socket_routes "https://github.com/sp201004/collabcanvas/blob/main/server/routes.ts"
click node_room_manager "https://github.com/sp201004/collabcanvas/blob/main/server/rooms.ts"
click node_file_persistence "https://github.com/sp201004/collabcanvas/blob/main/server/persistence.ts"
click node_schema "https://github.com/sp201004/collabcanvas/blob/main/shared/schema.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_landing,node_canvas_page,node_room_header toneBlue
class node_drawing_canvas,node_tool_panel,node_tool_settings,node_color_picker,node_local_storage toneAmber
class node_socket_hook,node_socket_client,node_cursor_overlay,node_user_presence,node_connection_status,node_performance toneMint
class node_socket_routes,node_room_manager,node_file_persistence,node_schema toneRose
class node_participants toneIndigo
```

## Components

### Client experience

- [App routing](https://github.com/sp201004/collabcanvas/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Room entry](https://github.com/sp201004/collabcanvas/blob/main/client/src/pages/landing-page.tsx): `client/src/pages/landing-page.tsx`
- [Canvas page](https://github.com/sp201004/collabcanvas/blob/main/client/src/pages/canvas-page.tsx): `client/src/pages/canvas-page.tsx`
- [Room controls](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/room-header.tsx): `client/src/components/room-header.tsx`

### Drawing workspace

- [Drawing canvas](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/drawing-canvas.tsx): `client/src/components/drawing-canvas.tsx`
- [Tool selection](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/tool-panel.tsx): `client/src/components/tool-panel.tsx`
- [Tool settings](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/tool-settings-bar.tsx): `client/src/components/tool-settings-bar.tsx`
- [Color picker](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/ColorPicker/AdvancedColorPicker.tsx): `client/src/components/ColorPicker/AdvancedColorPicker.tsx`
- [Browser persistence](https://github.com/sp201004/collabcanvas/blob/main/client/src/lib/persistence.ts): `client/src/lib/persistence.ts`

### Collaboration

- [Socket handling](https://github.com/sp201004/collabcanvas/blob/main/client/src/hooks/use-socket.ts): `client/src/hooks/use-socket.ts`
- [Socket client](https://github.com/sp201004/collabcanvas/blob/main/client/src/lib/socket.ts): `client/src/lib/socket.ts`
- [Cursor tracking](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/cursor-overlay.tsx): `client/src/components/cursor-overlay.tsx`
- [User presence](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/user-presence.tsx): `client/src/components/user-presence.tsx`
- [Connection status](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/connection-status.tsx): `client/src/components/connection-status.tsx`
- [Performance metrics](https://github.com/sp201004/collabcanvas/blob/main/client/src/components/performance-metrics.tsx): `client/src/components/performance-metrics.tsx`

### Server state

- [Socket event handlers](https://github.com/sp201004/collabcanvas/blob/main/server/routes.ts): `server/routes.ts`
- [Room state and history](https://github.com/sp201004/collabcanvas/blob/main/server/rooms.ts): `server/rooms.ts`
- [Room file storage](https://github.com/sp201004/collabcanvas/blob/main/server/persistence.ts): `server/persistence.ts`
- [Shared data schema](https://github.com/sp201004/collabcanvas/blob/main/shared/schema.ts): `shared/schema.ts`

### Other components

- **Participants**

## Connections

- Participants → Room entry: choose room (evidence: `README.md`)
- Participants → Canvas page: draw together (evidence: `README.md`)
- App routing → Room entry: routes to (evidence: `client/src/App.tsx`)
- App routing → Canvas page: routes to (evidence: `client/src/App.tsx`)
- Room entry → Canvas page: joins room (evidence: `README.md`)
- Canvas page → Drawing canvas: presents (evidence: `README.md`)
- Drawing canvas → Tool selection: uses tools (evidence: `README.md`)
- Drawing canvas → Tool settings: uses settings (evidence: `README.md`)
- Tool settings → Color picker: offers color input (evidence: `README.md`)
- Drawing canvas → Browser persistence: saves canvas (evidence: `README.md`)
- Canvas page → Room controls: shows controls (evidence: `README.md`)
- Canvas page → Socket handling: syncs room (evidence: `README.md`)
- Socket handling → Socket client: uses connection (evidence: `README.md`)
- Socket handling → Socket event handlers: exchanges events (evidence: `README.md`)
- Socket event handlers → Room state and history: updates room (evidence: `server/routes.ts`)
- Room state and history → Room file storage: loads and saves (evidence: `server/rooms.ts`)
- Socket event handlers → Cursor tracking: broadcasts cursors (evidence: `README.md`)
- Socket event handlers → User presence: broadcasts presence (evidence: `README.md`)
- Room controls → Connection status: shows status (evidence: `client/src/components/room-header.tsx`)
- Room controls → Performance metrics: shows metrics (evidence: `client/src/components/room-header.tsx`)
- Socket event handlers → Shared data schema: uses shared types (evidence: `server/routes.ts`)
- Room state and history → Shared data schema: uses shared types (evidence: `server/rooms.ts`)
