# nathanblatter/survivor50draft architecture

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

- Interactive diagram: https://gitdiagram.com/nathanblatter/survivor50draft
- Repository: https://github.com/nathanblatter/survivor50draft

## Overview

Survivor Fantasy Draft is a web app for organizing season-specific leagues, drafting castaways onto teams, tracking game events and scores, and viewing standings and recaps. The user workflow runs from browsing a show and season to joining a league, drafting players, and following league results; commissioners also manage season data and scoring. The frontend API client connects those workflows to Express route modules and PostgreSQL. The README is empty, so feature coverage is based on the source index and sampled code; several unsampled routes are shown as domain subsystems without speculative internal flows.

Main entry points: [`backend/src/index.ts`](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/index.ts) (Express entry), [`backend/src/db.ts`](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/db.ts) (PostgreSQL), [`backend/src/routes/extract.ts`](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/extract.ts) (Event extraction), [`frontend/src/api.ts`](https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["App routing<br/>[App.tsx]"]
  node_app_context["League context<br/>[AppContext.tsx]"]
  node_auth_context["Admin session<br/>[AuthContext.tsx]"]
  node_tribe_context["Tribe context<br/>[TribeContext.tsx]"]
  node_draft_ui["Fantasy draft<br/>[DraftPage.tsx]"]
  node_league_views["League views"]
  node_player_card["Player cards<br/>[PlayerCard.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["Backend API"]
  node_server["Express entry<br/>[index.ts]"]
  node_auth_routes["Authentication<br/>[auth.ts]"]
  node_league_routes["League management<br/>[leagues.ts]"]
  node_draft_routes["Draft management<br/>[draft.ts]"]
  node_player_routes["Castaway records<br/>[players.ts]"]
  node_team_routes["Fantasy teams<br/>[teams.ts]"]
  node_summary_routes["Standings and recaps<br/>[summary.ts]"]
  node_season_routes["Shows and seasons"]
  node_auth_middleware["Admin authorization<br/>[auth.ts]"]
end

subgraph group_scoring["Season operations"]
  node_game_routes["Game state<br/>[gamestate.ts]"]
  node_scoring_routes["Scoring events<br/>[scoring.ts]"]
  node_extract_routes["Event extraction<br/>[extract.ts]"]
  node_wikipedia["Wikipedia parser<br/>[wikipedia.ts]"]
  node_scoring_logic["Scoring rules<br/>[scoring.ts]"]
  node_proposal_logic["Wikipedia proposals"]
end

subgraph group_data["Persistence and domain logic"]
  node_database[("PostgreSQL<br/>[db.ts]")]
  node_player_logic["Player utilities<br/>[players.ts]"]
  node_season_data["Season definitions"]
end

node_visitor(("League user"))

node_visitor -->|"uses"| node_app
node_app -->|"routes to"| node_draft_ui
node_app -->|"routes to"| node_league_views
node_app_context -->|"loads league context"| node_api_client
node_auth_context -->|"verifies and logs in"| node_api_client
node_tribe_context -->|"loads tribes"| node_api_client
node_draft_ui -->|"requests draft actions"| node_api_client
node_draft_ui -->|"renders player data"| node_player_card
node_league_views -.->|"requests league data"| node_api_client
node_api_client -->|"sends API requests"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"mounts routes"| node_league_routes
node_server -->|"mounts routes"| node_draft_routes
node_server -->|"mounts routes"| node_player_routes
node_server -->|"mounts routes"| node_team_routes
node_server -->|"mounts routes"| node_summary_routes
node_server -.->|"mounts routes"| node_season_routes
node_server -->|"mounts routes"| node_game_routes
node_server -->|"mounts routes"| node_scoring_routes
node_server -->|"mounts routes"| node_extract_routes
node_auth_routes -.->|"persists auth data"| node_database
node_league_routes -->|"reads and writes"| node_database
node_draft_routes -->|"reads and writes"| node_database
node_player_routes -.->|"reads and writes"| node_database
node_team_routes -.->|"reads and writes"| node_database
node_summary_routes -->|"queries results"| node_database
node_game_routes -->|"reads and writes"| node_database
node_scoring_routes -->|"reads and writes"| node_database
node_scoring_routes -->|"uses scoring rules"| node_scoring_logic
node_extract_routes -->|"reads and writes"| node_database
node_extract_routes -->|"parses season facts"| node_wikipedia
node_extract_routes -->|"uses player helpers"| node_player_logic
node_extract_routes -->|"uses proposals"| node_proposal_logic
node_extract_routes -->|"requires authorization"| node_auth_middleware
node_draft_routes -->|"requires authorization"| node_auth_middleware
node_scoring_routes -->|"requires authorization"| node_auth_middleware
node_game_routes -->|"requires authorization"| node_auth_middleware
node_season_data -->|"seeded into"| node_database

click node_app "https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/App.tsx"
click node_app_context "https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/context/AppContext.tsx"
click node_auth_context "https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/context/AuthContext.tsx"
click node_tribe_context "https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/context/TribeContext.tsx"
click node_draft_ui "https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/pages/DraftPage.tsx"
click node_league_views "https://github.com/nathanblatter/survivor50draft/tree/master/frontend/src/pages"
click node_player_card "https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/components/PlayerCard.tsx"
click node_api_client "https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/api.ts"
click node_server "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/index.ts"
click node_auth_routes "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/auth.ts"
click node_league_routes "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/leagues.ts"
click node_draft_routes "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/draft.ts"
click node_player_routes "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/players.ts"
click node_team_routes "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/teams.ts"
click node_summary_routes "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/summary.ts"
click node_season_routes "https://github.com/nathanblatter/survivor50draft/tree/master/backend/src/routes"
click node_game_routes "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/gamestate.ts"
click node_scoring_routes "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/scoring.ts"
click node_extract_routes "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/extract.ts"
click node_wikipedia "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/lib/wikipedia.ts"
click node_scoring_logic "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/lib/scoring.ts"
click node_auth_middleware "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/middleware/auth.ts"
click node_database "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/db.ts"
click node_player_logic "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/lib/players.ts"
click node_proposal_logic "https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/lib/wikipediaProposals.ts"
click node_season_data "https://github.com/nathanblatter/survivor50draft/tree/master/backend/src/seasons"

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_app_context,node_auth_context,node_tribe_context,node_draft_ui,node_league_views,node_player_card,node_api_client,node_visitor toneBlue
class node_server,node_auth_routes,node_league_routes,node_draft_routes,node_player_routes,node_team_routes,node_summary_routes,node_season_routes,node_auth_middleware toneAmber
class node_game_routes,node_scoring_routes,node_extract_routes,node_wikipedia,node_scoring_logic,node_proposal_logic toneMint
class node_database,node_player_logic,node_season_data toneRose
```

## Components

### Web application

- [App routing](https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [League context](https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/context/AppContext.tsx): `frontend/src/context/AppContext.tsx`
- [Admin session](https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [Tribe context](https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/context/TribeContext.tsx): `frontend/src/context/TribeContext.tsx`
- [Fantasy draft](https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/pages/DraftPage.tsx): `frontend/src/pages/DraftPage.tsx`
- [League views](https://github.com/nathanblatter/survivor50draft/tree/master/frontend/src/pages): `frontend/src/pages`
- [Player cards](https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/components/PlayerCard.tsx): `frontend/src/components/PlayerCard.tsx`
- [API client](https://github.com/nathanblatter/survivor50draft/blob/master/frontend/src/api.ts): `frontend/src/api.ts`

### Backend API

- [Express entry](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/index.ts): `backend/src/index.ts`
- [Authentication](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/auth.ts): `backend/src/routes/auth.ts`
- [League management](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/leagues.ts): `backend/src/routes/leagues.ts`
- [Draft management](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/draft.ts): `backend/src/routes/draft.ts`
- [Castaway records](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/players.ts): `backend/src/routes/players.ts`
- [Fantasy teams](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/teams.ts): `backend/src/routes/teams.ts`
- [Standings and recaps](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/summary.ts): `backend/src/routes/summary.ts`
- [Shows and seasons](https://github.com/nathanblatter/survivor50draft/tree/master/backend/src/routes): `backend/src/routes`
- [Admin authorization](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/middleware/auth.ts): `backend/src/middleware/auth.ts`

### Season operations

- [Game state](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/gamestate.ts): `backend/src/routes/gamestate.ts`
- [Scoring events](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/scoring.ts): `backend/src/routes/scoring.ts`
- [Event extraction](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/routes/extract.ts): `backend/src/routes/extract.ts`
- [Wikipedia parser](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/lib/wikipedia.ts): `backend/src/lib/wikipedia.ts`
- [Scoring rules](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/lib/scoring.ts): `backend/src/lib/scoring.ts`
- [Wikipedia proposals](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/lib/wikipediaProposals.ts): `backend/src/lib/wikipediaProposals.ts`

### Persistence and domain logic

- [PostgreSQL](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/db.ts): `backend/src/db.ts`
- [Player utilities](https://github.com/nathanblatter/survivor50draft/blob/master/backend/src/lib/players.ts): `backend/src/lib/players.ts`
- [Season definitions](https://github.com/nathanblatter/survivor50draft/tree/master/backend/src/seasons): `backend/src/seasons`

### Other components

- **League user**

## Connections

- League user → App routing: uses (evidence: `frontend/src/App.tsx`)
- App routing → Fantasy draft: routes to (evidence: `frontend/src/App.tsx`)
- App routing → League views: routes to (evidence: `frontend/src/App.tsx`)
- League context → API client: loads league context (evidence: `frontend/src/context/AppContext.tsx`)
- Admin session → API client: verifies and logs in (evidence: `frontend/src/context/AuthContext.tsx`)
- Tribe context → API client: loads tribes (evidence: `frontend/src/context/TribeContext.tsx`)
- Fantasy draft → API client: requests draft actions (evidence: `frontend/src/api.ts`)
- Fantasy draft → Player cards: renders player data (evidence: `frontend/src/pages/DraftPage.tsx`)
- League views → API client: requests league data (evidence: `frontend/src/pages/admin/AdminContext.tsx`)
- API client → Express entry: sends API requests (evidence: `frontend/src/api.ts`)
- Express entry → Authentication: mounts routes (evidence: `backend/src/index.ts`)
- Express entry → League management: mounts routes (evidence: `backend/src/index.ts`)
- Express entry → Draft management: mounts routes (evidence: `backend/src/index.ts`)
- Express entry → Castaway records: mounts routes (evidence: `backend/src/index.ts`)
- Express entry → Fantasy teams: mounts routes (evidence: `backend/src/index.ts`)
- Express entry → Standings and recaps: mounts routes (evidence: `backend/src/index.ts`)
- Express entry → Shows and seasons: mounts routes (evidence: `backend/src/index.ts`)
- Express entry → Game state: mounts routes (evidence: `backend/src/index.ts`)
- Express entry → Scoring events: mounts routes (evidence: `backend/src/index.ts`)
- Express entry → Event extraction: mounts routes (evidence: `backend/src/index.ts`)
- Authentication → PostgreSQL: persists auth data
- League management → PostgreSQL: reads and writes (evidence: `backend/src/routes/leagues.ts`)
- Draft management → PostgreSQL: reads and writes (evidence: `backend/src/routes/draft.ts`)
- Castaway records → PostgreSQL: reads and writes
- Fantasy teams → PostgreSQL: reads and writes
- Standings and recaps → PostgreSQL: queries results (evidence: `backend/src/routes/summary.ts`)
- Game state → PostgreSQL: reads and writes (evidence: `backend/src/routes/gamestate.ts`)
- Scoring events → PostgreSQL: reads and writes (evidence: `backend/src/routes/scoring.ts`)
- Scoring events → Scoring rules: uses scoring rules (evidence: `backend/src/routes/scoring.ts`)
- Event extraction → PostgreSQL: reads and writes (evidence: `backend/src/routes/extract.ts`)
- Event extraction → Wikipedia parser: parses season facts (evidence: `backend/src/routes/extract.ts`)
- Event extraction → Player utilities: uses player helpers (evidence: `backend/src/routes/extract.ts`)
- Event extraction → Wikipedia proposals: uses proposals (evidence: `backend/src/routes/extract.ts`)
- Event extraction → Admin authorization: requires authorization (evidence: `backend/src/routes/extract.ts`)
- Draft management → Admin authorization: requires authorization (evidence: `backend/src/routes/draft.ts`)
- Scoring events → Admin authorization: requires authorization (evidence: `backend/src/routes/scoring.ts`)
- Game state → Admin authorization: requires authorization (evidence: `backend/src/routes/gamestate.ts`)
- Season definitions → PostgreSQL: seeded into (evidence: `backend/src/seed.ts`)
