How wizard-aka-aman/skribbl works
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]