# wizard-aka-aman/skribbl architecture

> Architecture diagram of the GitHub repository wizard-aka-aman/skribbl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wizard-aka-aman/skribbl
- Repository: https://github.com/wizard-aka-aman/skribbl

## Overview

##### Project Type and Purpose
- Project Type: Single-page, real-time, front-end application built with Angular CLI v19.
- Purpose: Provide a Skribbl-style drawing and guessing game. Key features include canvas broadcasting, real-time chat, round/time management, and a synchronized scoreboard via SignalR.

##### File Structure
Top-level files & folders:
- angular.json, tsconfig*.json — Angular build & type-checking configs
- package.json, package-lock.json — npm dependencies (Angular, SignalR client, etc.)
- public — static assets (redirect rules, favicon, etc.)
- src/
– app/ — root Angular module with:
- app.component* — shell component (bootstraps the UI)
- app.config.ts — central app-level constants (e.g., API base URLs)
- app.routes.ts — route definitions (home, game, not-found)
- home/, layout/, pagenotfound/ — feature components for main UX screens
- service.service.ts — SignalR & HTTP wrapper handling real-time game events, chat, timers, scoreboard updates
– main.ts, index.html, styles.css — Angular bootstrap & global styling

##### Extract Insights from README
- SignalR Integration: real-time hubs for canvas, chat, active users, timer, scoreboard.
- Whiteboard Actions: undo/clear/send drawing strokes.
- Game Logic: word generation, guessing, points, rounds, audio feedback.
- UI Concerns: modals, auto-scrolling chat, ViewChild DOM manipulations.
- Service Abstraction: single serviceSrv encapsulates all backend comms.

##### Main Components & Their Relationships
a. Browser (Angular SPA)
– UI Components (Layout, Home/Game, Chat, Canvas, Scoreboard)
– Angular Service Layer (service.service.ts)
b. Backend Real-Time Hub (e.g., SignalR on ASP.NET Core or Node.js)
– Manages hubs for drawing updates, chat, user presence, timers, rounds
c. Backend REST API (if any)
– Auth, initial game setup, word list fetch
d. Database (e.g., SQL/NoSQL)
– Persists user profiles, game history, scores
e. External Services (optional)
– Authentication provider (OAuth/JWT issuer)
– CDN for static assets

Interactions:
- Service Layer ↔ SignalR Hub: Maintains open WebSocket connection for publish/subscribe of real-time events.
- Service Layer ↔ REST API: On init or fallback, retrieves config, word lists or user tokens.
- SignalR Hub ↔ Database: Hub methods read/write persistent game state.

##### Architectural Patterns & Principles
- Component-based UI (Angular): separation of concerns per feature.
- Single Responsibility Service (service.service.ts): abstracts comms, letting components remain stateless.
- Event-driven, Pub/Sub via SignalR: decouples sender (server hub) from multiple receivers (browsers).
- Reactive programming (RxJS): Observables for streaming updates.

##### Putting It All Together
[Browser / Angular SPA]
├─ UI Components (Layout, Game Canvas, Chat, Scoreboard)
└─ Service Layer (service.service.ts + RxJS Observables)
│                         │
▼                         ▼
[SignalR Hub] ←– WebSocket –→ [Browser Clients]
│                                        (multiple)
▼
[Database]
▲
│
[REST API] ←– HTTP –→ [Service Layer]

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser Layer
    subgraph "Browser / Angular SPA"
        direction TB
        subgraph "UI Components"
            direction TB
            AppShell["App Shell<br/>(app.component.ts/html/css)"]:::ui
            HomeComp["Home Component<br/>(home.component.ts)"]:::ui
            LayoutComp["Layout Component<br/>(layout.component.ts)"]:::ui
            PageNotFound["Page Not Found Component<br/>(pagenotfound.component.ts)"]:::ui
        end
        subgraph "Configuration & Routing"
            direction TB
            AppConfig["App Config<br/>(app.config.ts)"]:::config
            AppRoutes["App Routes<br/>(app.routes.ts)"]:::config
        end
        subgraph "Service Layer"
            direction TB
            ServiceLayer["Service Layer<br/>(service.service.ts)"]:::service
        end
    end

    %% External Bootstrap & Styles
    subgraph "Bootstrap & Globals"
        direction TB
        MainTs["Main Bootstrap (main.ts)"]:::init
        IndexHtml["Global Template (index.html)"]:::init
        StylesCss["Global Styles (styles.css)"]:::init
    end

    %% Backend Services
    subgraph "Backend Services"
        direction TB
        SignalRHub["SignalR Hub<br/>(WebSocket)"]:::backend
        RESTAPI["REST API<br/>(HTTP)"]:::backend
    end

    %% Data Store
    Database["Database<br/>(SQL/NoSQL)"]:::db

    %% External Services
    AuthProvider["Auth Provider<br/>(OAuth/JWT)"]:::external
    CDN["CDN for Assets"]:::external

    %% Connections
    AppShell -->|uses| HomeComp
    AppShell -->|uses| LayoutComp
    AppShell -->|uses| PageNotFound
    AppShell -->|bootstraps| ServiceLayer
    AppShell -->|bootstraps| AppConfig
    AppShell -->|bootstraps| AppRoutes

    ServiceLayer ---|Realtime Events| SignalRHub
    ServiceLayer -->|HTTP Calls| RESTAPI

    SignalRHub -->|persists state| Database
    RESTAPI -->|reads/writes| Database

    ServiceLayer -->|token exchange| AuthProvider
    AppShell -->|loads assets| CDN

    MainTs -->|bootstraps| AppShell
    IndexHtml -->|renders| AppShell
    StylesCss -->|styles| AppShell

    %% Click events
    click AppShell "https://github.com/wizard-aka-aman/skribbl/blob/master/src/app/app.component.ts"
    click ServiceLayer "https://github.com/wizard-aka-aman/skribbl/blob/master/src/app/service.service.ts"
    click AppConfig "https://github.com/wizard-aka-aman/skribbl/blob/master/src/app/app.config.ts"
    click AppRoutes "https://github.com/wizard-aka-aman/skribbl/blob/master/src/app/app.routes.ts"
    click HomeComp "https://github.com/wizard-aka-aman/skribbl/blob/master/src/app/home/home.component.ts"
    click LayoutComp "https://github.com/wizard-aka-aman/skribbl/blob/master/src/app/layout/layout.component.ts"
    click PageNotFound "https://github.com/wizard-aka-aman/skribbl/blob/master/src/app/pagenotfound/pagenotfound.component.ts"
    click MainTs "https://github.com/wizard-aka-aman/skribbl/blob/master/src/main.ts"
    click IndexHtml "https://github.com/wizard-aka-aman/skribbl/blob/master/src/index.html"
    click StylesCss "https://github.com/wizard-aka-aman/skribbl/blob/master/src/styles.css"

    %% Styles
    classDef ui fill:#D6EAF8,stroke:#1B4F72,stroke-width:1px;
    classDef service fill:#D5F5E3,stroke:#1D8348,stroke-width:1px;
    classDef backend fill:#FCF3CF,stroke:#7D6608,stroke-width:1px;
    classDef db fill:#E8DAEF,stroke:#512E5F,stroke-width:1px;
    classDef external fill:#F2F3F4,stroke:#6C7A89,stroke-width:1px;
    classDef config fill:#FADBD8,stroke:#922B21,stroke-width:1px;
    classDef init fill:#EBDEF0,stroke:#6C3483,stroke-width:1px;
```
