# ralex91/razzia architecture

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

- Interactive diagram: https://gitdiagram.com/ralex91/razzia
- Repository: https://github.com/ralex91/razzia

## Overview

Razzia is a self-hosted quiz platform: a manager configures a quiz, creates a room, and participants join and play through live game updates; results are then available to the host. The graph preserves quiz authoring, media, authentication, game rounds/scoring, and the documented HTTP API. Several UI-to-API and persistence connections are not visible in the sampled source, so those links are omitted rather than inferred.

Main entry points: [`packages/socket/src/handlers/game.ts`](https://github.com/ralex91/razzia/blob/main/packages/socket/src/handlers/game.ts) (Game socket handlers), [`packages/socket/src/app.ts`](https://github.com/ralex91/razzia/blob/main/packages/socket/src/app.ts) (HTTP and socket app), [`packages/socket/src/services/game/index.ts`](https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/game/index.ts) (Game orchestration), [`packages/web/src/main.tsx`](https://github.com/ralex91/razzia/blob/main/packages/web/src/main.tsx) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Web application<br/>[main.tsx]"]
  node_managerui["Game manager"]
  node_quizeditor["Quiz editor"]
  node_mediaui["Media library"]
  node_gameui["Player game UI"]
  node_clientapi["Web API client<br/>[api.ts]"]
end

subgraph group_server["Socket service"]
  node_app["HTTP and socket app<br/>[app.ts]"]
  node_authroutes["Session routes<br/>[auth.ts]"]
  node_apiroutes["HTTP API routes"]
  node_auth["Token service<br/>[auth.ts]"]
  node_handlers["Game socket handlers<br/>[game.ts]"]
  node_registry["Game registry<br/>[registry.ts]"]
  node_media["Media service<br/>[media.ts]"]
end

subgraph group_domain["Quiz domain"]
  node_gameservice["Game orchestration<br/>[index.ts]"]
  node_rounds["Round manager<br/>[round-manager.ts]"]
  node_playersvc["Player manager<br/>[player-manager.ts]"]
  node_scoring["Answer scoring<br/>[round.ts]"]
end

subgraph group_shared["Shared contracts"]
  node_contracts["Types and validators"]
end

node_host(("Host"))
node_players(("Participants"))

node_host -->|"opens manager"| node_webapp
node_players -->|"join and play"| node_webapp
node_webapp -->|"hosts game views"| node_gameui
node_app -->|"mounts API"| node_apiroutes
node_app -->|"registers handlers"| node_handlers
node_app -->|"verifies socket tokens"| node_auth
node_authroutes -->|"mints and verifies tokens"| node_auth
node_handlers -->|"uses shared contracts"| node_contracts
node_rounds -->|"scores answers"| node_scoring
node_playersvc -->|"validates usernames"| node_contracts
node_mediaui -->|"uploads media"| node_clientapi
node_quizeditor -.->|"edits question media"| node_mediaui
node_managerui -.->|"requests quiz and results"| node_clientapi
node_clientapi -.->|"calls HTTP API"| node_apiroutes
node_gameui -.->|"exchanges live events"| node_handlers
node_handlers -.->|"dispatches game actions"| node_registry
node_registry -.->|"resolves game state"| node_gameservice
node_gameservice -.->|"manages rounds"| node_rounds
node_gameservice -.->|"manages participants"| node_playersvc
node_apiroutes -.->|"serves media operations"| node_media

click node_webapp "https://github.com/ralex91/razzia/blob/main/packages/web/src/main.tsx"
click node_managerui "https://github.com/ralex91/razzia/tree/main/packages/web/src/features/manager"
click node_quizeditor "https://github.com/ralex91/razzia/tree/main/packages/web/src/features/quizz"
click node_mediaui "https://github.com/ralex91/razzia/tree/main/packages/web/src/features/quizz/components/QuestionEditor/MediaLibrary"
click node_gameui "https://github.com/ralex91/razzia/tree/main/packages/web/src/features/game"
click node_clientapi "https://github.com/ralex91/razzia/blob/main/packages/web/src/lib/api.ts"
click node_app "https://github.com/ralex91/razzia/blob/main/packages/socket/src/app.ts"
click node_authroutes "https://github.com/ralex91/razzia/blob/main/packages/socket/src/api/routes/auth.ts"
click node_apiroutes "https://github.com/ralex91/razzia/tree/main/packages/socket/src/api/routes"
click node_auth "https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/auth.ts"
click node_handlers "https://github.com/ralex91/razzia/blob/main/packages/socket/src/handlers/game.ts"
click node_registry "https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/registry.ts"
click node_gameservice "https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/game/index.ts"
click node_rounds "https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/game/round-manager.ts"
click node_playersvc "https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/game/player-manager.ts"
click node_scoring "https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/scoring/round.ts"
click node_media "https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/media.ts"
click node_contracts "https://github.com/ralex91/razzia/tree/main/packages/common/src/validators"

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_webapp,node_managerui,node_quizeditor,node_mediaui,node_gameui,node_clientapi toneBlue
class node_app,node_authroutes,node_apiroutes,node_auth,node_handlers,node_registry,node_media toneAmber
class node_gameservice,node_rounds,node_playersvc,node_scoring toneMint
class node_contracts toneRose
class node_host,node_players toneIndigo
```

## Components

### Web experience

- [Web application](https://github.com/ralex91/razzia/blob/main/packages/web/src/main.tsx): `packages/web/src/main.tsx`
- [Game manager](https://github.com/ralex91/razzia/tree/main/packages/web/src/features/manager): `packages/web/src/features/manager`
- [Quiz editor](https://github.com/ralex91/razzia/tree/main/packages/web/src/features/quizz): `packages/web/src/features/quizz`
- [Media library](https://github.com/ralex91/razzia/tree/main/packages/web/src/features/quizz/components/QuestionEditor/MediaLibrary): `packages/web/src/features/quizz/components/QuestionEditor/MediaLibrary`
- [Player game UI](https://github.com/ralex91/razzia/tree/main/packages/web/src/features/game): `packages/web/src/features/game`
- [Web API client](https://github.com/ralex91/razzia/blob/main/packages/web/src/lib/api.ts): `packages/web/src/lib/api.ts`

### Socket service

- [HTTP and socket app](https://github.com/ralex91/razzia/blob/main/packages/socket/src/app.ts): `packages/socket/src/app.ts`
- [Session routes](https://github.com/ralex91/razzia/blob/main/packages/socket/src/api/routes/auth.ts): `packages/socket/src/api/routes/auth.ts`
- [HTTP API routes](https://github.com/ralex91/razzia/tree/main/packages/socket/src/api/routes): `packages/socket/src/api/routes`
- [Token service](https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/auth.ts): `packages/socket/src/services/auth.ts`
- [Game socket handlers](https://github.com/ralex91/razzia/blob/main/packages/socket/src/handlers/game.ts): `packages/socket/src/handlers/game.ts`
- [Game registry](https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/registry.ts): `packages/socket/src/services/registry.ts`
- [Media service](https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/media.ts): `packages/socket/src/services/media.ts`

### Quiz domain

- [Game orchestration](https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/game/index.ts): `packages/socket/src/services/game/index.ts`
- [Round manager](https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/game/round-manager.ts): `packages/socket/src/services/game/round-manager.ts`
- [Player manager](https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/game/player-manager.ts): `packages/socket/src/services/game/player-manager.ts`
- [Answer scoring](https://github.com/ralex91/razzia/blob/main/packages/socket/src/services/scoring/round.ts): `packages/socket/src/services/scoring/round.ts`

### Shared contracts

- [Types and validators](https://github.com/ralex91/razzia/tree/main/packages/common/src/validators): `packages/common/src/validators`

### Other components

- **Host**
- **Participants**

## Connections

- Host → Web application: opens manager (evidence: `README.md`)
- Participants → Web application: join and play (evidence: `README.md`)
- Web application → Player game UI: hosts game views (evidence: `packages/web/src/main.tsx`)
- HTTP and socket app → HTTP API routes: mounts API (evidence: `packages/socket/src/app.ts`)
- HTTP and socket app → Game socket handlers: registers handlers (evidence: `packages/socket/src/app.ts`)
- HTTP and socket app → Token service: verifies socket tokens (evidence: `packages/socket/src/app.ts`)
- Session routes → Token service: mints and verifies tokens (evidence: `packages/socket/src/api/routes/auth.ts`)
- Game socket handlers → Types and validators: uses shared contracts (evidence: `packages/socket/src/handlers/game.ts`)
- Round manager → Answer scoring: scores answers (evidence: `packages/socket/src/services/game/round-manager.ts`)
- Player manager → Types and validators: validates usernames (evidence: `packages/socket/src/services/game/player-manager.ts`)
- Media library → Web API client: uploads media
- Quiz editor → Media library: edits question media
- Game manager → Web API client: requests quiz and results
- Web API client → HTTP API routes: calls HTTP API
- Player game UI → Game socket handlers: exchanges live events
- Game socket handlers → Game registry: dispatches game actions
- Game registry → Game orchestration: resolves game state
- Game orchestration → Round manager: manages rounds
- Game orchestration → Player manager: manages participants
- HTTP API routes → Media service: serves media operations
