# geffrerson7/iv100-bot architecture

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

- Interactive diagram: https://gitdiagram.com/geffrerson7/iv100-bot
- Repository: https://github.com/geffrerson7/iv100-bot

## Overview

This repository implements a Telegram bot that periodically finds Pokémon coordinates for IV 90 or IV 100 and posts formatted results to a configured Telegram group. Users start or stop a search with commands; scheduled callbacks obtain data, build messages, and send them. The app can receive Telegram updates through a FastAPI webhook or run Telegram polling in debug mode. The graph includes the documented command capabilities and data-enrichment files. Some service internals and endpoint behavior are unsampled, so only relationships shown in excerpts, the source index, or README are connected.

Main entry points: [`bot/ptb.py`](https://github.com/geffrerson7/iv100-bot/blob/main/bot/ptb.py) (Telegram application), [`main.py`](https://github.com/geffrerson7/iv100-bot/blob/main/main.py) (Startup and routing), [`api.py`](https://github.com/geffrerson7/iv100-bot/blob/main/api.py) (FastAPI application), [`bot/service.py`](https://github.com/geffrerson7/iv100-bot/blob/main/bot/service.py) (Coordinate processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime entry"]
  node_main["Startup and routing<br/>[main.py]"]
  node_api["FastAPI application<br/>[api.py]"]
  node_webhook["Webhook endpoint<br/>[endpoints.py]"]
  node_ptb["Telegram application<br/>[ptb.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_botflow["Bot workflow"]
  node_commands["IV and stop commands<br/>[commands.py]"]
  node_scheduled["Scheduled IV callbacks<br/>[commands.py]"]
  node_handlers["Update error handling<br/>[handlers.py]"]
  node_logging["Logging setup<br/>[log.py]"]
end

subgraph group_pokemon["Pokemon data"]
  node_service["Coordinate processing<br/>[service.py]"]
  node_pokemon_names["Pokemon name data<br/>[pokemon_data.json]"]
  node_move_data["Move metadata<br/>[moves.json]"]
end

node_user(("Telegram user"))
node_telegram{{"Telegram platform"}}
node_pokemon_api{{"Pokemon map services"}}
node_telegram_group(("Configured Telegram group"))

node_user -->|"sends commands"| node_telegram
node_main -->|"reads settings"| node_config
node_main -->|"runs app"| node_api
node_main -->|"registers commands"| node_ptb
node_main -->|"registers handlers"| node_commands
node_api -->|"selects mode"| node_config
node_api -->|"mounts router"| node_webhook
node_api -->|"uses lifespan"| node_ptb
node_webhook -->|"dispatches updates"| node_ptb
node_telegram -->|"posts updates"| node_webhook
node_ptb -->|"reads token"| node_config
node_ptb -->|"configures webhook"| node_telegram
node_telegram -.->|"delivers updates"| node_ptb
node_commands -->|"schedules callbacks"| node_scheduled
node_scheduled -->|"generates messages"| node_service
node_service -->|"fetches coordinates"| node_pokemon_api
node_service -->|"reads names"| node_pokemon_names
node_service -->|"reads moves"| node_move_data
node_commands -->|"sends results"| node_telegram_group
node_user -->|"invokes commands"| node_commands
node_ptb -->|"routes errors"| node_handlers
node_handlers -->|"uses logger"| node_logging
node_handlers -->|"sends notices"| node_telegram_group

click node_main "https://github.com/geffrerson7/iv100-bot/blob/main/main.py"
click node_api "https://github.com/geffrerson7/iv100-bot/blob/main/api.py"
click node_webhook "https://github.com/geffrerson7/iv100-bot/blob/main/bot/endpoints.py"
click node_ptb "https://github.com/geffrerson7/iv100-bot/blob/main/bot/ptb.py"
click node_config "https://github.com/geffrerson7/iv100-bot/blob/main/settings/config.py"
click node_commands "https://github.com/geffrerson7/iv100-bot/blob/main/bot/commands.py"
click node_scheduled "https://github.com/geffrerson7/iv100-bot/blob/main/bot/commands.py"
click node_handlers "https://github.com/geffrerson7/iv100-bot/blob/main/bot/handlers.py"
click node_logging "https://github.com/geffrerson7/iv100-bot/blob/main/common/log.py"
click node_service "https://github.com/geffrerson7/iv100-bot/blob/main/bot/service.py"
click node_pokemon_names "https://github.com/geffrerson7/iv100-bot/blob/main/data/pokemon_data.json"
click node_move_data "https://github.com/geffrerson7/iv100-bot/blob/main/data/moves.json"

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_api,node_webhook,node_ptb,node_config,node_user toneBlue
class node_commands,node_scheduled,node_handlers,node_logging toneAmber
class node_service,node_pokemon_names,node_move_data toneMint
class node_telegram,node_pokemon_api,node_telegram_group toneIndigo
```

## Components

### Runtime entry

- [Startup and routing](https://github.com/geffrerson7/iv100-bot/blob/main/main.py): `main.py`
- [FastAPI application](https://github.com/geffrerson7/iv100-bot/blob/main/api.py): `api.py`
- [Webhook endpoint](https://github.com/geffrerson7/iv100-bot/blob/main/bot/endpoints.py): `bot/endpoints.py`
- [Telegram application](https://github.com/geffrerson7/iv100-bot/blob/main/bot/ptb.py): `bot/ptb.py`
- [Runtime settings](https://github.com/geffrerson7/iv100-bot/blob/main/settings/config.py): `settings/config.py`

### Bot workflow

- [IV and stop commands](https://github.com/geffrerson7/iv100-bot/blob/main/bot/commands.py): `bot/commands.py`
- [Scheduled IV callbacks](https://github.com/geffrerson7/iv100-bot/blob/main/bot/commands.py): `bot/commands.py`
- [Update error handling](https://github.com/geffrerson7/iv100-bot/blob/main/bot/handlers.py): `bot/handlers.py`
- [Logging setup](https://github.com/geffrerson7/iv100-bot/blob/main/common/log.py): `common/log.py`

### Pokemon data

- [Coordinate processing](https://github.com/geffrerson7/iv100-bot/blob/main/bot/service.py): `bot/service.py`
- [Pokemon name data](https://github.com/geffrerson7/iv100-bot/blob/main/data/pokemon_data.json): `data/pokemon_data.json`
- [Move metadata](https://github.com/geffrerson7/iv100-bot/blob/main/data/moves.json): `data/moves.json`

### Other components

- **Telegram user**
- **Telegram platform**
- **Pokemon map services**
- **Configured Telegram group**

## Connections

- Telegram user → Telegram platform: sends commands (evidence: `README.md`)
- Startup and routing → Runtime settings: reads settings (evidence: `main.py`)
- Startup and routing → FastAPI application: runs app (evidence: `main.py`)
- Startup and routing → Telegram application: registers commands (evidence: `main.py`)
- Startup and routing → IV and stop commands: registers handlers (evidence: `main.py`)
- FastAPI application → Runtime settings: selects mode (evidence: `api.py`)
- FastAPI application → Webhook endpoint: mounts router (evidence: `api.py`)
- FastAPI application → Telegram application: uses lifespan (evidence: `api.py`)
- Webhook endpoint → Telegram application: dispatches updates (evidence: `bot/endpoints.py`)
- Telegram platform → Webhook endpoint: posts updates (evidence: `bot/endpoints.py`)
- Telegram application → Runtime settings: reads token (evidence: `bot/ptb.py`)
- Telegram application → Telegram platform: configures webhook (evidence: `bot/ptb.py`)
- Telegram platform → Telegram application: delivers updates
- IV and stop commands → Scheduled IV callbacks: schedules callbacks (evidence: `bot/commands.py`)
- Scheduled IV callbacks → Coordinate processing: generates messages (evidence: `bot/commands.py`)
- Coordinate processing → Pokemon map services: fetches coordinates (evidence: `bot/service.py`)
- Coordinate processing → Pokemon name data: reads names (evidence: `bot/service.py`)
- Coordinate processing → Move metadata: reads moves (evidence: `bot/service.py`)
- IV and stop commands → Configured Telegram group: sends results (evidence: `bot/commands.py`)
- Telegram user → IV and stop commands: invokes commands (evidence: `README.md`)
- Telegram application → Update error handling: routes errors (evidence: `main.py`)
- Update error handling → Logging setup: uses logger (evidence: `bot/handlers.py`)
- Update error handling → Configured Telegram group: sends notices (evidence: `bot/handlers.py`)
