# veekun/pokedex architecture

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

- Interactive diagram: https://gitdiagram.com/veekun/pokedex
- Repository: https://github.com/veekun/pokedex

## Overview

Pokedex is a Pokémon game-data library and CLI: source data is loaded into a relational database, then accessed through search and lookup tools. The graph also shows the translation, media, and save-structure interfaces advertised or evidenced by the repository. Sampled excerpts establish the CLI load/search paths and the database-backed operations; other library modules are included by their exact tree paths, but their internal wiring is not inferred.

Main entry points: [`pokedex/main.py`](https://github.com/veekun/pokedex/blob/master/pokedex/main.py) (Command dispatcher), [`pokedex/db/load.py`](https://github.com/veekun/pokedex/blob/master/pokedex/db/load.py) (CSV loader), [`pokedex/struct/__init__.py`](https://github.com/veekun/pokedex/blob/master/pokedex/struct/__init__.py) (Save-file interface), [`pokedex/cli/search.py`](https://github.com/veekun/pokedex/blob/master/pokedex/cli/search.py) (Search command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_main["Command dispatcher<br/>[main.py]"]
  node_cli_search["Search command<br/>[search.py]"]
end

subgraph group_data["Data and schema"]
  node_loader["CSV loader<br/>[load.py]"]
  node_translations["Translation handling<br/>[translations.py]"]
  node_schema["Game-data schema<br/>[tables.py]"]
end

subgraph group_query["Search and lookup"]
  node_search["Structured search<br/>[search.py]"]
  node_lookup["Name lookup index<br/>[lookup.py]"]
end

subgraph group_library["Library interfaces"]
  node_formulae["Game formulae<br/>[formulae.py]"]
  node_compatibility["Game compatibility<br/>[compatibility.py]"]
  node_media["Media accessors<br/>[media.py]"]
  node_pokemon_struct["Pokémon save structures<br/>[_pokemon_struct.py]"]
  node_struct_api["Save-file interface<br/>[__init__.py]"]
end

node_user(("CLI user"))
node_csv_source["CSV data source"]
node_database[("Relational database")]
node_whoosh[("Whoosh index")]

node_user -->|"runs commands"| node_main
node_main -->|"dispatches search"| node_cli_search
node_cli_search -->|"gets session"| node_main
node_main -->|"opens session"| node_database
node_main -->|"runs load"| node_loader
node_csv_source -->|"reads CSV"| node_loader
node_loader -->|"loads translations"| node_translations
node_loader -->|"uses tables"| node_schema
node_loader -->|"writes rows"| node_database
node_cli_search -->|"runs query"| node_search
node_search -->|"queries models"| node_schema
node_search -->|"reads records"| node_database
node_main -->|"opens lookup"| node_lookup
node_lookup -->|"queries index"| node_whoosh
node_lookup -->|"resolves records"| node_database
node_struct_api -->|"parses structure"| node_pokemon_struct
node_struct_api -->|"loads game data"| node_schema
node_struct_api -->|"queries records"| node_database

click node_main "https://github.com/veekun/pokedex/blob/master/pokedex/main.py"
click node_cli_search "https://github.com/veekun/pokedex/blob/master/pokedex/cli/search.py"
click node_loader "https://github.com/veekun/pokedex/blob/master/pokedex/db/load.py"
click node_translations "https://github.com/veekun/pokedex/blob/master/pokedex/db/translations.py"
click node_schema "https://github.com/veekun/pokedex/blob/master/pokedex/db/tables.py"
click node_search "https://github.com/veekun/pokedex/blob/master/pokedex/search.py"
click node_lookup "https://github.com/veekun/pokedex/blob/master/pokedex/lookup.py"
click node_formulae "https://github.com/veekun/pokedex/blob/master/pokedex/formulae.py"
click node_compatibility "https://github.com/veekun/pokedex/blob/master/pokedex/compatibility.py"
click node_media "https://github.com/veekun/pokedex/blob/master/pokedex/util/media.py"
click node_pokemon_struct "https://github.com/veekun/pokedex/blob/master/pokedex/struct/_pokemon_struct.py"
click node_struct_api "https://github.com/veekun/pokedex/blob/master/pokedex/struct/__init__.py"

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_main,node_cli_search,node_user toneBlue
class node_loader,node_translations,node_schema,node_database,node_whoosh toneAmber
class node_search,node_lookup toneMint
class node_formulae,node_compatibility,node_media,node_pokemon_struct,node_struct_api toneRose
class node_csv_source toneIndigo
```

## Components

### CLI workflows

- [Command dispatcher](https://github.com/veekun/pokedex/blob/master/pokedex/main.py): `pokedex/main.py`
- [Search command](https://github.com/veekun/pokedex/blob/master/pokedex/cli/search.py): `pokedex/cli/search.py`

### Data and schema

- [CSV loader](https://github.com/veekun/pokedex/blob/master/pokedex/db/load.py): `pokedex/db/load.py`
- [Translation handling](https://github.com/veekun/pokedex/blob/master/pokedex/db/translations.py): `pokedex/db/translations.py`
- [Game-data schema](https://github.com/veekun/pokedex/blob/master/pokedex/db/tables.py): `pokedex/db/tables.py`

### Search and lookup

- [Structured search](https://github.com/veekun/pokedex/blob/master/pokedex/search.py): `pokedex/search.py`
- [Name lookup index](https://github.com/veekun/pokedex/blob/master/pokedex/lookup.py): `pokedex/lookup.py`

### Library interfaces

- [Game formulae](https://github.com/veekun/pokedex/blob/master/pokedex/formulae.py): `pokedex/formulae.py`
- [Game compatibility](https://github.com/veekun/pokedex/blob/master/pokedex/compatibility.py): `pokedex/compatibility.py`
- [Media accessors](https://github.com/veekun/pokedex/blob/master/pokedex/util/media.py): `pokedex/util/media.py`
- [Pokémon save structures](https://github.com/veekun/pokedex/blob/master/pokedex/struct/_pokemon_struct.py): `pokedex/struct/_pokemon_struct.py`
- [Save-file interface](https://github.com/veekun/pokedex/blob/master/pokedex/struct/__init__.py): `pokedex/struct/__init__.py`

### Other components

- **CLI user**
- **CSV data source**
- **Relational database**
- **Whoosh index**

## Connections

- CLI user → Command dispatcher: runs commands
- Command dispatcher → Search command: dispatches search
- Search command → Command dispatcher: gets session
- Command dispatcher → Relational database: opens session
- Command dispatcher → CSV loader: runs load
- CSV data source → CSV loader: reads CSV
- CSV loader → Translation handling: loads translations
- CSV loader → Game-data schema: uses tables
- CSV loader → Relational database: writes rows
- Search command → Structured search: runs query
- Structured search → Game-data schema: queries models
- Structured search → Relational database: reads records
- Command dispatcher → Name lookup index: opens lookup
- Name lookup index → Whoosh index: queries index
- Name lookup index → Relational database: resolves records
- Save-file interface → Pokémon save structures: parses structure
- Save-file interface → Game-data schema: loads game data
- Save-file interface → Relational database: queries records
