# mryog07/broadcast-bot architecture

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

- Interactive diagram: https://gitdiagram.com/mryog07/broadcast-bot
- Repository: https://github.com/mryog07/broadcast-bot

## Overview

MTC Unified Bot is a Telegram bot for managing Marathi and Hindi channel broadcasts. An administrator adds channels, broadcasts a replied-to message to the selected channel set, and can later delete the recorded copies; stats report registered channel counts. Pyrogram handles private commands, Motor persists channel registrations and broadcast message IDs in MongoDB, and Flask exposes a keep-alive endpoint. All behavior is implemented in bot.py; the graph reflects only relationships visible in that excerpt.

Main entry points: [`bot.py`](https://github.com/mryog07/broadcast-bot/blob/main/bot.py) (Command handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telegram["Telegram Bot"]
  node_command_handlers["Command handlers<br/>[bot.py]"]
  node_channel_copy["Channel broadcasts<br/>[bot.py]"]
  node_pyrogram_client["Pyrogram client<br/>[bot.py]"]
end

subgraph group_storage["MongoDB State"]
  node_channel_registry[("Channel registries<br/>[bot.py]")]
  node_broadcast_records[("Broadcast records<br/>[bot.py]")]
end

subgraph group_availability["Keep Alive"]
  node_keep_alive["Health endpoint<br/>[bot.py]"]
  node_flask_server["Flask server<br/>[bot.py]"]
end

node_admin(("Bot users and admin"))
node_telegram_channels["Telegram channels"]
node_http_monitor(("Keep-alive monitor"))

node_admin -->|"sends commands"| node_command_handlers
node_command_handlers -->|"registers channels"| node_channel_registry
node_command_handlers -->|"counts channels"| node_channel_registry
node_command_handlers -->|"requests broadcast"| node_channel_copy
node_channel_copy -->|"reads recipients"| node_channel_registry
node_channel_copy -->|"copies message"| node_telegram_channels
node_command_handlers -->|"reads delete IDs"| node_broadcast_records
node_command_handlers -->|"removes record"| node_broadcast_records
node_channel_copy -->|"stores sent IDs"| node_broadcast_records
node_command_handlers -->|"deletes messages"| node_pyrogram_client
node_http_monitor -->|"requests health"| node_keep_alive
node_flask_server -->|"serves route"| node_keep_alive
node_pyrogram_client -->|"dispatches commands"| node_command_handlers

click node_command_handlers "https://github.com/mryog07/broadcast-bot/blob/main/bot.py"
click node_channel_copy "https://github.com/mryog07/broadcast-bot/blob/main/bot.py"
click node_channel_registry "https://github.com/mryog07/broadcast-bot/blob/main/bot.py"
click node_broadcast_records "https://github.com/mryog07/broadcast-bot/blob/main/bot.py"
click node_keep_alive "https://github.com/mryog07/broadcast-bot/blob/main/bot.py"
click node_flask_server "https://github.com/mryog07/broadcast-bot/blob/main/bot.py"
click node_pyrogram_client "https://github.com/mryog07/broadcast-bot/blob/main/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_command_handlers,node_channel_copy,node_pyrogram_client,node_admin toneBlue
class node_channel_registry,node_broadcast_records toneAmber
class node_keep_alive,node_flask_server toneMint
class node_telegram_channels,node_http_monitor toneIndigo
```

## Components

### Telegram Bot

- [Command handlers](https://github.com/mryog07/broadcast-bot/blob/main/bot.py): `bot.py`
- [Channel broadcasts](https://github.com/mryog07/broadcast-bot/blob/main/bot.py): `bot.py`
- [Pyrogram client](https://github.com/mryog07/broadcast-bot/blob/main/bot.py): `bot.py`

### MongoDB State

- [Channel registries](https://github.com/mryog07/broadcast-bot/blob/main/bot.py): `bot.py`
- [Broadcast records](https://github.com/mryog07/broadcast-bot/blob/main/bot.py): `bot.py`

### Keep Alive

- [Health endpoint](https://github.com/mryog07/broadcast-bot/blob/main/bot.py): `bot.py`
- [Flask server](https://github.com/mryog07/broadcast-bot/blob/main/bot.py): `bot.py`

### Other components

- **Bot users and admin**
- **Telegram channels**
- **Keep-alive monitor**

## Connections

- Bot users and admin → Command handlers: sends commands (evidence: `bot.py`)
- Command handlers → Channel registries: registers channels (evidence: `bot.py`)
- Command handlers → Channel registries: counts channels (evidence: `bot.py`)
- Command handlers → Channel broadcasts: requests broadcast (evidence: `bot.py`)
- Channel broadcasts → Channel registries: reads recipients (evidence: `bot.py`)
- Channel broadcasts → Telegram channels: copies message (evidence: `bot.py`)
- Command handlers → Broadcast records: reads delete IDs (evidence: `bot.py`)
- Command handlers → Broadcast records: removes record (evidence: `bot.py`)
- Channel broadcasts → Broadcast records: stores sent IDs (evidence: `bot.py`)
- Command handlers → Pyrogram client: deletes messages (evidence: `bot.py`)
- Keep-alive monitor → Health endpoint: requests health (evidence: `bot.py`)
- Flask server → Health endpoint: serves route (evidence: `bot.py`)
- Pyrogram client → Command handlers: dispatches commands (evidence: `bot.py`)
