# huydamm/pokemonvgc-calculator architecture

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

- Interactive diagram: https://gitdiagram.com/huydamm/pokemonvgc-calculator
- Repository: https://github.com/huydamm/pokemonvgc-calculator

## Overview

Pokémon Damage Calculator supports manual Gen 9 OU, VGC, and Champions matchup analysis, plus a Showdown live-battle overlay. The main workflow is to import a team or choose Pokémon, resolve a format and opponent set, edit battle conditions, then calculate and inspect move damage and bulk. The service layer wraps shared dex data, format/set lookup, and the damage engine. The README documents major capabilities not fully visible in the excerpts; live-overlay internals are only partly sampled, so its deeper runtime links are limited.

Main entry points: [`src/App.tsx`](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/App.tsx) (App orchestration), [`extension/content.ts`](https://github.com/huydamm/pokemonvgc-calculator/blob/main/extension/content.ts) (Overlay controller), [`src/services/sets.ts`](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/sets.ts) (Opponent sets), [`src/services/results.ts`](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/results.ts) (Move results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Calculator app"]
  node_entry["App entry<br/>[main.tsx]"]
  node_app["App orchestration<br/>[App.tsx]"]
end

subgraph group_domain["Matchup services"]
  node_team["Team parsing<br/>[team.ts]"]
  node_formats["Format discovery<br/>[formats.ts]"]
  node_sets["Opponent sets<br/>[sets.ts]"]
  node_data[("Shared dex<br/>[data.ts]")]
  node_conditions["Battle conditions<br/>[conditions.ts]"]
  node_engine["Damage engine<br/>[calc.ts]"]
  node_mechanics["Champions rules"]
  node_results["Move results<br/>[results.ts]"]
  node_teambox[("Saved teams<br/>[team-box.ts]")]
  node_cloudbox["Cloud teams<br/>[cloud-box.ts]"]
  node_account["Account service<br/>[account.ts]"]
end

subgraph group_view["Calculator views"]
  node_calcview["Matchup views<br/>[Results.tsx]"]
  node_opponent["Opponent editor<br/>[OpponentEditor.tsx]"]
  node_conditionsview["Field editor"]
  node_heatmap["Bulk heatmap<br/>[Heatmap.tsx]"]
  node_teamview["Team box view<br/>[TeamBox.tsx]"]
end

subgraph group_overlay["Live overlay"]
  node_inject["Board reader<br/>[inject.ts]"]
  node_content["Overlay controller<br/>[content.ts]"]
  node_panel["Overlay panel<br/>[panel.ts]"]
end

node_user(("Player"))
node_showdown(("Showdown battle"))
node_usage[("Usage data")]
node_formatdata[("Format data")]

node_user -->|"opens"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"parses teams"| node_team
node_app -->|"resolves format"| node_formats
node_app -->|"loads opponent"| node_sets
node_app -->|"renders editor"| node_opponent
node_app -->|"renders results"| node_calcview
node_app -->|"renders field"| node_conditionsview
node_app -->|"renders team"| node_teamview
node_team -->|"reads dex"| node_data
node_sets -->|"reads dex"| node_data
node_sets -->|"uses format"| node_formats
node_formats -->|"probes sources"| node_formatdata
node_sets -->|"fetches usage"| node_usage
node_conditionsview -->|"edits conditions"| node_conditions
node_calcview -->|"shows results"| node_results
node_results -->|"runs damage"| node_engine
node_results -->|"builds Pokémon"| node_team
node_results -->|"uses conditions"| node_conditions
node_engine -->|"uses generation"| node_data
node_engine -->|"applies rules"| node_mechanics
node_calcview -->|"offers heatmap"| node_heatmap
node_heatmap -->|"calculates bulk"| node_engine
node_heatmap -->|"uses conditions"| node_conditions
node_teamview -->|"loads and saves"| node_teambox
node_teamview -->|"parses roster"| node_team
node_teamview -->|"uses format"| node_formats
node_showdown -.->|"provides board"| node_inject
node_inject -->|"sends snapshots"| node_content
node_content -->|"resolves live format"| node_formats
node_content -->|"renders board"| node_panel
node_content -.->|"computes damage"| node_results
node_content -.->|"infers opponent"| node_sets
node_content -.->|"reads battle state"| node_conditions
node_user -.->|"syncs teams"| node_cloudbox
node_account -.->|"supports account"| node_cloudbox

click node_entry "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/main.tsx"
click node_app "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/App.tsx"
click node_team "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/team.ts"
click node_formats "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/formats.ts"
click node_sets "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/sets.ts"
click node_data "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/data.ts"
click node_conditions "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/conditions.ts"
click node_engine "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/calc.ts"
click node_mechanics "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/champions-mechanics.ts"
click node_results "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/results.ts"
click node_teambox "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/team-box.ts"
click node_cloudbox "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/cloud-box.ts"
click node_account "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/account.ts"
click node_calcview "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/components/Results.tsx"
click node_opponent "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/components/OpponentEditor.tsx"
click node_conditionsview "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/components/ConditionsPanel.tsx"
click node_heatmap "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/components/Heatmap.tsx"
click node_teamview "https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/components/TeamBox.tsx"
click node_inject "https://github.com/huydamm/pokemonvgc-calculator/blob/main/extension/inject.ts"
click node_content "https://github.com/huydamm/pokemonvgc-calculator/blob/main/extension/content.ts"
click node_panel "https://github.com/huydamm/pokemonvgc-calculator/blob/main/extension/panel.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_app toneBlue
class node_team,node_formats,node_sets,node_data,node_conditions,node_engine,node_mechanics,node_results,node_teambox,node_cloudbox,node_account,node_usage,node_formatdata toneAmber
class node_calcview,node_opponent,node_conditionsview,node_heatmap,node_teamview toneMint
class node_inject,node_content,node_panel toneRose
class node_user,node_showdown toneIndigo
```

## Components

### Calculator app

- [App entry](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/main.tsx): `src/main.tsx`
- [App orchestration](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/App.tsx): `src/App.tsx`

### Matchup services

- [Team parsing](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/team.ts): `src/services/team.ts`
- [Format discovery](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/formats.ts): `src/services/formats.ts`
- [Opponent sets](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/sets.ts): `src/services/sets.ts`
- [Shared dex](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/data.ts): `src/services/data.ts`
- [Battle conditions](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/conditions.ts): `src/services/conditions.ts`
- [Damage engine](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/calc.ts): `src/services/calc.ts`
- [Champions rules](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/champions-mechanics.ts): `src/services/champions-mechanics.ts`
- [Move results](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/results.ts): `src/services/results.ts`
- [Saved teams](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/team-box.ts): `src/services/team-box.ts`
- [Cloud teams](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/cloud-box.ts): `src/services/cloud-box.ts`
- [Account service](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/services/account.ts): `src/services/account.ts`

### Calculator views

- [Matchup views](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/components/Results.tsx): `src/components/Results.tsx`
- [Opponent editor](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/components/OpponentEditor.tsx): `src/components/OpponentEditor.tsx`
- [Field editor](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/components/ConditionsPanel.tsx): `src/components/ConditionsPanel.tsx`
- [Bulk heatmap](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/components/Heatmap.tsx): `src/components/Heatmap.tsx`
- [Team box view](https://github.com/huydamm/pokemonvgc-calculator/blob/main/src/components/TeamBox.tsx): `src/components/TeamBox.tsx`

### Live overlay

- [Board reader](https://github.com/huydamm/pokemonvgc-calculator/blob/main/extension/inject.ts): `extension/inject.ts`
- [Overlay controller](https://github.com/huydamm/pokemonvgc-calculator/blob/main/extension/content.ts): `extension/content.ts`
- [Overlay panel](https://github.com/huydamm/pokemonvgc-calculator/blob/main/extension/panel.ts): `extension/panel.ts`

### Other components

- **Player**
- **Showdown battle**
- **Usage data**
- **Format data**

## Connections

- Player → App entry: opens
- App entry → App orchestration: renders (evidence: `src/main.tsx`)
- App orchestration → Team parsing: parses teams (evidence: `src/App.tsx`)
- App orchestration → Format discovery: resolves format (evidence: `src/App.tsx`)
- App orchestration → Opponent sets: loads opponent (evidence: `src/App.tsx`)
- App orchestration → Opponent editor: renders editor (evidence: `src/App.tsx`)
- App orchestration → Matchup views: renders results (evidence: `src/App.tsx`)
- App orchestration → Field editor: renders field (evidence: `src/App.tsx`)
- App orchestration → Team box view: renders team (evidence: `src/App.tsx`)
- Team parsing → Shared dex: reads dex (evidence: `src/services/team.ts`)
- Opponent sets → Shared dex: reads dex (evidence: `src/services/sets.ts`)
- Opponent sets → Format discovery: uses format (evidence: `src/services/sets.ts`)
- Format discovery → Format data: probes sources (evidence: `src/services/formats.ts`)
- Opponent sets → Usage data: fetches usage (evidence: `src/services/sets.ts`)
- Field editor → Battle conditions: edits conditions (evidence: `src/components/ConditionsPanel.tsx`)
- Matchup views → Move results: shows results (evidence: `src/components/Results.tsx`)
- Move results → Damage engine: runs damage (evidence: `src/services/results.ts`)
- Move results → Team parsing: builds Pokémon (evidence: `src/services/results.ts`)
- Move results → Battle conditions: uses conditions (evidence: `src/services/results.ts`)
- Damage engine → Shared dex: uses generation (evidence: `src/services/calc.ts`)
- Damage engine → Champions rules: applies rules (evidence: `src/services/calc.ts`)
- Matchup views → Bulk heatmap: offers heatmap (evidence: `src/components/Results.tsx`)
- Bulk heatmap → Damage engine: calculates bulk (evidence: `src/components/Heatmap.tsx`)
- Bulk heatmap → Battle conditions: uses conditions (evidence: `src/components/Heatmap.tsx`)
- Team box view → Saved teams: loads and saves (evidence: `src/components/TeamBox.tsx`)
- Team box view → Team parsing: parses roster (evidence: `src/components/TeamBox.tsx`)
- Team box view → Format discovery: uses format (evidence: `src/components/TeamBox.tsx`)
- Showdown battle → Board reader: provides board
- Board reader → Overlay controller: sends snapshots (evidence: `extension/content.ts`)
- Overlay controller → Format discovery: resolves live format (evidence: `extension/content.ts`)
- Overlay controller → Overlay panel: renders board (evidence: `extension/content.ts`)
- Overlay controller → Move results: computes damage
- Overlay controller → Opponent sets: infers opponent (evidence: `extension/content.ts`)
- Overlay controller → Battle conditions: reads battle state
- Player → Cloud teams: syncs teams
- Account service → Cloud teams: supports account
