# codeflix-bots/manga-bot architecture

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

- Interactive diagram: https://gitdiagram.com/codeflix-bots/manga-bot
- Repository: https://github.com/codeflix-bots/manga-bot

## Overview

Manga Bot is a Pyrogram-based Telegram manga downloader. Users search manga sources, browse chapters, request a chapter, and receive it in selected formats; subscriptions also drive periodic update checks and queued delivery. The bot coordinates source clients, downloads chapter images, creates PDF/CBZ or Telegraph output, and stores user preferences, subscriptions, and reusable file identifiers. The bot excerpt is partial, so some handler-to-service wiring and conversion details are omitted where not directly evidenced.

Main entry points: [`bot.py`](https://github.com/codeflix-bots/manga-bot/blob/master/bot.py) (Delivery workers), [`plugins`](https://github.com/codeflix-bots/manga-bot/tree/master/plugins) (Source clients), [`models/db.py`](https://github.com/codeflix-bots/manga-bot/blob/master/models/db.py) (Application database), [`main.py`](https://github.com/codeflix-bots/manga-bot/blob/master/main.py) (Runtime startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Telegram interaction"]
  node_bot["Bot handlers<br/>[bot.py]"]
  node_main["Runtime startup<br/>[main.py]"]
end

subgraph group_sources["Manga sources"]
  node_client["Manga client base<br/>[client.py]"]
  node_source_plugins["Source clients"]
  node_search["Search ranking<br/>[search_engine.py]"]
end

subgraph group_delivery["Chapter delivery"]
  node_queue["Chapter queue<br/>[aqueue.py]"]
  node_worker["Delivery workers<br/>[bot.py]"]
  node_pdf["PDF and thumbnail<br/>[core.py]"]
  node_cbz["CBZ packaging<br/>[core.py]"]
  node_telegraph["Telegraph pages<br/>[core.py]"]
end

subgraph group_state["Persistence and updates"]
  node_database[("Application database<br/>[db.py]")]
  node_updater["Subscription updater<br/>[bot.py]"]
end

node_user(("Telegram user"))
node_telegram(("Telegram API"))
node_sites(("Manga websites"))
node_telegraph_service(("Telegraph"))

node_user -->|"sends commands"| node_telegram
node_telegram -->|"dispatches updates"| node_bot
node_bot -->|"replies and sends"| node_telegram
node_bot -->|"searches and browses"| node_source_plugins
node_source_plugins -->|"uses base behavior"| node_client
node_source_plugins -->|"requests manga data"| node_sites
node_source_plugins -->|"ranks results"| node_search
node_bot -->|"reads and writes"| node_database
node_bot -->|"enqueues chapters"| node_queue
node_main -->|"connects"| node_database
node_main -->|"starts"| node_updater
node_main -->|"starts workers"| node_worker
node_updater -->|"reads subscriptions"| node_database
node_updater -->|"checks chapter updates"| node_source_plugins
node_updater -->|"enqueues new chapters"| node_queue
node_worker -->|"dequeues chapters"| node_queue
node_worker -->|"downloads chapter images"| node_source_plugins
node_worker -->|"reads files and options"| node_database
node_worker -->|"creates PDF output"| node_pdf
node_worker -->|"creates CBZ output"| node_cbz
node_worker -->|"creates page output"| node_telegraph
node_telegraph -->|"publishes page"| node_telegraph_service
node_worker -->|"sends chapter output"| node_telegram
node_worker -->|"records file identifiers"| node_database

click node_bot "https://github.com/codeflix-bots/manga-bot/blob/master/bot.py"
click node_main "https://github.com/codeflix-bots/manga-bot/blob/master/main.py"
click node_client "https://github.com/codeflix-bots/manga-bot/blob/master/plugins/client.py"
click node_source_plugins "https://github.com/codeflix-bots/manga-bot/tree/master/plugins"
click node_search "https://github.com/codeflix-bots/manga-bot/blob/master/plugins/search_engine.py"
click node_queue "https://github.com/codeflix-bots/manga-bot/blob/master/tools/aqueue.py"
click node_worker "https://github.com/codeflix-bots/manga-bot/blob/master/bot.py"
click node_pdf "https://github.com/codeflix-bots/manga-bot/blob/master/img2pdf/core.py"
click node_cbz "https://github.com/codeflix-bots/manga-bot/blob/master/img2cbz/core.py"
click node_telegraph "https://github.com/codeflix-bots/manga-bot/blob/master/img2tph/core.py"
click node_database "https://github.com/codeflix-bots/manga-bot/blob/master/models/db.py"
click node_updater "https://github.com/codeflix-bots/manga-bot/blob/master/bot.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_main,node_user toneBlue
class node_client,node_source_plugins,node_search toneAmber
class node_queue,node_worker,node_pdf,node_cbz,node_telegraph,node_telegram toneMint
class node_database,node_updater toneRose
class node_sites,node_telegraph_service toneIndigo
```

## Components

### Telegram interaction

- [Bot handlers](https://github.com/codeflix-bots/manga-bot/blob/master/bot.py): `bot.py`
- [Runtime startup](https://github.com/codeflix-bots/manga-bot/blob/master/main.py): `main.py`

### Manga sources

- [Manga client base](https://github.com/codeflix-bots/manga-bot/blob/master/plugins/client.py): `plugins/client.py`
- [Source clients](https://github.com/codeflix-bots/manga-bot/tree/master/plugins): `plugins`
- [Search ranking](https://github.com/codeflix-bots/manga-bot/blob/master/plugins/search_engine.py): `plugins/search_engine.py`

### Chapter delivery

- [Chapter queue](https://github.com/codeflix-bots/manga-bot/blob/master/tools/aqueue.py): `tools/aqueue.py`
- [Delivery workers](https://github.com/codeflix-bots/manga-bot/blob/master/bot.py): `bot.py`
- [PDF and thumbnail](https://github.com/codeflix-bots/manga-bot/blob/master/img2pdf/core.py): `img2pdf/core.py`
- [CBZ packaging](https://github.com/codeflix-bots/manga-bot/blob/master/img2cbz/core.py): `img2cbz/core.py`
- [Telegraph pages](https://github.com/codeflix-bots/manga-bot/blob/master/img2tph/core.py): `img2tph/core.py`

### Persistence and updates

- [Application database](https://github.com/codeflix-bots/manga-bot/blob/master/models/db.py): `models/db.py`
- [Subscription updater](https://github.com/codeflix-bots/manga-bot/blob/master/bot.py): `bot.py`

### Other components

- **Telegram user**
- **Telegram API**
- **Manga websites**
- **Telegraph**

## Connections

- Telegram user → Telegram API: sends commands
- Telegram API → Bot handlers: dispatches updates
- Bot handlers → Telegram API: replies and sends
- Bot handlers → Source clients: searches and browses
- Source clients → Manga client base: uses base behavior
- Source clients → Manga websites: requests manga data
- Source clients → Search ranking: ranks results
- Bot handlers → Application database: reads and writes
- Bot handlers → Chapter queue: enqueues chapters
- Runtime startup → Application database: connects
- Runtime startup → Subscription updater: starts
- Runtime startup → Delivery workers: starts workers
- Subscription updater → Application database: reads subscriptions
- Subscription updater → Source clients: checks chapter updates
- Subscription updater → Chapter queue: enqueues new chapters
- Delivery workers → Chapter queue: dequeues chapters
- Delivery workers → Source clients: downloads chapter images
- Delivery workers → Application database: reads files and options
- Delivery workers → PDF and thumbnail: creates PDF output
- Delivery workers → CBZ packaging: creates CBZ output
- Delivery workers → Telegraph pages: creates page output
- Telegraph pages → Telegraph: publishes page
- Delivery workers → Telegram API: sends chapter output
- Delivery workers → Application database: records file identifiers
