# scriptersaurav/telegram-movie-search-bot architecture

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

- Interactive diagram: https://gitdiagram.com/scriptersaurav/telegram-movie-search-bot
- Repository: https://github.com/scriptersaurav/telegram-movie-search-bot

## Overview

Media Search bot indexes Telegram documents, videos, and audio into MongoDB, then serves paginated inline searches with optional caption, file-type, and access filters. The main workflow runs from channel posts through catalog persistence to inline results; admins can also backfill history and manage the catalog. The graph includes documented capabilities whose implementation is only partly sampled; those unsampled relationships are not inferred.

Main entry points: [`utils/database.py`](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/utils/database.py) (Media catalog), [`info.py`](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/info.py) (Bot settings), [`bot.py`](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/bot.py) (Bot runtime), [`plugins/inline.py`](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/plugins/inline.py) (Inline search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and settings"]
  node_settings["Bot settings<br/>[info.py]"]
  node_bot_runtime["Bot runtime<br/>[bot.py]"]
end

subgraph group_ingest["Indexing"]
  node_channel_ingest["Channel ingestion<br/>[channel.py]"]
  node_admin_index["Admin history indexing<br/>[userbot.py]"]
  node_bulk_index["One-time indexing"]
end

subgraph group_catalog["Catalog and search"]
  node_media_catalog[("Media catalog<br/>[database.py]")]
  node_file_id_helpers["File ID helpers<br/>[helpers.py]"]
end

subgraph group_telegram["Telegram features"]
  node_inline_search["Inline search<br/>[inline.py]"]
  node_bot_commands["Bot commands<br/>[commands.py]"]
end

node_user(("Telegram users"))
node_admin(("Bot admins"))
node_telegram_channels["Telegram channels"]
node_telegram_service["Telegram service"]

node_bot_runtime -->|"reads settings"| node_settings
node_bot_runtime -->|"starts client"| node_telegram_service
node_bot_runtime -->|"ensures indexes"| node_media_catalog
node_bot_runtime -->|"loads plugins"| node_channel_ingest
node_telegram_channels -->|"posts media"| node_channel_ingest
node_channel_ingest -->|"saves media"| node_media_catalog
node_admin -->|"requests indexing"| node_admin_index
node_admin_index -->|"reads history"| node_telegram_service
node_admin_index -->|"saves media"| node_media_catalog
node_bulk_index -->|"reads settings"| node_settings
node_bulk_index -->|"reads history"| node_telegram_service
node_bulk_index -->|"saves media"| node_media_catalog
node_media_catalog -->|"reads database config"| node_settings
node_media_catalog -->|"normalizes file IDs"| node_file_id_helpers
node_user -->|"submits queries"| node_inline_search
node_inline_search -->|"fetches matches"| node_media_catalog
node_inline_search -->|"checks membership"| node_telegram_service
node_inline_search -->|"reads access settings"| node_settings
node_admin -->|"runs commands"| node_bot_commands
node_bot_commands -->|"counts or deletes"| node_media_catalog
node_bot_commands -->|"looks up channels"| node_telegram_service
node_bot_commands -->|"reads command settings"| node_settings

click node_settings "https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/info.py"
click node_bot_runtime "https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/bot.py"
click node_channel_ingest "https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/plugins/channel.py"
click node_admin_index "https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/plugins/userbot.py"
click node_bulk_index "https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/one_time_indexer.py"
click node_media_catalog "https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/utils/database.py"
click node_file_id_helpers "https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/utils/helpers.py"
click node_inline_search "https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/plugins/inline.py"
click node_bot_commands "https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/plugins/commands.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_settings,node_bot_runtime,node_user toneBlue
class node_channel_ingest,node_admin_index,node_bulk_index toneAmber
class node_media_catalog,node_file_id_helpers toneMint
class node_inline_search,node_bot_commands toneRose
class node_admin,node_telegram_channels,node_telegram_service toneIndigo
```

## Components

### Runtime and settings

- [Bot settings](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/info.py): `info.py`
- [Bot runtime](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/bot.py): `bot.py`

### Indexing

- [Channel ingestion](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/plugins/channel.py): `plugins/channel.py`
- [Admin history indexing](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/plugins/userbot.py): `plugins/userbot.py`
- [One-time indexing](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/one_time_indexer.py): `one_time_indexer.py`

### Catalog and search

- [Media catalog](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/utils/database.py): `utils/database.py`
- [File ID helpers](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/utils/helpers.py): `utils/helpers.py`

### Telegram features

- [Inline search](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/plugins/inline.py): `plugins/inline.py`
- [Bot commands](https://github.com/scriptersaurav/telegram-movie-search-bot/blob/master/plugins/commands.py): `plugins/commands.py`

### Other components

- **Telegram users**
- **Bot admins**
- **Telegram channels**
- **Telegram service**

## Connections

- Bot runtime → Bot settings: reads settings (evidence: `bot.py`)
- Bot runtime → Telegram service: starts client (evidence: `bot.py`)
- Bot runtime → Media catalog: ensures indexes (evidence: `bot.py`)
- Bot runtime → Channel ingestion: loads plugins (evidence: `bot.py`)
- Telegram channels → Channel ingestion: posts media (evidence: `plugins/channel.py`)
- Channel ingestion → Media catalog: saves media (evidence: `plugins/channel.py`)
- Bot admins → Admin history indexing: requests indexing (evidence: `plugins/userbot.py`)
- Admin history indexing → Telegram service: reads history (evidence: `plugins/userbot.py`)
- Admin history indexing → Media catalog: saves media (evidence: `plugins/userbot.py`)
- One-time indexing → Bot settings: reads settings (evidence: `one_time_indexer.py`)
- One-time indexing → Telegram service: reads history (evidence: `one_time_indexer.py`)
- One-time indexing → Media catalog: saves media (evidence: `one_time_indexer.py`)
- Media catalog → Bot settings: reads database config (evidence: `utils/database.py`)
- Media catalog → File ID helpers: normalizes file IDs (evidence: `utils/database.py`)
- Telegram users → Inline search: submits queries (evidence: `plugins/inline.py`)
- Inline search → Media catalog: fetches matches (evidence: `plugins/inline.py`)
- Inline search → Telegram service: checks membership (evidence: `plugins/inline.py`)
- Inline search → Bot settings: reads access settings (evidence: `plugins/inline.py`)
- Bot admins → Bot commands: runs commands (evidence: `plugins/commands.py`)
- Bot commands → Media catalog: counts or deletes (evidence: `plugins/commands.py`)
- Bot commands → Telegram service: looks up channels (evidence: `plugins/commands.py`)
- Bot commands → Bot settings: reads command settings (evidence: `plugins/commands.py`)
