# ihsangan/mpl-calculator architecture

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

- Interactive diagram: https://gitdiagram.com/ihsangan/mpl-calculator
- Repository: https://github.com/ihsangan/mpl-calculator

## Overview

MPL Calculator is a browser app for exploring league standings and playoff odds. Users select a league, edit or sync its schedule, then view calculated standings and run standard or ELO-weighted playoff simulations; results include match countdowns and can be exported as images. The app also supports theme and league selection. The graph follows documented capabilities and visible imports/calls; some UI wiring and unsampled implementations are represented only where the README or source index supports them.

Main entry points: [`src/App.tsx`](https://github.com/ihsangan/mpl-calculator/blob/main/src/App.tsx) (App state and routing), [`src/components/schedule/schedule-editor.tsx`](https://github.com/ihsangan/mpl-calculator/blob/main/src/components/schedule/schedule-editor.tsx) (Schedule editor), [`src/lib/simulation.ts`](https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/simulation.ts) (Monte Carlo engine), [`src/hooks/use-liquipedia-sync.ts`](https://github.com/ihsangan/mpl-calculator/blob/main/src/hooks/use-liquipedia-sync.ts) (Live sync hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_entry["App state and routing<br/>[App.tsx]"]
  node_league["League configuration<br/>[leagues.ts]"]
  node_header["League and theme controls<br/>[header.tsx]"]
  node_theme["Theme provider<br/>[theme-provider.tsx]"]
  node_footer["Attribution footer<br/>[footer.tsx]"]
end

subgraph group_schedule["League Schedule"]
  node_schedule_editor["Schedule editor"]
  node_match_card["Match card<br/>[match-card.tsx]"]
  node_next_match["Next match countdown"]
end

subgraph group_analysis["Standings and Odds"]
  node_standings_view["Standings table"]
  node_probability_view["Playoff probabilities"]
  node_rank_view["Rank scenarios"]
  node_standings["Standings and tiebreakers<br/>[standings.ts]"]
  node_simulation_hook["Simulation hook<br/>[use-simulation.ts]"]
  node_worker["Simulation worker"]
  node_simulation["Monte Carlo engine<br/>[simulation.ts]"]
  node_elo["ELO engine<br/>[elo.ts]"]
end

subgraph group_sync["Schedule Sync"]
  node_browser_sync["Live sync hook"]
  node_mediawiki["Browser MediaWiki client<br/>[mediawiki.ts]"]
  node_sync_cli["Liquipedia sync CLI<br/>[liquipedia.ts]"]
end

subgraph group_shared["Shared Services"]
  node_image_export["Image export hook"]
  node_date_utils["Date and countdown utilities<br/>[date-utils.ts]"]
end

node_user(("League user"))
node_liquipedia{{"Liquipedia API"}}

node_user -->|"selects league"| node_entry
node_entry -->|"loads league"| node_league
node_entry -->|"renders"| node_header
node_entry -->|"uses provider"| node_theme
node_entry -->|"renders"| node_footer
node_entry -->|"renders"| node_schedule_editor
node_entry -->|"renders"| node_next_match
node_entry -->|"renders"| node_standings_view
node_entry -->|"renders"| node_probability_view
node_entry -->|"renders"| node_rank_view
node_entry -->|"starts sync"| node_browser_sync
node_league -.->|"provides matches"| node_schedule_editor
node_schedule_editor -->|"renders"| node_match_card
node_entry -.->|"requests simulations"| node_simulation_hook
node_simulation_hook -->|"dispatches jobs"| node_worker
node_worker -->|"runs simulation"| node_simulation
node_simulation -->|"calculates standings"| node_standings
node_simulation -->|"loads ELO engine"| node_elo
node_entry -->|"calculates standings"| node_standings
node_standings_view -.->|"exports image"| node_image_export
node_probability_view -->|"exports image"| node_image_export
node_rank_view -->|"exports image"| node_image_export
node_browser_sync -->|"uses client"| node_mediawiki
node_mediawiki -->|"fetches MediaWiki API"| node_liquipedia
node_sync_cli -->|"fetches OpenAPI data"| node_liquipedia
node_schedule_editor -.->|"offers live sync"| node_browser_sync
node_match_card -->|"formats match dates"| node_date_utils
node_next_match -->|"formats countdown"| node_date_utils

click node_entry "https://github.com/ihsangan/mpl-calculator/blob/main/src/App.tsx"
click node_league "https://github.com/ihsangan/mpl-calculator/blob/main/src/leagues.ts"
click node_header "https://github.com/ihsangan/mpl-calculator/blob/main/src/components/header.tsx"
click node_theme "https://github.com/ihsangan/mpl-calculator/blob/main/src/components/theme-provider.tsx"
click node_footer "https://github.com/ihsangan/mpl-calculator/blob/main/src/components/footer.tsx"
click node_schedule_editor "https://github.com/ihsangan/mpl-calculator/blob/main/src/components/schedule/schedule-editor.tsx"
click node_match_card "https://github.com/ihsangan/mpl-calculator/blob/main/src/components/schedule/match-card.tsx"
click node_next_match "https://github.com/ihsangan/mpl-calculator/blob/main/src/components/schedule/next-match-card.tsx"
click node_browser_sync "https://github.com/ihsangan/mpl-calculator/blob/main/src/hooks/use-liquipedia-sync.ts"
click node_mediawiki "https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/mediawiki.ts"
click node_sync_cli "https://github.com/ihsangan/mpl-calculator/blob/main/liquipedia.ts"
click node_standings_view "https://github.com/ihsangan/mpl-calculator/blob/main/src/components/standings/standings-table.tsx"
click node_probability_view "https://github.com/ihsangan/mpl-calculator/blob/main/src/components/probabilities/probabilities-card.tsx"
click node_rank_view "https://github.com/ihsangan/mpl-calculator/blob/main/src/components/probabilities/rank-scenarios-card.tsx"
click node_standings "https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/standings.ts"
click node_simulation_hook "https://github.com/ihsangan/mpl-calculator/blob/main/src/hooks/use-simulation.ts"
click node_worker "https://github.com/ihsangan/mpl-calculator/blob/main/src/workers/simulation.worker.ts"
click node_simulation "https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/simulation.ts"
click node_elo "https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/elo.ts"
click node_image_export "https://github.com/ihsangan/mpl-calculator/blob/main/src/hooks/use-save-as-image.ts"
click node_date_utils "https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/date-utils.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_entry,node_league,node_header,node_theme,node_footer,node_user toneBlue
class node_schedule_editor,node_match_card,node_next_match toneAmber
class node_standings_view,node_probability_view,node_rank_view,node_standings,node_simulation_hook,node_worker,node_simulation,node_elo,node_liquipedia toneMint
class node_browser_sync,node_mediawiki,node_sync_cli toneRose
class node_image_export,node_date_utils toneIndigo
```

## Components

### Application

- [App state and routing](https://github.com/ihsangan/mpl-calculator/blob/main/src/App.tsx): `src/App.tsx`
- [League configuration](https://github.com/ihsangan/mpl-calculator/blob/main/src/leagues.ts): `src/leagues.ts`
- [League and theme controls](https://github.com/ihsangan/mpl-calculator/blob/main/src/components/header.tsx): `src/components/header.tsx`
- [Theme provider](https://github.com/ihsangan/mpl-calculator/blob/main/src/components/theme-provider.tsx): `src/components/theme-provider.tsx`
- [Attribution footer](https://github.com/ihsangan/mpl-calculator/blob/main/src/components/footer.tsx): `src/components/footer.tsx`

### League Schedule

- [Schedule editor](https://github.com/ihsangan/mpl-calculator/blob/main/src/components/schedule/schedule-editor.tsx): `src/components/schedule/schedule-editor.tsx`
- [Match card](https://github.com/ihsangan/mpl-calculator/blob/main/src/components/schedule/match-card.tsx): `src/components/schedule/match-card.tsx`
- [Next match countdown](https://github.com/ihsangan/mpl-calculator/blob/main/src/components/schedule/next-match-card.tsx): `src/components/schedule/next-match-card.tsx`

### Standings and Odds

- [Standings table](https://github.com/ihsangan/mpl-calculator/blob/main/src/components/standings/standings-table.tsx): `src/components/standings/standings-table.tsx`
- [Playoff probabilities](https://github.com/ihsangan/mpl-calculator/blob/main/src/components/probabilities/probabilities-card.tsx): `src/components/probabilities/probabilities-card.tsx`
- [Rank scenarios](https://github.com/ihsangan/mpl-calculator/blob/main/src/components/probabilities/rank-scenarios-card.tsx): `src/components/probabilities/rank-scenarios-card.tsx`
- [Standings and tiebreakers](https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/standings.ts): `src/lib/standings.ts`
- [Simulation hook](https://github.com/ihsangan/mpl-calculator/blob/main/src/hooks/use-simulation.ts): `src/hooks/use-simulation.ts`
- [Simulation worker](https://github.com/ihsangan/mpl-calculator/blob/main/src/workers/simulation.worker.ts): `src/workers/simulation.worker.ts`
- [Monte Carlo engine](https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/simulation.ts): `src/lib/simulation.ts`
- [ELO engine](https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/elo.ts): `src/lib/elo.ts`

### Schedule Sync

- [Live sync hook](https://github.com/ihsangan/mpl-calculator/blob/main/src/hooks/use-liquipedia-sync.ts): `src/hooks/use-liquipedia-sync.ts`
- [Browser MediaWiki client](https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/mediawiki.ts): `src/lib/mediawiki.ts`
- [Liquipedia sync CLI](https://github.com/ihsangan/mpl-calculator/blob/main/liquipedia.ts): `liquipedia.ts`

### Shared Services

- [Image export hook](https://github.com/ihsangan/mpl-calculator/blob/main/src/hooks/use-save-as-image.ts): `src/hooks/use-save-as-image.ts`
- [Date and countdown utilities](https://github.com/ihsangan/mpl-calculator/blob/main/src/lib/date-utils.ts): `src/lib/date-utils.ts`

### Other components

- **League user**
- **Liquipedia API**

## Connections

- League user → App state and routing: selects league
- App state and routing → League configuration: loads league (evidence: `src/App.tsx`)
- App state and routing → League and theme controls: renders (evidence: `src/App.tsx`)
- App state and routing → Theme provider: uses provider (evidence: `src/App.tsx`)
- App state and routing → Attribution footer: renders (evidence: `src/App.tsx`)
- App state and routing → Schedule editor: renders (evidence: `src/App.tsx`)
- App state and routing → Next match countdown: renders (evidence: `src/App.tsx`)
- App state and routing → Standings table: renders (evidence: `src/App.tsx`)
- App state and routing → Playoff probabilities: renders (evidence: `src/App.tsx`)
- App state and routing → Rank scenarios: renders (evidence: `src/App.tsx`)
- App state and routing → Live sync hook: starts sync (evidence: `src/App.tsx`)
- League configuration → Schedule editor: provides matches
- Schedule editor → Match card: renders (evidence: `src/components/schedule/schedule-editor.tsx`)
- App state and routing → Simulation hook: requests simulations (evidence: `src/App.tsx`)
- Simulation hook → Simulation worker: dispatches jobs (evidence: `src/hooks/use-simulation.ts`)
- Simulation worker → Monte Carlo engine: runs simulation (evidence: `src/workers/simulation.worker.ts`)
- Monte Carlo engine → Standings and tiebreakers: calculates standings (evidence: `src/lib/simulation.ts`)
- Monte Carlo engine → ELO engine: loads ELO engine (evidence: `src/lib/simulation.ts`)
- App state and routing → Standings and tiebreakers: calculates standings (evidence: `src/App.tsx`)
- Standings table → Image export hook: exports image (evidence: `src/components/standings/standings-table.tsx`)
- Playoff probabilities → Image export hook: exports image (evidence: `src/components/probabilities/probabilities-card.tsx`)
- Rank scenarios → Image export hook: exports image (evidence: `src/components/probabilities/rank-scenarios-card.tsx`)
- Live sync hook → Browser MediaWiki client: uses client (evidence: `src/hooks/use-liquipedia-sync.ts`)
- Browser MediaWiki client → Liquipedia API: fetches MediaWiki API
- Liquipedia sync CLI → Liquipedia API: fetches OpenAPI data
- Schedule editor → Live sync hook: offers live sync
- Match card → Date and countdown utilities: formats match dates (evidence: `src/components/schedule/match-card.tsx`)
- Next match countdown → Date and countdown utilities: formats countdown (evidence: `src/components/schedule/next-match-card.tsx`)
