# mathewskdaniel/telqbot architecture

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

- Interactive diagram: https://gitdiagram.com/mathewskdaniel/telqbot
- Repository: https://github.com/mathewskdaniel/telqbot

## Overview

TelQbot is a Telegram interface for managing qBittorrent downloads, with optional Stremio library administration and content-folder configuration. The main path is Telegram interaction through authorization and message/callback handlers, into torrent operations and back to Telegram; background tasks also track completions and reload configuration. The graph preserves the documented torrent, folder, Stremio, access-control, and notification capabilities. Some callback and integration implementations were not excerpted, so their links are omitted or marked unverified.

Main entry points: [`src/main.py`](https://github.com/mathewskdaniel/telqbot/blob/main/src/main.py) (Bot startup and routing), [`src/client_manager/client_repo.py`](https://github.com/mathewskdaniel/telqbot/blob/main/src/client_manager/client_repo.py) (Client selection), [`src/tasks.py`](https://github.com/mathewskdaniel/telqbot/blob/main/src/tasks.py) (Completion notifications and watcher), [`src/content_categories.py`](https://github.com/mathewskdaniel/telqbot/blob/main/src/content_categories.py) (Content folder categories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telegram["Telegram interface"]
  node_entry["Bot startup and routing<br/>[main.py]"]
  node_access["Authorization and user context"]
  node_messages["Message intake<br/>[on_message.py]"]
  node_commands["Commands and menu<br/>[common.py]"]
  node_torrent_callbacks["Torrent management callbacks"]
end

subgraph group_domain["Torrent and Stremio features"]
  node_content_add["Torrent intake<br/>[content_add.py]"]
  node_content_folders["Content folder categories"]
  node_stremio_callbacks["Stremio admin actions"]
  node_stremio_admin["Stremio admin client<br/>[stremio_admin.py]"]
end

subgraph group_services["Clients and state"]
  node_client_repo["Client selection<br/>[client_repo.py]"]
  node_qbt_manager["qBittorrent operations"]
  node_redis[("Redis session state<br/>[wrapper.py]")]
end

subgraph group_runtime["Runtime configuration"]
  node_tasks["Completion notifications and watcher<br/>[tasks.py]"]
  node_settings["Settings and user roles<br/>[__init__.py]"]
end

node_user(("Telegram user"))
node_telegram(("Telegram API"))
node_qbt_service(("qBittorrent Web UI"))

node_user -->|"sends commands"| node_telegram
node_telegram -->|"delivers updates"| node_entry
node_entry -->|"registers middleware"| node_access
node_entry -->|"registers router"| node_messages
node_entry -->|"registers router"| node_commands
node_entry -->|"registers routers"| node_torrent_callbacks
node_messages -.->|"handles intake"| node_content_add
node_content_add -->|"selects client"| node_client_repo
node_commands -->|"queries torrents"| node_client_repo
node_torrent_callbacks -->|"manages torrents"| node_client_repo
node_content_add -->|"resolves folder"| node_content_folders
node_entry -->|"syncs categories"| node_content_folders
node_content_folders -->|"syncs categories"| node_client_repo
node_torrent_callbacks -.->|"registers admin actions"| node_stremio_callbacks
node_stremio_callbacks -.->|"requests admin operation"| node_stremio_admin
node_client_repo -->|"selects implementation"| node_qbt_manager
node_qbt_manager -->|"calls Web UI"| node_qbt_service
node_entry -->|"loads settings"| node_settings
node_entry -->|"connects state store"| node_redis
node_entry -->|"starts scheduled work"| node_tasks
node_tasks -->|"checks completion"| node_client_repo
node_tasks -->|"tracks completion"| node_redis
node_tasks -->|"sends notifications"| node_telegram
node_tasks -->|"resyncs after reload"| node_content_folders

click node_entry "https://github.com/mathewskdaniel/telqbot/blob/main/src/main.py"
click node_access "https://github.com/mathewskdaniel/telqbot/tree/main/src/bot/middlewares"
click node_messages "https://github.com/mathewskdaniel/telqbot/blob/main/src/bot/handlers/on_message.py"
click node_commands "https://github.com/mathewskdaniel/telqbot/blob/main/src/bot/handlers/common.py"
click node_torrent_callbacks "https://github.com/mathewskdaniel/telqbot/tree/main/src/bot/handlers/callbacks"
click node_content_add "https://github.com/mathewskdaniel/telqbot/blob/main/src/bot/handlers/content_add.py"
click node_content_folders "https://github.com/mathewskdaniel/telqbot/blob/main/src/content_categories.py"
click node_stremio_callbacks "https://github.com/mathewskdaniel/telqbot/blob/main/src/bot/handlers/callbacks/stremio_callbacks.py"
click node_stremio_admin "https://github.com/mathewskdaniel/telqbot/blob/main/src/stremio_admin.py"
click node_client_repo "https://github.com/mathewskdaniel/telqbot/blob/main/src/client_manager/client_repo.py"
click node_qbt_manager "https://github.com/mathewskdaniel/telqbot/blob/main/src/client_manager/qbittorrent_manager/qbittorrent_manager.py"
click node_redis "https://github.com/mathewskdaniel/telqbot/blob/main/src/redis_helper/wrapper.py"
click node_tasks "https://github.com/mathewskdaniel/telqbot/blob/main/src/tasks.py"
click node_settings "https://github.com/mathewskdaniel/telqbot/blob/main/src/settings/__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_entry,node_access,node_messages,node_commands,node_torrent_callbacks,node_user,node_qbt_service toneBlue
class node_content_add,node_content_folders,node_stremio_callbacks,node_stremio_admin toneAmber
class node_client_repo,node_qbt_manager,node_redis,node_telegram toneMint
class node_tasks,node_settings toneRose
```

## Components

### Telegram interface

- [Bot startup and routing](https://github.com/mathewskdaniel/telqbot/blob/main/src/main.py): `src/main.py`
- [Authorization and user context](https://github.com/mathewskdaniel/telqbot/tree/main/src/bot/middlewares): `src/bot/middlewares`
- [Message intake](https://github.com/mathewskdaniel/telqbot/blob/main/src/bot/handlers/on_message.py): `src/bot/handlers/on_message.py`
- [Commands and menu](https://github.com/mathewskdaniel/telqbot/blob/main/src/bot/handlers/common.py): `src/bot/handlers/common.py`
- [Torrent management callbacks](https://github.com/mathewskdaniel/telqbot/tree/main/src/bot/handlers/callbacks): `src/bot/handlers/callbacks`

### Torrent and Stremio features

- [Torrent intake](https://github.com/mathewskdaniel/telqbot/blob/main/src/bot/handlers/content_add.py): `src/bot/handlers/content_add.py`
- [Content folder categories](https://github.com/mathewskdaniel/telqbot/blob/main/src/content_categories.py): `src/content_categories.py`
- [Stremio admin actions](https://github.com/mathewskdaniel/telqbot/blob/main/src/bot/handlers/callbacks/stremio_callbacks.py): `src/bot/handlers/callbacks/stremio_callbacks.py`
- [Stremio admin client](https://github.com/mathewskdaniel/telqbot/blob/main/src/stremio_admin.py): `src/stremio_admin.py`

### Clients and state

- [Client selection](https://github.com/mathewskdaniel/telqbot/blob/main/src/client_manager/client_repo.py): `src/client_manager/client_repo.py`
- [qBittorrent operations](https://github.com/mathewskdaniel/telqbot/blob/main/src/client_manager/qbittorrent_manager/qbittorrent_manager.py): `src/client_manager/qbittorrent_manager/qbittorrent_manager.py`
- [Redis session state](https://github.com/mathewskdaniel/telqbot/blob/main/src/redis_helper/wrapper.py): `src/redis_helper/wrapper.py`

### Runtime configuration

- [Completion notifications and watcher](https://github.com/mathewskdaniel/telqbot/blob/main/src/tasks.py): `src/tasks.py`
- [Settings and user roles](https://github.com/mathewskdaniel/telqbot/blob/main/src/settings/__init__.py): `src/settings/__init__.py`

### Other components

- **Telegram user**
- **Telegram API**
- **qBittorrent Web UI**

## Connections

- Telegram user → Telegram API: sends commands (evidence: `README.md`)
- Telegram API → Bot startup and routing: delivers updates (evidence: `src/main.py`)
- Bot startup and routing → Authorization and user context: registers middleware (evidence: `src/main.py`)
- Bot startup and routing → Message intake: registers router (evidence: `src/main.py`)
- Bot startup and routing → Commands and menu: registers router (evidence: `src/main.py`)
- Bot startup and routing → Torrent management callbacks: registers routers (evidence: `src/main.py`)
- Message intake → Torrent intake: handles intake
- Torrent intake → Client selection: selects client (evidence: `src/bot/handlers/content_add.py`)
- Commands and menu → Client selection: queries torrents (evidence: `src/bot/handlers/common.py`)
- Torrent management callbacks → Client selection: manages torrents (evidence: `src/bot/handlers/callbacks/pause_resume/pause_callbacks.py`)
- Torrent intake → Content folder categories: resolves folder (evidence: `src/bot/handlers/content_add.py`)
- Bot startup and routing → Content folder categories: syncs categories (evidence: `src/main.py`)
- Content folder categories → Client selection: syncs categories (evidence: `src/content_categories.py`)
- Torrent management callbacks → Stremio admin actions: registers admin actions (evidence: `src/bot/handlers/callbacks/__init__.py`)
- Stremio admin actions → Stremio admin client: requests admin operation
- Client selection → qBittorrent operations: selects implementation (evidence: `src/client_manager/client_repo.py`)
- qBittorrent operations → qBittorrent Web UI: calls Web UI (evidence: `src/client_manager/qbittorrent_manager/qbittorrent_manager.py`)
- Bot startup and routing → Settings and user roles: loads settings (evidence: `src/main.py`)
- Bot startup and routing → Redis session state: connects state store (evidence: `src/main.py`)
- Bot startup and routing → Completion notifications and watcher: starts scheduled work (evidence: `src/main.py`)
- Completion notifications and watcher → Client selection: checks completion (evidence: `src/tasks.py`)
- Completion notifications and watcher → Redis session state: tracks completion (evidence: `src/tasks.py`)
- Completion notifications and watcher → Telegram API: sends notifications (evidence: `src/tasks.py`)
- Completion notifications and watcher → Content folder categories: resyncs after reload (evidence: `src/tasks.py`)
