# hackerheroop/batra architecture

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

- Interactive diagram: https://gitdiagram.com/hackerheroop/batra
- Repository: https://github.com/hackerheroop/batra

## Overview

This is a Telegram auto-posting bot: users request channel subscriptions and admins review payment details; indexed source-channel media is then scheduled for posting to subscribed channels, with settings and expiry managed alongside it. The graph separates bot entry/routing, subscription administration, media indexing, scheduled delivery, and persistence/health support. Source excerpts show the core calls; payment and admin workflows are only partially excerpted, so omitted internal links are not inferred.

Main entry points: [`bot.py`](https://github.com/hackerheroop/batra/blob/main/bot.py) (Bot Runtime), [`scheduler_tasks.py`](https://github.com/hackerheroop/batra/blob/main/scheduler_tasks.py) (Scheduled Jobs), [`plugins/payment.py`](https://github.com/hackerheroop/batra/blob/main/plugins/payment.py) (Payment Requests), [`plugins/indexing.py`](https://github.com/hackerheroop/batra/blob/main/plugins/indexing.py) (Media Indexing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Bot and User Entry"]
  node_bot_runtime["Bot Runtime<br/>[bot.py]"]
  node_welcome["Welcome Commands<br/>[start.py]"]
  node_user_subscriptions["Subscription Listing<br/>[user_commands.py]"]
end

subgraph group_subscription["Subscriptions and Admin"]
  node_payment_flow["Payment Requests<br/>[payment.py]"]
  node_admin_controls["Admin Settings<br/>[admin_settings.py]"]
end

subgraph group_media["Media Indexing"]
  node_media_index["Media Indexing<br/>[indexing.py]"]
end

subgraph group_delivery["Scheduled Delivery"]
  node_scheduler["Scheduled Jobs<br/>[scheduler_tasks.py]"]
end

subgraph group_platform["Persistence and Health"]
  node_subscription_store[("Subscription Records<br/>[database.py]")]
  node_video_store[("Indexed Media<br/>[database.py]")]
  node_settings_store[("Settings and Admins<br/>[database.py]")]
  node_health_server["Health Endpoint<br/>[web_server.py]"]
  node_configuration["Runtime Configuration<br/>[config.py]"]
end

node_telegram_user(("Telegram User"))
node_channel(("Telegram Channels"))

node_telegram_user -->|"sends commands"| node_bot_runtime
node_bot_runtime -->|"registers handlers"| node_welcome
node_bot_runtime -->|"registers handlers"| node_payment_flow
node_bot_runtime -->|"registers handlers"| node_media_index
node_bot_runtime -->|"registers handlers"| node_admin_controls
node_bot_runtime -->|"registers handlers"| node_user_subscriptions
node_welcome -->|"offers purchase"| node_telegram_user
node_user_subscriptions -->|"reads subscriptions"| node_subscription_store
node_user_subscriptions -->|"shows subscriptions"| node_telegram_user
node_payment_flow -->|"manages requests"| node_subscription_store
node_payment_flow -->|"requests payment details"| node_telegram_user
node_payment_flow -->|"logs requests"| node_channel
node_admin_controls -->|"reads and updates"| node_settings_store
node_admin_controls -->|"logs changes"| node_channel
node_media_index -->|"reads settings"| node_settings_store
node_media_index -->|"stores media"| node_video_store
node_media_index -->|"scans source history"| node_channel
node_bot_runtime -->|"schedules jobs"| node_scheduler
node_scheduler -->|"reads active subscriptions"| node_subscription_store
node_scheduler -->|"selects and records media"| node_video_store
node_scheduler -->|"reads job settings"| node_settings_store
node_scheduler -->|"posts media"| node_channel
node_bot_runtime -->|"starts server"| node_health_server
node_bot_runtime -->|"loads credentials"| node_configuration
node_subscription_store -->|"gets database settings"| node_configuration

click node_bot_runtime "https://github.com/hackerheroop/batra/blob/main/bot.py"
click node_welcome "https://github.com/hackerheroop/batra/blob/main/plugins/start.py"
click node_user_subscriptions "https://github.com/hackerheroop/batra/blob/main/plugins/user_commands.py"
click node_payment_flow "https://github.com/hackerheroop/batra/blob/main/plugins/payment.py"
click node_admin_controls "https://github.com/hackerheroop/batra/blob/main/plugins/admin_settings.py"
click node_subscription_store "https://github.com/hackerheroop/batra/blob/main/database.py"
click node_media_index "https://github.com/hackerheroop/batra/blob/main/plugins/indexing.py"
click node_video_store "https://github.com/hackerheroop/batra/blob/main/database.py"
click node_settings_store "https://github.com/hackerheroop/batra/blob/main/database.py"
click node_scheduler "https://github.com/hackerheroop/batra/blob/main/scheduler_tasks.py"
click node_health_server "https://github.com/hackerheroop/batra/blob/main/web_server.py"
click node_configuration "https://github.com/hackerheroop/batra/blob/main/config.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_runtime,node_welcome,node_user_subscriptions,node_telegram_user toneBlue
class node_payment_flow,node_admin_controls toneAmber
class node_media_index toneMint
class node_scheduler toneRose
class node_subscription_store,node_video_store,node_settings_store,node_health_server,node_configuration,node_channel toneIndigo
```

## Components

### Bot and User Entry

- [Bot Runtime](https://github.com/hackerheroop/batra/blob/main/bot.py): `bot.py`
- [Welcome Commands](https://github.com/hackerheroop/batra/blob/main/plugins/start.py): `plugins/start.py`
- [Subscription Listing](https://github.com/hackerheroop/batra/blob/main/plugins/user_commands.py): `plugins/user_commands.py`

### Subscriptions and Admin

- [Payment Requests](https://github.com/hackerheroop/batra/blob/main/plugins/payment.py): `plugins/payment.py`
- [Admin Settings](https://github.com/hackerheroop/batra/blob/main/plugins/admin_settings.py): `plugins/admin_settings.py`

### Media Indexing

- [Media Indexing](https://github.com/hackerheroop/batra/blob/main/plugins/indexing.py): `plugins/indexing.py`

### Scheduled Delivery

- [Scheduled Jobs](https://github.com/hackerheroop/batra/blob/main/scheduler_tasks.py): `scheduler_tasks.py`

### Persistence and Health

- [Subscription Records](https://github.com/hackerheroop/batra/blob/main/database.py): `database.py`
- [Indexed Media](https://github.com/hackerheroop/batra/blob/main/database.py): `database.py`
- [Settings and Admins](https://github.com/hackerheroop/batra/blob/main/database.py): `database.py`
- [Health Endpoint](https://github.com/hackerheroop/batra/blob/main/web_server.py): `web_server.py`
- [Runtime Configuration](https://github.com/hackerheroop/batra/blob/main/config.py): `config.py`

### Other components

- **Telegram User**
- **Telegram Channels**

## Connections

- Telegram User → Bot Runtime: sends commands (evidence: `bot.py`)
- Bot Runtime → Welcome Commands: registers handlers (evidence: `bot.py`)
- Bot Runtime → Payment Requests: registers handlers (evidence: `bot.py`)
- Bot Runtime → Media Indexing: registers handlers (evidence: `bot.py`)
- Bot Runtime → Admin Settings: registers handlers (evidence: `bot.py`)
- Bot Runtime → Subscription Listing: registers handlers (evidence: `bot.py`)
- Welcome Commands → Telegram User: offers purchase (evidence: `plugins/start.py`)
- Subscription Listing → Subscription Records: reads subscriptions (evidence: `plugins/user_commands.py`)
- Subscription Listing → Telegram User: shows subscriptions (evidence: `plugins/user_commands.py`)
- Payment Requests → Subscription Records: manages requests (evidence: `plugins/payment.py`)
- Payment Requests → Telegram User: requests payment details (evidence: `plugins/payment.py`)
- Payment Requests → Telegram Channels: logs requests (evidence: `plugins/payment.py`)
- Admin Settings → Settings and Admins: reads and updates (evidence: `plugins/admin_settings.py`)
- Admin Settings → Telegram Channels: logs changes (evidence: `plugins/admin_settings.py`)
- Media Indexing → Settings and Admins: reads settings (evidence: `plugins/indexing.py`)
- Media Indexing → Indexed Media: stores media (evidence: `plugins/indexing.py`)
- Media Indexing → Telegram Channels: scans source history (evidence: `plugins/indexing.py`)
- Bot Runtime → Scheduled Jobs: schedules jobs (evidence: `bot.py`)
- Scheduled Jobs → Subscription Records: reads active subscriptions (evidence: `scheduler_tasks.py`)
- Scheduled Jobs → Indexed Media: selects and records media (evidence: `scheduler_tasks.py`)
- Scheduled Jobs → Settings and Admins: reads job settings (evidence: `scheduler_tasks.py`)
- Scheduled Jobs → Telegram Channels: posts media (evidence: `scheduler_tasks.py`)
- Bot Runtime → Health Endpoint: starts server (evidence: `bot.py`)
- Bot Runtime → Runtime Configuration: loads credentials (evidence: `bot.py`)
- Subscription Records → Runtime Configuration: gets database settings (evidence: `database.py`)
