# grilled-swampert/slate-board architecture

> Architecture diagram of the GitHub repository grilled-swampert/slate-board, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/grilled-swampert/slate-board
- Repository: https://github.com/grilled-swampert/slate-board

## Overview

##### Project type and purpose
- slateboard is a full-stack, real-time collaborative whiteboard application.
- The frontend is a React+TypeScript single-page app (Vite-powered).
- The backend is a Node.js/Express server using Socket.io for real-time messaging and an in-memory room manager for state.

##### File structure
- Top-level “frontend” and “backend” directories clearly separate concerns.
- Frontend:
- src/components – React UI pieces (Canvas, Toolbar, RoomHeader, etc.)
- src/config.tsx – runtime configuration (e.g., backend URL)
- assets/fonts, public – static assets
- Vite and TypeScript configs for build/dev
- Backend:
- server.js – Express+Socket.io initialization
- utils/roomManager.js – maintains room state and user lists in memory

##### Key insights from README
- Real-time drawing, cursor tracking, undo/redo, room-based sessions
- No external database—state is ephemeral and held in roomManager
- Frontend and backend communicate exclusively over WebSockets (Socket.io)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Tier
    subgraph "Client Tier"
        direction TB
        Browser["Browser / React SPA"]:::frontend
        subgraph "React SPA"
            direction TB
            Entry["main.tsx"]:::frontend
            Root["App.tsx"]:::frontend
            ConfigFE["config.tsx"]:::frontend
            Canvas["Canvas.tsx"]:::frontend
            Toolbar["Toolbar.tsx"]:::frontend
            RoomHeader["RoomHeader.tsx"]:::frontend
            Whiteboard["WhiteboardRoom.tsx"]:::frontend
            UserList["UserList.tsx"]:::frontend
            HomePage["HomePage.tsx"]:::frontend
            Public["public/"]:::assets
            Fonts["assets/fonts/"]:::assets
        end
    end

    %% Frontend Hosting & Config
    subgraph "Frontend Hosting & Build Config"
        direction TB
        Vite["vite.config.ts"]:::config
        Tailwind["tailwind.config.js"]:::config
        TS1["tsconfig.json"]:::config
        TS2["tsconfig.app.json"]:::config
        TS3["tsconfig.node.json"]:::config
        ESLint["eslint.config.js"]:::config
        EnvFE[".env"]:::config
        FEpkg["package.json"]:::config
        ViteServer["Vite Dev Server / Static CDN"]:::frontend
    end

    %% Backend Tier
    subgraph "Backend Tier"
        direction TB
        EnvBE[".env"]:::config
        BEpkg["package.json"]:::config
        Server["server.js\nExpress + Socket.io"]:::backend
        Handlers["index.js\nSocket.io Event Handlers"]:::backend
        RoomMgr["roomManager.js\n(in-memory store)"]:::store
    end

    %% Connections
    ViteServer -->|"HTTP GET /index.html"| Browser
    Browser -->|"initializes"| Entry
    Entry -->|"renders"| Root
    Root -->|"uses UI components"| Canvas
    Root -->|"uses UI components"| Toolbar
    Root -->|"uses UI components"| RoomHeader
    Root -->|"uses UI components"| Whiteboard
    Root -->|"uses UI components"| UserList
    Root -->|"uses UI components"| HomePage
    Root -->|"reads config"| ConfigFE
    Root -->|"serves assets"| Public
    Root -->|"loads fonts"| Fonts

    Browser -->|"WS connect"| Server
    Server -->|"on connect/draw/undo"| Handlers
    Handlers -->|"calls"| RoomMgr
    RoomMgr -->|"broadcast updates"| Handlers
    Handlers -->|"emit events"| Server
    Server -->|"WS emit"| Browser

    %% Build Config Relationships
    ViteServer --> Vite
    ViteServer --> Tailwind
    ViteServer --> TS1
    ViteServer --> TS2
    ViteServer --> TS3
    ViteServer --> ESLint
    ViteServer --> EnvFE
    ViteServer --> FEpkg

    Server --> EnvBE
    Server --> BEpkg
    Server --> Handlers
    Handlers --> RoomMgr

    %% Click Events - Frontend
    click Entry "https://github.com/grilled-swampert/slate-board/blob/main/frontend/src/main.tsx"
    click Root "https://github.com/grilled-swampert/slate-board/blob/main/frontend/src/App.tsx"
    click ConfigFE "https://github.com/grilled-swampert/slate-board/blob/main/frontend/src/config.tsx"
    click Canvas "https://github.com/grilled-swampert/slate-board/blob/main/frontend/src/components/Canvas.tsx"
    click Toolbar "https://github.com/grilled-swampert/slate-board/blob/main/frontend/src/components/Toolbar.tsx"
    click RoomHeader "https://github.com/grilled-swampert/slate-board/blob/main/frontend/src/components/RoomHeader.tsx"
    click Whiteboard "https://github.com/grilled-swampert/slate-board/blob/main/frontend/src/components/WhiteboardRoom.tsx"
    click UserList "https://github.com/grilled-swampert/slate-board/blob/main/frontend/src/components/UserList.tsx"
    click HomePage "https://github.com/grilled-swampert/slate-board/blob/main/frontend/src/components/HomePage.tsx"
    click Public "https://github.com/grilled-swampert/slate-board/tree/main/frontend/public"
    click Fonts "https://github.com/grilled-swampert/slate-board/tree/main/frontend/src/assets/fonts"
    click Vite "https://github.com/grilled-swampert/slate-board/blob/main/frontend/vite.config.ts"
    click Tailwind "https://github.com/grilled-swampert/slate-board/blob/main/frontend/tailwind.config.js"
    click TS1 "https://github.com/grilled-swampert/slate-board/blob/main/frontend/tsconfig.json"
    click TS2 "https://github.com/grilled-swampert/slate-board/blob/main/frontend/tsconfig.app.json"
    click TS3 "https://github.com/grilled-swampert/slate-board/blob/main/frontend/tsconfig.node.json"
    click ESLint "https://github.com/grilled-swampert/slate-board/blob/main/frontend/eslint.config.js"
    click EnvFE "https://github.com/grilled-swampert/slate-board/blob/main/frontend/.env"
    click FEpkg "https://github.com/grilled-swampert/slate-board/blob/main/frontend/package.json"

    %% Click Events - Backend
    click Server "https://github.com/grilled-swampert/slate-board/blob/main/backend/server.js"
    click Handlers "https://github.com/grilled-swampert/slate-board/blob/main/backend/sockets/index.js"
    click RoomMgr "https://github.com/grilled-swampert/slate-board/blob/main/backend/utils/roomManager.js"
    click EnvBE "https://github.com/grilled-swampert/slate-board/blob/main/backend/.env"
    click BEpkg "https://github.com/grilled-swampert/slate-board/blob/main/backend/package.json"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#0366d6,color:#000;
    classDef backend fill:#CFF2D1,stroke:#28a745,color:#000;
    classDef store fill:#FFE5B4,stroke:#FF8C00,color:#000;
    classDef config fill:#F0F0F0,stroke:#888,color:#000;
    classDef assets fill:#E8E1FC,stroke:#7F5AF0,color:#000;
```
