# notfulii/pokefight architecture

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

- Interactive diagram: https://gitdiagram.com/notfulii/pokefight
- Repository: https://github.com/notfulii/pokefight

## Overview

PokeFIGHT is a local, turn-based Pokémon game built with Python and Pygame. The main workflow moves from login and mode selection through Pokémon selection and battle, then displays the result and rankings; multiplayer can request a second login before saving a win. Pokémon data and media are fetched or loaded into a local cache for gameplay. The README also documents debug controls, screen music, and animated battles. Some screen transitions and persistence details are supported only by the README or source index, so unsupported links are omitted.

Main entry points: [`main.py`](https://github.com/notfulii/pokefight/blob/main/main.py) (Game loop), [`get_pokemon.py`](https://github.com/notfulii/pokefight/blob/main/get_pokemon.py) (Pokédex loader), [`battle_screen.py`](https://github.com/notfulii/pokefight/blob/main/battle_screen.py) (Battle screen), [`select_pokemon_screen.py`](https://github.com/notfulii/pokefight/blob/main/select_pokemon_screen.py) (Pokémon selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flow["Game flow"]
  node_main["Game loop<br/>[main.py]"]
  node_start["Start screen<br/>[start_menu.py]"]
  node_difficulty["Mode selection"]
  node_selection["Pokémon selection"]
  node_result["Battle result<br/>[result_screen.py]"]
end

subgraph group_battle["Battle system"]
  node_battle_screen["Battle screen<br/>[battle_screen.py]"]
  node_pokemon["Pokémon combat model<br/>[pokemon.py]"]
end

subgraph group_pokemon_data["Pokémon data"]
  node_pokedex["Pokédex loader<br/>[get_pokemon.py]"]
  node_pokeapi["PokéAPI client<br/>[pokeapi.py]"]
  node_stats["Stats cache<br/>[stats.py]"]
  node_moves["Moves cache<br/>[moves.py]"]
end

subgraph group_accounts_scores["Accounts and rankings"]
  node_login["Login screen<br/>[login_screen.py]"]
  node_register["Registration screen<br/>[register_screen.py]"]
  node_rankings_screen["Rankings screen<br/>[rankings_screen.py]"]
  node_auth["Account authentication<br/>[auth.py]"]
  node_input["Text input<br/>[input_box.py]"]
  node_rankings["Ranking records<br/>[rankings.py]"]
end

subgraph group_game_services["Game services"]
  node_animation["Sprite animation<br/>[animation.py]"]
  node_backgrounds["Backgrounds<br/>[backgrounds.py]"]
  node_ui["UI rendering<br/>[ui.py]"]
  node_sound["Audio playback<br/>[sound.py]"]
  node_debug["Debug console<br/>[debug_console.py]"]
  node_settings["Game settings<br/>[settings.py]"]
end

node_player(("Player"))
node_api_service{{"PokéAPI"}}

node_player -->|"plays"| node_main
node_main -->|"creates screens"| node_start
node_main -->|"creates screens"| node_login
node_main -->|"creates screens"| node_register
node_main -->|"creates screens"| node_difficulty
node_main -->|"creates screens"| node_selection
node_main -->|"creates screens"| node_battle_screen
node_main -->|"creates screens"| node_result
node_main -->|"creates screens"| node_rankings_screen
node_main -->|"saves records"| node_rankings
node_login -->|"checks credentials"| node_auth
node_login -->|"uses fields"| node_input
node_register -->|"registers account"| node_auth
node_register -->|"uses fields"| node_input
node_selection -->|"reads choices"| node_pokedex
node_selection -->|"draws backdrop"| node_backgrounds
node_selection -->|"draws controls"| node_ui
node_battle_screen -->|"loads combatants"| node_pokedex
node_battle_screen -->|"calculates damage"| node_pokemon
node_battle_screen -->|"animates attacks"| node_animation
node_battle_screen -->|"draws battle"| node_ui
node_battle_screen -->|"plays effects"| node_sound
node_pokedex -->|"gets Pokémon data"| node_pokeapi
node_pokedex -->|"loads stats"| node_stats
node_pokedex -->|"loads moves"| node_moves
node_pokedex -->|"builds instances"| node_pokemon
node_pokedex -->|"loads GIFs"| node_animation
node_pokedex -->|"loads cries"| node_sound
node_pokeapi -->|"requests data"| node_api_service
node_stats -->|"requests move data"| node_pokeapi
node_moves -->|"requests move data"| node_pokeapi
node_main -->|"handles commands"| node_debug
node_main -->|"plays screen music"| node_sound
node_main -->|"loads backgrounds"| node_backgrounds
node_rankings_screen -->|"reads records"| node_rankings
node_main -->|"configures game"| node_settings

click node_main "https://github.com/notfulii/pokefight/blob/main/main.py"
click node_start "https://github.com/notfulii/pokefight/blob/main/start_menu.py"
click node_login "https://github.com/notfulii/pokefight/blob/main/login_screen.py"
click node_register "https://github.com/notfulii/pokefight/blob/main/register_screen.py"
click node_difficulty "https://github.com/notfulii/pokefight/blob/main/difficulty_screen.py"
click node_selection "https://github.com/notfulii/pokefight/blob/main/select_pokemon_screen.py"
click node_battle_screen "https://github.com/notfulii/pokefight/blob/main/battle_screen.py"
click node_pokemon "https://github.com/notfulii/pokefight/blob/main/pokemon.py"
click node_result "https://github.com/notfulii/pokefight/blob/main/result_screen.py"
click node_rankings_screen "https://github.com/notfulii/pokefight/blob/main/rankings_screen.py"
click node_auth "https://github.com/notfulii/pokefight/blob/main/auth.py"
click node_input "https://github.com/notfulii/pokefight/blob/main/input_box.py"
click node_rankings "https://github.com/notfulii/pokefight/blob/main/rankings.py"
click node_pokedex "https://github.com/notfulii/pokefight/blob/main/get_pokemon.py"
click node_pokeapi "https://github.com/notfulii/pokefight/blob/main/pokeapi.py"
click node_stats "https://github.com/notfulii/pokefight/blob/main/stats.py"
click node_moves "https://github.com/notfulii/pokefight/blob/main/moves.py"
click node_animation "https://github.com/notfulii/pokefight/blob/main/animation.py"
click node_backgrounds "https://github.com/notfulii/pokefight/blob/main/backgrounds.py"
click node_ui "https://github.com/notfulii/pokefight/blob/main/ui.py"
click node_sound "https://github.com/notfulii/pokefight/blob/main/sound.py"
click node_debug "https://github.com/notfulii/pokefight/blob/main/debug_console.py"
click node_settings "https://github.com/notfulii/pokefight/blob/main/settings.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_start,node_difficulty,node_selection,node_result toneBlue
class node_battle_screen,node_pokemon toneAmber
class node_pokedex,node_pokeapi,node_stats,node_moves,node_api_service toneMint
class node_login,node_register,node_rankings_screen,node_auth,node_input,node_rankings toneRose
class node_animation,node_backgrounds,node_ui,node_sound,node_debug,node_settings,node_player toneIndigo
```

## Components

### Game flow

- [Game loop](https://github.com/notfulii/pokefight/blob/main/main.py): `main.py`
- [Start screen](https://github.com/notfulii/pokefight/blob/main/start_menu.py): `start_menu.py`
- [Mode selection](https://github.com/notfulii/pokefight/blob/main/difficulty_screen.py): `difficulty_screen.py`
- [Pokémon selection](https://github.com/notfulii/pokefight/blob/main/select_pokemon_screen.py): `select_pokemon_screen.py`
- [Battle result](https://github.com/notfulii/pokefight/blob/main/result_screen.py): `result_screen.py`

### Battle system

- [Battle screen](https://github.com/notfulii/pokefight/blob/main/battle_screen.py): `battle_screen.py`
- [Pokémon combat model](https://github.com/notfulii/pokefight/blob/main/pokemon.py): `pokemon.py`

### Pokémon data

- [Pokédex loader](https://github.com/notfulii/pokefight/blob/main/get_pokemon.py): `get_pokemon.py`
- [PokéAPI client](https://github.com/notfulii/pokefight/blob/main/pokeapi.py): `pokeapi.py`
- [Stats cache](https://github.com/notfulii/pokefight/blob/main/stats.py): `stats.py`
- [Moves cache](https://github.com/notfulii/pokefight/blob/main/moves.py): `moves.py`

### Accounts and rankings

- [Login screen](https://github.com/notfulii/pokefight/blob/main/login_screen.py): `login_screen.py`
- [Registration screen](https://github.com/notfulii/pokefight/blob/main/register_screen.py): `register_screen.py`
- [Rankings screen](https://github.com/notfulii/pokefight/blob/main/rankings_screen.py): `rankings_screen.py`
- [Account authentication](https://github.com/notfulii/pokefight/blob/main/auth.py): `auth.py`
- [Text input](https://github.com/notfulii/pokefight/blob/main/input_box.py): `input_box.py`
- [Ranking records](https://github.com/notfulii/pokefight/blob/main/rankings.py): `rankings.py`

### Game services

- [Sprite animation](https://github.com/notfulii/pokefight/blob/main/animation.py): `animation.py`
- [Backgrounds](https://github.com/notfulii/pokefight/blob/main/backgrounds.py): `backgrounds.py`
- [UI rendering](https://github.com/notfulii/pokefight/blob/main/ui.py): `ui.py`
- [Audio playback](https://github.com/notfulii/pokefight/blob/main/sound.py): `sound.py`
- [Debug console](https://github.com/notfulii/pokefight/blob/main/debug_console.py): `debug_console.py`
- [Game settings](https://github.com/notfulii/pokefight/blob/main/settings.py): `settings.py`

### Other components

- **Player**
- **PokéAPI**

## Connections

- Player → Game loop: plays (evidence: `README.md`)
- Game loop → Start screen: creates screens (evidence: `main.py`)
- Game loop → Login screen: creates screens (evidence: `main.py`)
- Game loop → Registration screen: creates screens (evidence: `main.py`)
- Game loop → Mode selection: creates screens (evidence: `main.py`)
- Game loop → Pokémon selection: creates screens (evidence: `main.py`)
- Game loop → Battle screen: creates screens (evidence: `main.py`)
- Game loop → Battle result: creates screens (evidence: `main.py`)
- Game loop → Rankings screen: creates screens (evidence: `main.py`)
- Game loop → Ranking records: saves records (evidence: `main.py`)
- Login screen → Account authentication: checks credentials (evidence: `login_screen.py`)
- Login screen → Text input: uses fields (evidence: `login_screen.py`)
- Registration screen → Account authentication: registers account (evidence: `register_screen.py`)
- Registration screen → Text input: uses fields (evidence: `register_screen.py`)
- Pokémon selection → Pokédex loader: reads choices (evidence: `select_pokemon_screen.py`)
- Pokémon selection → Backgrounds: draws backdrop (evidence: `select_pokemon_screen.py`)
- Pokémon selection → UI rendering: draws controls (evidence: `select_pokemon_screen.py`)
- Battle screen → Pokédex loader: loads combatants (evidence: `battle_screen.py`)
- Battle screen → Pokémon combat model: calculates damage (evidence: `battle_screen.py`)
- Battle screen → Sprite animation: animates attacks (evidence: `battle_screen.py`)
- Battle screen → UI rendering: draws battle (evidence: `battle_screen.py`)
- Battle screen → Audio playback: plays effects (evidence: `battle_screen.py`)
- Pokédex loader → PokéAPI client: gets Pokémon data (evidence: `get_pokemon.py`)
- Pokédex loader → Stats cache: loads stats (evidence: `get_pokemon.py`)
- Pokédex loader → Moves cache: loads moves (evidence: `get_pokemon.py`)
- Pokédex loader → Pokémon combat model: builds instances (evidence: `get_pokemon.py`)
- Pokédex loader → Sprite animation: loads GIFs (evidence: `get_pokemon.py`)
- Pokédex loader → Audio playback: loads cries (evidence: `get_pokemon.py`)
- PokéAPI client → PokéAPI: requests data (evidence: `pokeapi.py`)
- Stats cache → PokéAPI client: requests move data (evidence: `stats.py`)
- Moves cache → PokéAPI client: requests move data (evidence: `moves.py`)
- Game loop → Debug console: handles commands (evidence: `main.py`)
- Game loop → Audio playback: plays screen music (evidence: `main.py`)
- Game loop → Backgrounds: loads backgrounds (evidence: `main.py`)
- Rankings screen → Ranking records: reads records (evidence: `rankings_screen.py`)
- Game loop → Game settings: configures game (evidence: `main.py`)
