# amlan-sinha07/pokemon_advisor architecture

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

- Interactive diagram: https://gitdiagram.com/amlan-sinha07/pokemon_advisor
- Repository: https://github.com/amlan-sinha07/pokemon_advisor

## Overview

Pokemon Champions Battle Advisor is a CLI tool for choosing a four-Pokemon squad before a match and recommending a move during battle; it also manages a saved six-Pokemon box. The main workflow starts in the CLI, loads Pokemon and move data, and delegates to separate pre-match or battle advisors. The battle advisor uses type matchups and a Python-to-C++ damage calculation path. The README documents cached data and optional live PokeAPI fetching. Some runtime wiring is supported only by the README or source index, so those links are identified accordingly.

Main entry points: [`data_loader.py`](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/data_loader.py) (Data Loader), [`main.py`](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/main.py) (CLI Modes), [`engine/damage_calc.py`](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/damage_calc.py) (Damage Calculator), [`engine/type_calc.py`](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/type_calc.py) (Type Calculator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["CLI and Team Setup"]
  node_cli["CLI Modes<br/>[main.py]"]
  node_box["Box Manager<br/>[box_manager.py]"]
end

subgraph group_data["Data and Persistence"]
  node_boxstore[("Saved Box")]
  node_loader["Data Loader<br/>[data_loader.py]"]
  node_pokemondata[("Pokemon Cache<br/>[pokemon_all.json]")]
  node_movedata[("Move Caches")]
  node_fetcher["PokeAPI Fetcher<br/>[fetch_data.py]"]
  node_pokemon["Pokemon Model<br/>[pokemon.py]"]
  node_move["Move Model<br/>[move.py]"]
end

subgraph group_advice["Battle Analysis"]
  node_prematch["Team Advisor"]
  node_battle["Move Advisor<br/>[battle_advisor.py]"]
end

subgraph group_calculation["Calculation Engine"]
  node_typecalc["Type Calculator<br/>[type_calc.py]"]
  node_typechart[("Type Chart<br/>[type_chart.json]")]
  node_damage["Damage Calculator<br/>[damage_calc.py]"]
  node_cpp["C++ Damage Engine<br/>[damage_calc.cpp]"]
end

node_player(("Player"))
node_pokeapi["PokeAPI"]

node_player -->|"chooses mode"| node_cli
node_cli -->|"manages box"| node_box
node_box -->|"reads and writes"| node_boxstore
node_cli -->|"loads Pokemon"| node_loader
node_loader -->|"reads cache"| node_pokemondata
node_loader -->|"constructs"| node_pokemon
node_loader -->|"constructs"| node_move
node_loader -->|"reads and writes"| node_movedata
node_loader -->|"fetches missing moves"| node_fetcher
node_fetcher -->|"requests data"| node_pokeapi
node_cli -->|"requests team picks"| node_prematch
node_cli -->|"requests move advice"| node_battle
node_prematch -->|"scores matchups"| node_typecalc
node_typecalc -->|"loads chart"| node_typechart
node_battle -->|"evaluates moves"| node_damage
node_damage -->|"gets effectiveness"| node_typecalc
node_damage -.->|"runs damage engine"| node_cpp

click node_cli "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/main.py"
click node_box "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/box_manager.py"
click node_loader "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/data_loader.py"
click node_pokemondata "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/data/pokemon_all.json"
click node_movedata "https://github.com/amlan-sinha07/pokemon_advisor/tree/main/data"
click node_fetcher "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/scraper/fetch_data.py"
click node_pokemon "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/models/pokemon.py"
click node_move "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/models/move.py"
click node_prematch "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/pre_match_advisor.py"
click node_battle "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/battle_advisor.py"
click node_typecalc "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/type_calc.py"
click node_typechart "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/data/type_chart.json"
click node_damage "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/damage_calc.py"
click node_cpp "https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/damage_calc.cpp"

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_cli,node_box toneBlue
class node_boxstore,node_loader,node_pokemondata,node_movedata,node_fetcher,node_pokemon,node_move toneAmber
class node_prematch,node_battle,node_pokeapi toneMint
class node_typecalc,node_typechart,node_damage,node_cpp toneRose
class node_player toneIndigo
```

## Components

### CLI and Team Setup

- [CLI Modes](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/main.py): `main.py`
- [Box Manager](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/box_manager.py): `box_manager.py`

### Data and Persistence

- **Saved Box**
- [Data Loader](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/data_loader.py): `data_loader.py`
- [Pokemon Cache](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/data/pokemon_all.json): `data/pokemon_all.json`
- [Move Caches](https://github.com/amlan-sinha07/pokemon_advisor/tree/main/data): `data`
- [PokeAPI Fetcher](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/scraper/fetch_data.py): `scraper/fetch_data.py`
- [Pokemon Model](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/models/pokemon.py): `models/pokemon.py`
- [Move Model](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/models/move.py): `models/move.py`

### Battle Analysis

- [Team Advisor](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/pre_match_advisor.py): `engine/pre_match_advisor.py`
- [Move Advisor](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/battle_advisor.py): `engine/battle_advisor.py`

### Calculation Engine

- [Type Calculator](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/type_calc.py): `engine/type_calc.py`
- [Type Chart](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/data/type_chart.json): `data/type_chart.json`
- [Damage Calculator](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/damage_calc.py): `engine/damage_calc.py`
- [C++ Damage Engine](https://github.com/amlan-sinha07/pokemon_advisor/blob/main/engine/damage_calc.cpp): `engine/damage_calc.cpp`

### Other components

- **Player**
- **PokeAPI**

## Connections

- Player → CLI Modes: chooses mode (evidence: `README.md`)
- CLI Modes → Box Manager: manages box (evidence: `main.py`)
- Box Manager → Saved Box: reads and writes (evidence: `box_manager.py`)
- CLI Modes → Data Loader: loads Pokemon (evidence: `main.py`)
- Data Loader → Pokemon Cache: reads cache (evidence: `data_loader.py`)
- Data Loader → Pokemon Model: constructs (evidence: `data_loader.py`)
- Data Loader → Move Model: constructs (evidence: `data_loader.py`)
- Data Loader → Move Caches: reads and writes (evidence: `data_loader.py`)
- Data Loader → PokeAPI Fetcher: fetches missing moves (evidence: `data_loader.py`)
- PokeAPI Fetcher → PokeAPI: requests data (evidence: `scraper/fetch_data.py`)
- CLI Modes → Team Advisor: requests team picks (evidence: `main.py`)
- CLI Modes → Move Advisor: requests move advice (evidence: `main.py`)
- Team Advisor → Type Calculator: scores matchups (evidence: `engine/pre_match_advisor.py`)
- Type Calculator → Type Chart: loads chart (evidence: `engine/type_calc.py`)
- Move Advisor → Damage Calculator: evaluates moves (evidence: `engine/battle_advisor.py`)
- Damage Calculator → Type Calculator: gets effectiveness (evidence: `engine/damage_calc.py`)
- Damage Calculator → C++ Damage Engine: runs damage engine (evidence: `README.md`)
