# alifaguslerian/bdcahoot-live architecture

> Architecture diagram of the GitHub repository alifaguslerian/bdcahoot-live, 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/alifaguslerian/bdcahoot-live
- Repository: https://github.com/alifaguslerian/bdcahoot-live

## Overview

BDCAHOOT Live is a self-hosted, LAN multiplayer quiz app. Operators create quizzes, open a room, and control its rounds; players join by room code, answer on their phones, and see reveals and rankings. The flow centers on the shared Socket.io context and server-authoritative game engine, with quiz storage and completed-match history as distinct supporting capabilities. The README documents SQLite-backed persistence and gameplay stages; unsampled server wiring is represented only where documented or indicated by the source index.

Main entry points: [`server/socketServer.ts`](https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/socketServer.ts) (Socket Server), [`lib/quizStore.ts`](https://github.com/alifaguslerian/bdcahoot-live/blob/main/lib/quizStore.ts) (Quiz Store Client), [`context/GameContext.tsx`](https://github.com/alifaguslerian/bdcahoot-live/blob/main/context/GameContext.tsx) (Session Context), [`components/host/arena`](https://github.com/alifaguslerian/bdcahoot-live/tree/main/components/host/arena) (Host Arena)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host Console"]
  node_library["Quiz Library<br/>[page.tsx]"]
  node_editor["Quiz Editor<br/>[QuizEditorView.tsx]"]
  node_settings["Game Settings"]
  node_host_arena["Host Arena"]
  node_history["Match History"]
  node_csv["CSV Export"]
end

subgraph group_player["Player Experience"]
  node_join["Join Flow<br/>[PlayerJoinForm.tsx]"]
  node_identity["Player Identity<br/>[page.tsx]"]
  node_player_arena["Player Arena"]
end

subgraph group_runtime["Live Game Runtime"]
  node_session["Session Context<br/>[GameContext.tsx]"]
  node_socket["Socket Server<br/>[socketServer.ts]"]
  node_engine["Game Engine<br/>[gameEngine.ts]"]
  node_scoring["Scoring and Rankings<br/>[scoring.ts]"]
end

subgraph group_data["Quiz and Results Data"]
  node_quiz_store["Quiz Store Client<br/>[quizStore.ts]"]
  node_quiz_library["Quiz Library Service<br/>[quizLibrary.ts]"]
  node_match_history["Match Archive<br/>[matchHistory.ts]"]
  node_persistence["Persistence Service<br/>[persistence.ts]"]
  node_sqlite[("SQLite Database")]
end

node_operator(("Operator"))
node_participants(("Participants"))

node_operator -->|"manages quizzes"| node_library
node_library -->|"loads library"| node_quiz_store
node_editor -->|"saves quizzes"| node_quiz_store
node_settings -->|"updates quiz"| node_quiz_store
node_operator -->|"controls rounds"| node_host_arena
node_participants -->|"joins room"| node_join
node_join -->|"requests session"| node_session
node_identity -->|"joins with identity"| node_session
node_session -->|"emits socket events"| node_socket
node_socket -.->|"dispatches game actions"| node_engine
node_engine -->|"calculates rankings"| node_scoring
node_engine -->|"creates match result"| node_match_history
node_socket -.->|"handles library requests"| node_quiz_library
node_socket -.->|"serves history requests"| node_match_history
node_quiz_store -->|"requests library data"| node_socket
node_quiz_store -->|"requests match history"| node_socket
node_quiz_library -.->|"persists quizzes"| node_persistence
node_match_history -.->|"stores match archive"| node_persistence
node_persistence -->|"reads and writes"| node_sqlite
node_host_arena -.->|"uses live state"| node_session
node_player_arena -->|"uses live state"| node_session
node_operator -->|"reviews completed matches"| node_history
node_history -->|"loads match records"| node_quiz_store
node_history -->|"downloads results"| node_csv
node_host_arena -->|"exports podium results"| node_csv

click node_library "https://github.com/alifaguslerian/bdcahoot-live/blob/main/app/host/library/page.tsx"
click node_editor "https://github.com/alifaguslerian/bdcahoot-live/blob/main/components/host/QuizEditorView.tsx"
click node_settings "https://github.com/alifaguslerian/bdcahoot-live/blob/main/components/host/GameSettingsView.tsx"
click node_host_arena "https://github.com/alifaguslerian/bdcahoot-live/tree/main/components/host/arena"
click node_history "https://github.com/alifaguslerian/bdcahoot-live/tree/main/app/host/history"
click node_csv "https://github.com/alifaguslerian/bdcahoot-live/blob/main/components/host/DownloadMatchButton.tsx"
click node_join "https://github.com/alifaguslerian/bdcahoot-live/blob/main/components/player/PlayerJoinForm.tsx"
click node_identity "https://github.com/alifaguslerian/bdcahoot-live/blob/main/app/player/name/page.tsx"
click node_player_arena "https://github.com/alifaguslerian/bdcahoot-live/tree/main/components/player/controller"
click node_session "https://github.com/alifaguslerian/bdcahoot-live/blob/main/context/GameContext.tsx"
click node_socket "https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/socketServer.ts"
click node_engine "https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/gameEngine.ts"
click node_scoring "https://github.com/alifaguslerian/bdcahoot-live/blob/main/lib/scoring.ts"
click node_quiz_store "https://github.com/alifaguslerian/bdcahoot-live/blob/main/lib/quizStore.ts"
click node_quiz_library "https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/quizLibrary.ts"
click node_match_history "https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/matchHistory.ts"
click node_persistence "https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/persistence.ts"
click node_sqlite "https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/persistenceWorker.mjs"

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_library,node_editor,node_settings,node_host_arena,node_history,node_csv toneBlue
class node_join,node_identity,node_player_arena toneAmber
class node_session,node_socket,node_engine,node_scoring toneMint
class node_quiz_store,node_quiz_library,node_match_history,node_persistence,node_sqlite toneRose
class node_operator,node_participants toneIndigo
```

## Components

### Host Console

- [Quiz Library](https://github.com/alifaguslerian/bdcahoot-live/blob/main/app/host/library/page.tsx): `app/host/library/page.tsx`
- [Quiz Editor](https://github.com/alifaguslerian/bdcahoot-live/blob/main/components/host/QuizEditorView.tsx): `components/host/QuizEditorView.tsx`
- [Game Settings](https://github.com/alifaguslerian/bdcahoot-live/blob/main/components/host/GameSettingsView.tsx): `components/host/GameSettingsView.tsx`
- [Host Arena](https://github.com/alifaguslerian/bdcahoot-live/tree/main/components/host/arena): `components/host/arena`
- [Match History](https://github.com/alifaguslerian/bdcahoot-live/tree/main/app/host/history): `app/host/history`
- [CSV Export](https://github.com/alifaguslerian/bdcahoot-live/blob/main/components/host/DownloadMatchButton.tsx): `components/host/DownloadMatchButton.tsx`

### Player Experience

- [Join Flow](https://github.com/alifaguslerian/bdcahoot-live/blob/main/components/player/PlayerJoinForm.tsx): `components/player/PlayerJoinForm.tsx`
- [Player Identity](https://github.com/alifaguslerian/bdcahoot-live/blob/main/app/player/name/page.tsx): `app/player/name/page.tsx`
- [Player Arena](https://github.com/alifaguslerian/bdcahoot-live/tree/main/components/player/controller): `components/player/controller`

### Live Game Runtime

- [Session Context](https://github.com/alifaguslerian/bdcahoot-live/blob/main/context/GameContext.tsx): `context/GameContext.tsx`
- [Socket Server](https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/socketServer.ts): `server/socketServer.ts`
- [Game Engine](https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/gameEngine.ts): `server/gameEngine.ts`
- [Scoring and Rankings](https://github.com/alifaguslerian/bdcahoot-live/blob/main/lib/scoring.ts): `lib/scoring.ts`

### Quiz and Results Data

- [Quiz Store Client](https://github.com/alifaguslerian/bdcahoot-live/blob/main/lib/quizStore.ts): `lib/quizStore.ts`
- [Quiz Library Service](https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/quizLibrary.ts): `server/quizLibrary.ts`
- [Match Archive](https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/matchHistory.ts): `server/matchHistory.ts`
- [Persistence Service](https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/persistence.ts): `server/persistence.ts`
- [SQLite Database](https://github.com/alifaguslerian/bdcahoot-live/blob/main/server/persistenceWorker.mjs): `server/persistenceWorker.mjs`

### Other components

- **Operator**
- **Participants**

## Connections

- Operator → Quiz Library: manages quizzes (evidence: `README.md`)
- Quiz Library → Quiz Store Client: loads library (evidence: `app/host/library/page.tsx`)
- Quiz Editor → Quiz Store Client: saves quizzes (evidence: `components/host/QuizEditorView.tsx`)
- Game Settings → Quiz Store Client: updates quiz (evidence: `components/host/GameSettingsView.tsx`)
- Operator → Host Arena: controls rounds (evidence: `README.md`)
- Participants → Join Flow: joins room (evidence: `README.md`)
- Join Flow → Session Context: requests session (evidence: `components/player/PlayerJoinForm.tsx`)
- Player Identity → Session Context: joins with identity (evidence: `app/player/name/page.tsx`)
- Session Context → Socket Server: emits socket events (evidence: `context/GameContext.tsx`)
- Socket Server → Game Engine: dispatches game actions (evidence: `server/socketServer.ts`)
- Game Engine → Scoring and Rankings: calculates rankings (evidence: `server/gameEngine.ts`)
- Game Engine → Match Archive: creates match result (evidence: `server/gameEngine.ts`)
- Socket Server → Quiz Library Service: handles library requests (evidence: `server/socketServer.ts`)
- Socket Server → Match Archive: serves history requests (evidence: `server/socketServer.ts`)
- Quiz Store Client → Socket Server: requests library data (evidence: `lib/quizStore.ts`)
- Quiz Store Client → Socket Server: requests match history (evidence: `lib/quizStore.ts`)
- Quiz Library Service → Persistence Service: persists quizzes
- Match Archive → Persistence Service: stores match archive
- Persistence Service → SQLite Database: reads and writes (evidence: `README.md`)
- Host Arena → Session Context: uses live state (evidence: `components/host/arena/PodiumView.tsx`)
- Player Arena → Session Context: uses live state (evidence: `components/player/controller/PlayerControllerContainer.tsx`)
- Operator → Match History: reviews completed matches (evidence: `README.md`)
- Match History → Quiz Store Client: loads match records (evidence: `app/host/history/page.tsx`)
- Match History → CSV Export: downloads results (evidence: `app/host/history/[matchId]/page.tsx`)
- Host Arena → CSV Export: exports podium results (evidence: `components/host/arena/PodiumView.tsx`)
