# ananyo-sen-b2530066/football-tournament architecture

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

- Interactive diagram: https://gitdiagram.com/ananyo-sen-b2530066/football-tournament
- Repository: https://github.com/ananyo-sen-b2530066/football-tournament

## Overview

Tournament Hub is a LAN-hosted tournament manager: an owner configures the roster and stages live draws, volunteers submit confirmed scores from phones, and the server maintains the shared tournament state used to calculate standings and knockout progression. The owner can resolve ties, manage projector pages, and export results; a PIN-protected screen presents ceremonies, fixtures, tables, brackets, and results. Edges reflect the README and shown source-index references or excerpts; unsampled implementation details are not inferred.

Main entry points: [`app/owner/page.tsx`](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/owner/page.tsx) (Owner console), [`lib/server/store.ts`](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/server/store.ts) (Tournament store), [`components/ScreenPlaylist.tsx`](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/ScreenPlaylist.tsx) (Screen playlist), [`lib/useTournament.ts`](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/useTournament.ts) (Tournament client state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sites["User-facing sites"]
  node_home["Front door<br/>[page.tsx]"]
  node_editor["Score editor<br/>[page.tsx]"]
  node_ownerconsole["Owner console<br/>[page.tsx]"]
  node_screen["Projector site<br/>[page.tsx]"]
  node_sharedstate["Tournament client state<br/>[useTournament.ts]"]
  node_confighealth["Config health<br/>[useConfigHealth.ts]"]
  node_scorecard["Phone score card<br/>[PhoneScoreCard.tsx]"]
end

subgraph group_api["Server and state"]
  node_controlapi["Control API<br/>[route.ts]"]
  node_rosterapi["Roster API<br/>[route.ts]"]
  node_scoreapi["Score API<br/>[route.ts]"]
  node_stateapi["State API<br/>[route.ts]"]
  node_serverstore[("Tournament store<br/>[store.ts]")]
  node_statefile["Host state file"]
  node_avatarstore[("Avatar storage<br/>[avatarStore.ts]")]
  node_avatarapi["Avatar endpoint<br/>[route.ts]"]
end

subgraph group_domain["Tournament operations"]
  node_drafts["Score drafts<br/>[drafts.ts]"]
  node_rosterimport["Roster parsing<br/>[roster.ts]"]
  node_xlsx["Spreadsheet reader<br/>[xlsx.ts]"]
  node_drawengine["Draw and bracket engine<br/>[draw.ts]"]
  node_table["Standings and tie-breaks<br/>[table.ts]"]
  node_stats["Tournament statistics<br/>[stats.ts]"]
  node_exports["Spreadsheet exports<br/>[sheets.ts]"]
end

subgraph group_display["Projection and reporting"]
  node_playlist["Screen playlist<br/>[ScreenPlaylist.tsx]"]
  node_screenplan["Playlist rules<br/>[screenPlaylist.ts]"]
  node_drawshow["Draw ceremony<br/>[DrawShow.tsx]"]
  node_bracket["Knockout bracket"]
  node_pointstable["Points table<br/>[PointsTable.tsx]"]
  node_resultshow["Results show<br/>[ResultsShow.tsx]"]
end

node_visitor(("Visitor"))
node_volunteer(("Volunteer"))
node_owner(("Tournament owner"))
node_audience(("Projector audience"))

node_visitor -->|"opens"| node_home
node_volunteer -->|"records scores"| node_editor
node_owner -->|"manages tournament"| node_ownerconsole
node_audience -->|"views projection"| node_screen
node_home -->|"reads state"| node_sharedstate
node_editor -->|"syncs state"| node_sharedstate
node_ownerconsole -->|"syncs state"| node_sharedstate
node_screen -.->|"reads state"| node_sharedstate
node_editor -->|"renders"| node_scorecard
node_scorecard -->|"saves drafts"| node_drafts
node_sharedstate -->|"polls state"| node_stateapi
node_sharedstate -.->|"submits scores"| node_scoreapi
node_ownerconsole -->|"sends actions"| node_controlapi
node_ownerconsole -->|"imports roster"| node_rosterapi
node_ownerconsole -->|"exports results"| node_exports
node_ownerconsole -->|"checks config"| node_confighealth
node_confighealth -.->|"checks config"| node_controlapi
node_controlapi -->|"mutates state"| node_serverstore
node_rosterapi -->|"sets roster"| node_serverstore
node_rosterapi -->|"builds roster"| node_rosterimport
node_rosterapi -->|"reads workbook"| node_xlsx
node_rosterapi -->|"stores photos"| node_avatarstore
node_scoreapi -->|"updates scores"| node_serverstore
node_stateapi -->|"reads state"| node_serverstore
node_serverstore -->|"persists state"| node_statefile
node_serverstore -->|"resolves winners"| node_drawengine
node_serverstore -->|"computes standings"| node_table
node_serverstore -->|"derives statistics"| node_stats
node_ownerconsole -->|"stages draws"| node_drawengine
node_screen -->|"renders screen"| node_playlist
node_playlist -->|"plans pages"| node_screenplan
node_playlist -->|"shows ceremony"| node_drawshow
node_playlist -->|"shows bracket"| node_bracket
node_playlist -->|"shows table"| node_pointstable
node_playlist -->|"shows results"| node_resultshow
node_ownerconsole -->|"previews standings"| node_pointstable
node_ownerconsole -->|"previews bracket"| node_bracket
node_avatarapi -->|"serves images"| node_avatarstore

click node_home "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/page.tsx"
click node_editor "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/editor/page.tsx"
click node_ownerconsole "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/owner/page.tsx"
click node_screen "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/screen/page.tsx"
click node_sharedstate "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/useTournament.ts"
click node_confighealth "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/useConfigHealth.ts"
click node_scorecard "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/PhoneScoreCard.tsx"
click node_drafts "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/drafts.ts"
click node_controlapi "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/api/control/route.ts"
click node_rosterapi "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/api/roster/route.ts"
click node_scoreapi "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/api/score/route.ts"
click node_stateapi "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/api/state/route.ts"
click node_serverstore "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/server/store.ts"
click node_statefile "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/config/tournament.config.ts"
click node_rosterimport "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/roster.ts"
click node_xlsx "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/server/xlsx.ts"
click node_avatarstore "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/server/avatarStore.ts"
click node_drawengine "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/draw.ts"
click node_table "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/table.ts"
click node_stats "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/stats.ts"
click node_playlist "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/ScreenPlaylist.tsx"
click node_screenplan "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/screenPlaylist.ts"
click node_drawshow "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/DrawShow.tsx"
click node_bracket "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/KnockoutBracket.tsx"
click node_pointstable "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/PointsTable.tsx"
click node_resultshow "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/ResultsShow.tsx"
click node_exports "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/sheets.ts"
click node_avatarapi "https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/api/avatar/%5Bid%5D/route.ts"

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_home,node_editor,node_ownerconsole,node_screen,node_sharedstate,node_confighealth,node_scorecard toneBlue
class node_controlapi,node_rosterapi,node_scoreapi,node_stateapi,node_serverstore,node_statefile,node_avatarstore,node_avatarapi toneAmber
class node_drafts,node_rosterimport,node_xlsx,node_drawengine,node_table,node_stats,node_exports toneMint
class node_playlist,node_screenplan,node_drawshow,node_bracket,node_pointstable,node_resultshow toneRose
class node_visitor,node_volunteer,node_owner,node_audience toneIndigo
```

## Components

### User-facing sites

- [Front door](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/page.tsx): `app/page.tsx`
- [Score editor](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/editor/page.tsx): `app/editor/page.tsx`
- [Owner console](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/owner/page.tsx): `app/owner/page.tsx`
- [Projector site](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/screen/page.tsx): `app/screen/page.tsx`
- [Tournament client state](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/useTournament.ts): `lib/useTournament.ts`
- [Config health](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/useConfigHealth.ts): `lib/useConfigHealth.ts`
- [Phone score card](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/PhoneScoreCard.tsx): `components/PhoneScoreCard.tsx`

### Server and state

- [Control API](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/api/control/route.ts): `app/api/control/route.ts`
- [Roster API](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/api/roster/route.ts): `app/api/roster/route.ts`
- [Score API](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/api/score/route.ts): `app/api/score/route.ts`
- [State API](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/api/state/route.ts): `app/api/state/route.ts`
- [Tournament store](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/server/store.ts): `lib/server/store.ts`
- [Host state file](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/config/tournament.config.ts): `config/tournament.config.ts`
- [Avatar storage](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/server/avatarStore.ts): `lib/server/avatarStore.ts`
- [Avatar endpoint](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/app/api/avatar/%5Bid%5D/route.ts): `app/api/avatar/[id]/route.ts`

### Tournament operations

- [Score drafts](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/drafts.ts): `lib/drafts.ts`
- [Roster parsing](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/roster.ts): `lib/roster.ts`
- [Spreadsheet reader](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/server/xlsx.ts): `lib/server/xlsx.ts`
- [Draw and bracket engine](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/draw.ts): `lib/draw.ts`
- [Standings and tie-breaks](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/table.ts): `lib/table.ts`
- [Tournament statistics](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/stats.ts): `lib/stats.ts`
- [Spreadsheet exports](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/sheets.ts): `lib/sheets.ts`

### Projection and reporting

- [Screen playlist](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/ScreenPlaylist.tsx): `components/ScreenPlaylist.tsx`
- [Playlist rules](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/lib/screenPlaylist.ts): `lib/screenPlaylist.ts`
- [Draw ceremony](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/DrawShow.tsx): `components/DrawShow.tsx`
- [Knockout bracket](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/KnockoutBracket.tsx): `components/KnockoutBracket.tsx`
- [Points table](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/PointsTable.tsx): `components/PointsTable.tsx`
- [Results show](https://github.com/ananyo-sen-b2530066/football-tournament/blob/main/components/ResultsShow.tsx): `components/ResultsShow.tsx`

### Other components

- **Visitor**
- **Volunteer**
- **Tournament owner**
- **Projector audience**

## Connections

- Visitor → Front door: opens
- Volunteer → Score editor: records scores
- Tournament owner → Owner console: manages tournament
- Projector audience → Projector site: views projection
- Front door → Tournament client state: reads state (evidence: `app/page.tsx`)
- Score editor → Tournament client state: syncs state (evidence: `app/editor/page.tsx`)
- Owner console → Tournament client state: syncs state (evidence: `app/owner/page.tsx`)
- Projector site → Tournament client state: reads state
- Score editor → Phone score card: renders (evidence: `app/editor/page.tsx`)
- Phone score card → Score drafts: saves drafts (evidence: `components/PhoneScoreCard.tsx`)
- Tournament client state → State API: polls state (evidence: `lib/useTournament.ts`)
- Tournament client state → Score API: submits scores
- Owner console → Control API: sends actions (evidence: `app/owner/page.tsx`)
- Owner console → Roster API: imports roster
- Owner console → Spreadsheet exports: exports results (evidence: `app/owner/page.tsx`)
- Owner console → Config health: checks config (evidence: `lib/useConfigHealth.ts`)
- Config health → Control API: checks config
- Control API → Tournament store: mutates state (evidence: `app/api/control/route.ts`)
- Roster API → Tournament store: sets roster (evidence: `app/api/roster/route.ts`)
- Roster API → Roster parsing: builds roster (evidence: `app/api/roster/route.ts`)
- Roster API → Spreadsheet reader: reads workbook (evidence: `app/api/roster/route.ts`)
- Roster API → Avatar storage: stores photos (evidence: `app/api/roster/route.ts`)
- Score API → Tournament store: updates scores (evidence: `app/api/score/route.ts`)
- State API → Tournament store: reads state (evidence: `app/api/state/route.ts`)
- Tournament store → Host state file: persists state (evidence: `lib/server/store.ts`)
- Tournament store → Draw and bracket engine: resolves winners (evidence: `lib/server/store.ts`)
- Tournament store → Standings and tie-breaks: computes standings (evidence: `lib/server/store.ts`)
- Tournament store → Tournament statistics: derives statistics (evidence: `lib/server/store.ts`)
- Owner console → Draw and bracket engine: stages draws (evidence: `app/owner/page.tsx`)
- Projector site → Screen playlist: renders screen (evidence: `app/screen/page.tsx`)
- Screen playlist → Playlist rules: plans pages (evidence: `components/ScreenPlaylist.tsx`)
- Screen playlist → Draw ceremony: shows ceremony (evidence: `components/ScreenPlaylist.tsx`)
- Screen playlist → Knockout bracket: shows bracket (evidence: `components/ScreenPlaylist.tsx`)
- Screen playlist → Points table: shows table (evidence: `components/ScreenPlaylist.tsx`)
- Screen playlist → Results show: shows results (evidence: `components/ScreenPlaylist.tsx`)
- Owner console → Points table: previews standings (evidence: `app/owner/page.tsx`)
- Owner console → Knockout bracket: previews bracket (evidence: `app/owner/page.tsx`)
- Avatar endpoint → Avatar storage: serves images (evidence: `app/api/avatar/[id]/route.ts`)
