# mofeed63/stratz-telegram-bot architecture

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

- Interactive diagram: https://gitdiagram.com/mofeed63/stratz-telegram-bot
- Repository: https://github.com/mofeed63/stratz-telegram-bot

## Overview

This is an asynchronous Telegram bot for retrieving and presenting Dota 2 player statistics. A user selects or supplies a Steam profile; the bot resolves it to an account ID, requests player data from STRATZ, and formats the selected category for Telegram. It also provides saved account slots, inline topic navigation, and a documented alternate parser for Cloudflare-blocked connections. The graph follows the sampled calls; the alternate parser’s use is documented but its wiring is not shown in the excerpts.

Main entry points: [`main.py`](https://github.com/mofeed63/stratz-telegram-bot/blob/main/main.py) (Bot handlers and topics), [`steam_id.py`](https://github.com/mofeed63/stratz-telegram-bot/blob/main/steam_id.py) (Steam ID resolver), [`parser.py`](https://github.com/mofeed63/stratz-telegram-bot/blob/main/parser.py) (STRATZ GraphQL parser), [`formatters.py`](https://github.com/mofeed63/stratz-telegram-bot/blob/main/formatters.py) (Stats formatter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Telegram interaction"]
  node_bot["Bot handlers and topics<br/>[main.py]"]
  node_telegram{{"Telegram Bot API"}}
end

subgraph group_account["Account management"]
  node_steam["Steam ID resolver<br/>[steam_id.py]"]
  node_slots[("Saved account slots<br/>[database.py]")]
  node_steam_community{{"Steam Community"}}
end

subgraph group_statistics["Statistics retrieval"]
  node_stratz["STRATZ GraphQL parser<br/>[parser.py]"]
  node_alternate["Cloudflare alternate parser<br/>[parser_server.py]"]
  node_formatter["Stats formatter<br/>[formatters.py]"]
  node_constants["Hero and rank constants<br/>[constants.py]"]
  node_stratz_api{{"STRATZ GraphQL API"}}
end

node_player(("Telegram user"))

node_player -->|"sends commands"| node_bot
node_bot -->|"replies and edits"| node_telegram
node_bot -->|"reads slots"| node_slots
node_bot -->|"resolves profile"| node_steam
node_steam -->|"fetches profile XML"| node_steam_community
node_bot -->|"requests player data"| node_stratz
node_stratz -->|"posts GraphQL query"| node_stratz_api
node_bot -->|"formats selected topic"| node_formatter
node_formatter -->|"looks up labels"| node_constants
node_bot -.->|"uses if blocked"| node_alternate

click node_bot "https://github.com/mofeed63/stratz-telegram-bot/blob/main/main.py"
click node_steam "https://github.com/mofeed63/stratz-telegram-bot/blob/main/steam_id.py"
click node_slots "https://github.com/mofeed63/stratz-telegram-bot/blob/main/database.py"
click node_stratz "https://github.com/mofeed63/stratz-telegram-bot/blob/main/parser.py"
click node_alternate "https://github.com/mofeed63/stratz-telegram-bot/blob/main/parser_server.py"
click node_formatter "https://github.com/mofeed63/stratz-telegram-bot/blob/main/formatters.py"
click node_constants "https://github.com/mofeed63/stratz-telegram-bot/blob/main/constants.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_bot,node_telegram,node_player toneBlue
class node_steam,node_slots,node_steam_community toneAmber
class node_stratz,node_alternate,node_formatter,node_constants,node_stratz_api toneMint
```

## Components

### Telegram interaction

- [Bot handlers and topics](https://github.com/mofeed63/stratz-telegram-bot/blob/main/main.py): `main.py`
- **Telegram Bot API**

### Account management

- [Steam ID resolver](https://github.com/mofeed63/stratz-telegram-bot/blob/main/steam_id.py): `steam_id.py`
- [Saved account slots](https://github.com/mofeed63/stratz-telegram-bot/blob/main/database.py): `database.py`
- **Steam Community**

### Statistics retrieval

- [STRATZ GraphQL parser](https://github.com/mofeed63/stratz-telegram-bot/blob/main/parser.py): `parser.py`
- [Cloudflare alternate parser](https://github.com/mofeed63/stratz-telegram-bot/blob/main/parser_server.py): `parser_server.py`
- [Stats formatter](https://github.com/mofeed63/stratz-telegram-bot/blob/main/formatters.py): `formatters.py`
- [Hero and rank constants](https://github.com/mofeed63/stratz-telegram-bot/blob/main/constants.py): `constants.py`
- **STRATZ GraphQL API**

### Other components

- **Telegram user**

## Connections

- Telegram user → Bot handlers and topics: sends commands (evidence: `main.py`)
- Bot handlers and topics → Telegram Bot API: replies and edits (evidence: `main.py`)
- Bot handlers and topics → Saved account slots: reads slots (evidence: `main.py`)
- Bot handlers and topics → Steam ID resolver: resolves profile (evidence: `main.py`)
- Steam ID resolver → Steam Community: fetches profile XML (evidence: `steam_id.py`)
- Bot handlers and topics → STRATZ GraphQL parser: requests player data (evidence: `main.py`)
- STRATZ GraphQL parser → STRATZ GraphQL API: posts GraphQL query (evidence: `parser.py`)
- Bot handlers and topics → Stats formatter: formats selected topic (evidence: `main.py`)
- Stats formatter → Hero and rank constants: looks up labels (evidence: `formatters.py`)
- Bot handlers and topics → Cloudflare alternate parser: uses if blocked (evidence: `README.md`)
