# nicolas-riera/lebuzzer architecture

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

- Interactive diagram: https://gitdiagram.com/nicolas-riera/lebuzzer
- Repository: https://github.com/nicolas-riera/lebuzzer

## Overview

LeBuzzer is a real-time multiplayer quiz: a host opens a room, players join by code or QR, answer timed questions, and see speed-weighted scores on shared host/player views. The React client keeps resumable host/player sessions and synchronizes through REST snapshots plus STOMP-over-WebSocket events; Spring coordinates room membership, question timing, scoring and leaderboards using in-memory game state. The README documents the major capabilities; source excerpts confirm key service and context relationships, but unsampled routes and wiring are represented only where documented.

Main entry points: [`backend/src/main/java/com/nicolasgabriel/lebuzzer/service/BuzzerService.java`](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/BuzzerService.java) (Game coordinator), [`backend/src/main/java/com/nicolasgabriel/lebuzzer/service/QuestionFlowService.java`](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/QuestionFlowService.java) (Question lifecycle), [`frontend/src/App.tsx`](https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/App.tsx) (App routes), [`backend/src/main/java/com/nicolasgabriel/lebuzzer/service/GameRegistry.java`](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/GameRegistry.java) (Room registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routes<br/>[App.tsx]"]
  node_hostctx["Host session<br/>[HostContext.tsx]"]
  node_playerctx["Player session<br/>[GameContext.tsx]"]
  node_hostpages["Host views"]
  node_playerpages["Player views"]
end

subgraph group_transport["Game transport"]
  node_api["REST client<br/>[gameApi.ts]"]
  node_socketclient["Socket client<br/>[gameSocket.ts]"]
  node_rest["REST endpoints"]
  node_ws["WebSocket commands"]
end

subgraph group_gameplay["Game runtime"]
  node_buzzer["Game coordinator<br/>[BuzzerService.java]"]
  node_hostflow["Host actions<br/>[HostService.java]"]
  node_playerflow["Player actions<br/>[PlayerService.java]"]
  node_questionflow["Question lifecycle"]
  node_scheduler["Game timers"]
  node_scoring["Scoring and ranks"]
end

subgraph group_domain["Game data"]
  node_registry[("Room registry<br/>[GameRegistry.java]")]
  node_gamedata["Game state<br/>[Game.java]"]
  node_catalog["Question catalog"]
  node_snapshot["Game snapshot<br/>[GameSnapshot.java]"]
end

node_host(("Host"))
node_players(("Players"))

node_host -->|"uses host views"| node_app
node_players -->|"join and play"| node_app
node_app -->|"routes to"| node_hostpages
node_app -->|"routes to"| node_playerpages
node_hostpages -->|"uses session"| node_hostctx
node_playerpages -->|"uses session"| node_playerctx
node_hostctx -->|"loads room"| node_api
node_playerctx -->|"gets snapshot"| node_api
node_hostctx -->|"connects host"| node_socketclient
node_playerctx -->|"syncs gameplay"| node_socketclient
node_api -->|"REST requests"| node_rest
node_socketclient -->|"STOMP events"| node_ws
node_rest -->|"invokes"| node_buzzer
node_ws -->|"dispatches actions"| node_buzzer
node_buzzer -->|"delegates"| node_hostflow
node_buzzer -->|"delegates"| node_playerflow
node_buzzer -->|"delegates"| node_questionflow
node_buzzer -->|"builds ranks"| node_scoring
node_hostflow -->|"accesses rooms"| node_registry
node_playerflow -->|"accesses rooms"| node_registry
node_questionflow -->|"loads game"| node_registry
node_questionflow -->|"schedules expiry"| node_scheduler
node_questionflow -->|"scores answers"| node_scoring
node_scoring -->|"updates scores"| node_gamedata
node_registry -->|"stores in memory"| node_gamedata
node_catalog -.->|"provides questions"| node_gamedata
node_rest -->|"returns snapshot"| node_snapshot

click node_app "https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/App.tsx"
click node_hostctx "https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/context/HostContext.tsx"
click node_playerctx "https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/context/GameContext.tsx"
click node_hostpages "https://github.com/nicolas-riera/lebuzzer/tree/main/frontend/src/pages/Host"
click node_playerpages "https://github.com/nicolas-riera/lebuzzer/tree/main/frontend/src/pages/User"
click node_api "https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/services/gameApi.ts"
click node_socketclient "https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/services/gameSocket.ts"
click node_rest "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/controller/GameRestController.java"
click node_ws "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/controller/GameWebSocketController.java"
click node_buzzer "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/BuzzerService.java"
click node_hostflow "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/HostService.java"
click node_playerflow "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/PlayerService.java"
click node_questionflow "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/QuestionFlowService.java"
click node_scheduler "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/GameSchedulerService.java"
click node_scoring "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/ScoringService.java"
click node_registry "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/GameRegistry.java"
click node_gamedata "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/model/Game.java"
click node_catalog "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/model/QuestionCatalog.java"
click node_snapshot "https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/dto/GameSnapshot.java"

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_hostctx,node_playerctx,node_hostpages,node_playerpages toneBlue
class node_api,node_socketclient,node_rest,node_ws toneAmber
class node_buzzer,node_hostflow,node_playerflow,node_questionflow,node_scheduler,node_scoring toneMint
class node_registry,node_gamedata,node_catalog,node_snapshot toneRose
class node_host,node_players toneIndigo
```

## Components

### Web client

- [App routes](https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Host session](https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/context/HostContext.tsx): `frontend/src/context/HostContext.tsx`
- [Player session](https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/context/GameContext.tsx): `frontend/src/context/GameContext.tsx`
- [Host views](https://github.com/nicolas-riera/lebuzzer/tree/main/frontend/src/pages/Host): `frontend/src/pages/Host`
- [Player views](https://github.com/nicolas-riera/lebuzzer/tree/main/frontend/src/pages/User): `frontend/src/pages/User`

### Game transport

- [REST client](https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/services/gameApi.ts): `frontend/src/services/gameApi.ts`
- [Socket client](https://github.com/nicolas-riera/lebuzzer/blob/main/frontend/src/services/gameSocket.ts): `frontend/src/services/gameSocket.ts`
- [REST endpoints](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/controller/GameRestController.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/controller/GameRestController.java`
- [WebSocket commands](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/controller/GameWebSocketController.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/controller/GameWebSocketController.java`

### Game runtime

- [Game coordinator](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/BuzzerService.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/BuzzerService.java`
- [Host actions](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/HostService.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/HostService.java`
- [Player actions](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/PlayerService.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/PlayerService.java`
- [Question lifecycle](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/QuestionFlowService.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/QuestionFlowService.java`
- [Game timers](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/GameSchedulerService.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/GameSchedulerService.java`
- [Scoring and ranks](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/ScoringService.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/ScoringService.java`

### Game data

- [Room registry](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/service/GameRegistry.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/GameRegistry.java`
- [Game state](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/model/Game.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/model/Game.java`
- [Question catalog](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/model/QuestionCatalog.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/model/QuestionCatalog.java`
- [Game snapshot](https://github.com/nicolas-riera/lebuzzer/blob/main/backend/src/main/java/com/nicolasgabriel/lebuzzer/dto/GameSnapshot.java): `backend/src/main/java/com/nicolasgabriel/lebuzzer/dto/GameSnapshot.java`

### Other components

- **Host**
- **Players**

## Connections

- Host → App routes: uses host views (evidence: `README.md`)
- Players → App routes: join and play (evidence: `README.md`)
- App routes → Host views: routes to (evidence: `frontend/src/App.tsx`)
- App routes → Player views: routes to (evidence: `frontend/src/App.tsx`)
- Host views → Host session: uses session (evidence: `frontend/src/pages/Host/CreateQuiz.tsx`)
- Player views → Player session: uses session (evidence: `frontend/src/pages/User/AnswerUser.tsx`)
- Host session → REST client: loads room (evidence: `frontend/src/context/HostContext.tsx`)
- Player session → REST client: gets snapshot (evidence: `frontend/src/context/GameContext.tsx`)
- Host session → Socket client: connects host (evidence: `frontend/src/context/HostContext.tsx`)
- Player session → Socket client: syncs gameplay (evidence: `frontend/src/context/GameContext.tsx`)
- REST client → REST endpoints: REST requests (evidence: `README.md`)
- Socket client → WebSocket commands: STOMP events (evidence: `README.md`)
- REST endpoints → Game coordinator: invokes (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/controller/GameRestController.java`)
- WebSocket commands → Game coordinator: dispatches actions (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/controller/GameWebSocketController.java`)
- Game coordinator → Host actions: delegates (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/BuzzerService.java`)
- Game coordinator → Player actions: delegates (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/BuzzerService.java`)
- Game coordinator → Question lifecycle: delegates (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/BuzzerService.java`)
- Game coordinator → Scoring and ranks: builds ranks (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/BuzzerService.java`)
- Host actions → Room registry: accesses rooms (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/HostService.java`)
- Player actions → Room registry: accesses rooms (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/PlayerService.java`)
- Question lifecycle → Room registry: loads game (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/QuestionFlowService.java`)
- Question lifecycle → Game timers: schedules expiry (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/QuestionFlowService.java`)
- Question lifecycle → Scoring and ranks: scores answers (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/QuestionFlowService.java`)
- Scoring and ranks → Game state: updates scores (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/service/ScoringService.java`)
- Room registry → Game state: stores in memory (evidence: `README.md`)
- Question catalog → Game state: provides questions
- REST endpoints → Game snapshot: returns snapshot (evidence: `backend/src/main/java/com/nicolasgabriel/lebuzzer/controller/GameRestController.java`)
