# weebzone/telegram-stremio architecture

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

- Interactive diagram: https://gitdiagram.com/weebzone/telegram-stremio
- Repository: https://github.com/weebzone/telegram-stremio

## Overview

Telegram Stremio Media Server turns files in Telegram channels into an indexed library served to Stremio/Nuvio. The main path is channel ingestion, metadata enrichment and indexing, catalog discovery, then authenticated streaming; the web panel and bot also manage configuration and access. The README documents these capabilities, while the source index confirms several module references. Some major branches are represented by their module paths because their implementation excerpts were not supplied; their internal wiring is not inferred.

Main entry points: [`Backend/fastapi/routes/stream_routes.py`](https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/stream_routes.py) (Stream delivery), [`Backend/fastapi/routes/stremio_routes.py`](https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/stremio_routes.py) (Stremio catalogs), [`Backend/pyrofork/plugins/receiver.py`](https://github.com/weebzone/telegram-stremio/blob/master/Backend/pyrofork/plugins/receiver.py) (Message receiver), [`Backend/fastapi/routes/api_routes.py`](https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/api_routes.py) (Web administration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion &amp; Library"]
  node_receiver["Message receiver<br/>[receiver.py]"]
  node_scan["Library scanning<br/>[scan_manager.py]"]
  node_metadata["Metadata resolution"]
  node_split["Multipart media<br/>[split_files.py]"]
  node_database[("Media database<br/>[database.py]")]
end

subgraph group_discovery["Catalog &amp; Discovery"]
  node_stremio_routes["Stremio catalogs<br/>[stremio_routes.py]"]
  node_global_search["Global search<br/>[global_search.py]"]
  node_custom_catalogs["Custom catalogs<br/>[auto_catalog.py]"]
end

subgraph group_delivery["Playback &amp; Access"]
  node_stream_routes["Stream delivery<br/>[stream_routes.py]"]
  node_telegram_bot["Telegram clients<br/>[bot.py]"]
  node_access_tokens["Access tokens<br/>[tokens.py]"]
  node_subtitles["Subtitle handling<br/>[subtitles.py]"]
  node_webdav["WebDAV access<br/>[webdav_routes.py]"]
end

subgraph group_management["Management &amp; Operations"]
  node_web_admin["Web administration<br/>[api_routes.py]"]
  node_settings["Server settings"]
  node_subscriptions["Subscriptions<br/>[subscription.py]"]
  node_analytics["Activity analytics<br/>[analytics.py]"]
  node_announcements["Announcements<br/>[announcer.py]"]
end

subgraph group_integrations["External Services"]
  node_metadata_providers["Metadata providers"]
  node_cloudflare["Cloudflare streaming<br/>[cf_stream.py]"]
end

node_telegram_user(("Telegram contributors"))
node_telegram_channels[("Media channels")]
node_stremio_clients(("Stremio / Nuvio"))

node_telegram_user -->|"forwards media"| node_telegram_channels
node_telegram_channels -->|"provides messages"| node_receiver
node_receiver -->|"indexes media"| node_database
node_receiver -->|"resolves details"| node_metadata
node_receiver -->|"handles parts"| node_split
node_scan -->|"updates index"| node_database
node_scan -->|"resolves details"| node_metadata
node_metadata -->|"queries providers"| node_metadata_providers
node_stremio_clients -->|"requests catalogs"| node_stremio_routes
node_stremio_routes -->|"reads library"| node_database
node_stremio_routes -->|"searches channels"| node_global_search
node_stremio_routes -.->|"serves catalogs"| node_custom_catalogs
node_stremio_routes -->|"offers playback"| node_stream_routes
node_stremio_clients -->|"requests streams"| node_stream_routes
node_stream_routes -->|"verifies access"| node_access_tokens
node_stream_routes -->|"fetches media"| node_telegram_bot
node_stream_routes -->|"streams multipart"| node_split
node_stream_routes -->|"tracks usage"| node_analytics
node_stream_routes -.->|"uses proxy mode"| node_cloudflare
node_stremio_routes -->|"provides subtitles"| node_subtitles
node_webdav -->|"reuses streaming"| node_stream_routes
node_web_admin -->|"updates settings"| node_settings
node_web_admin -->|"manages library"| node_database
node_web_admin -->|"shows activity"| node_analytics
node_settings -->|"configures clients"| node_telegram_bot
node_telegram_user -->|"manages server"| node_web_admin
node_telegram_user -->|"manages access"| node_subscriptions
node_telegram_bot -->|"announces content"| node_announcements

click node_receiver "https://github.com/weebzone/telegram-stremio/blob/master/Backend/pyrofork/plugins/receiver.py"
click node_scan "https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/scan_manager.py"
click node_metadata "https://github.com/weebzone/telegram-stremio/tree/master/Backend/helper/metadata"
click node_split "https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/split_files.py"
click node_database "https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/database.py"
click node_stremio_routes "https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/stremio_routes.py"
click node_global_search "https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/global_search.py"
click node_custom_catalogs "https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/auto_catalog.py"
click node_stream_routes "https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/stream_routes.py"
click node_telegram_bot "https://github.com/weebzone/telegram-stremio/blob/master/Backend/pyrofork/bot.py"
click node_access_tokens "https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/security/tokens.py"
click node_subtitles "https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/subtitles.py"
click node_webdav "https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/webdav_routes.py"
click node_web_admin "https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/api_routes.py"
click node_settings "https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/settings_manager.py"
click node_subscriptions "https://github.com/weebzone/telegram-stremio/blob/master/Backend/pyrofork/plugins/subscription.py"
click node_analytics "https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/analytics.py"
click node_announcements "https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/announcer.py"
click node_metadata_providers "https://github.com/weebzone/telegram-stremio/tree/master/Backend/helper/metadata/providers"
click node_cloudflare "https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/cf_stream.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_receiver,node_scan,node_metadata,node_split,node_database toneBlue
class node_stremio_routes,node_global_search,node_custom_catalogs,node_telegram_channels toneAmber
class node_stream_routes,node_telegram_bot,node_access_tokens,node_subtitles,node_webdav toneMint
class node_web_admin,node_settings,node_subscriptions,node_analytics,node_announcements toneRose
class node_metadata_providers,node_cloudflare,node_telegram_user,node_stremio_clients toneIndigo
```

## Components

### Ingestion & Library

- [Message receiver](https://github.com/weebzone/telegram-stremio/blob/master/Backend/pyrofork/plugins/receiver.py): `Backend/pyrofork/plugins/receiver.py`
- [Library scanning](https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/scan_manager.py): `Backend/helper/scan_manager.py`
- [Metadata resolution](https://github.com/weebzone/telegram-stremio/tree/master/Backend/helper/metadata): `Backend/helper/metadata`
- [Multipart media](https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/split_files.py): `Backend/helper/split_files.py`
- [Media database](https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/database.py): `Backend/helper/database.py`

### Catalog & Discovery

- [Stremio catalogs](https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/stremio_routes.py): `Backend/fastapi/routes/stremio_routes.py`
- [Global search](https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/global_search.py): `Backend/helper/global_search.py`
- [Custom catalogs](https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/auto_catalog.py): `Backend/helper/auto_catalog.py`

### Playback & Access

- [Stream delivery](https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/stream_routes.py): `Backend/fastapi/routes/stream_routes.py`
- [Telegram clients](https://github.com/weebzone/telegram-stremio/blob/master/Backend/pyrofork/bot.py): `Backend/pyrofork/bot.py`
- [Access tokens](https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/security/tokens.py): `Backend/fastapi/security/tokens.py`
- [Subtitle handling](https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/subtitles.py): `Backend/helper/subtitles.py`
- [WebDAV access](https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/webdav_routes.py): `Backend/fastapi/routes/webdav_routes.py`

### Management & Operations

- [Web administration](https://github.com/weebzone/telegram-stremio/blob/master/Backend/fastapi/routes/api_routes.py): `Backend/fastapi/routes/api_routes.py`
- [Server settings](https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/settings_manager.py): `Backend/helper/settings_manager.py`
- [Subscriptions](https://github.com/weebzone/telegram-stremio/blob/master/Backend/pyrofork/plugins/subscription.py): `Backend/pyrofork/plugins/subscription.py`
- [Activity analytics](https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/analytics.py): `Backend/helper/analytics.py`
- [Announcements](https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/announcer.py): `Backend/helper/announcer.py`

### External Services

- [Metadata providers](https://github.com/weebzone/telegram-stremio/tree/master/Backend/helper/metadata/providers): `Backend/helper/metadata/providers`
- [Cloudflare streaming](https://github.com/weebzone/telegram-stremio/blob/master/Backend/helper/cf_stream.py): `Backend/helper/cf_stream.py`

### Other components

- **Telegram contributors**
- **Media channels**
- **Stremio / Nuvio**

## Connections

- Telegram contributors → Media channels: forwards media
- Media channels → Message receiver: provides messages
- Message receiver → Media database: indexes media (evidence: `Backend/pyrofork/plugins/receiver.py`)
- Message receiver → Metadata resolution: resolves details (evidence: `Backend/pyrofork/plugins/receiver.py`)
- Message receiver → Multipart media: handles parts (evidence: `Backend/pyrofork/plugins/receiver.py`)
- Library scanning → Media database: updates index (evidence: `Backend/helper/scan_manager.py`)
- Library scanning → Metadata resolution: resolves details (evidence: `Backend/helper/scan_manager.py`)
- Metadata resolution → Metadata providers: queries providers (evidence: `Backend/helper/metadata/__init__.py`)
- Stremio / Nuvio → Stremio catalogs: requests catalogs
- Stremio catalogs → Media database: reads library (evidence: `Backend/fastapi/routes/stremio_routes.py`)
- Stremio catalogs → Global search: searches channels (evidence: `Backend/fastapi/routes/stremio_routes.py`)
- Stremio catalogs → Custom catalogs: serves catalogs
- Stremio catalogs → Stream delivery: offers playback
- Stremio / Nuvio → Stream delivery: requests streams
- Stream delivery → Access tokens: verifies access (evidence: `Backend/fastapi/routes/stream_routes.py`)
- Stream delivery → Telegram clients: fetches media (evidence: `Backend/fastapi/routes/stream_routes.py`)
- Stream delivery → Multipart media: streams multipart (evidence: `Backend/fastapi/routes/stream_routes.py`)
- Stream delivery → Activity analytics: tracks usage (evidence: `Backend/fastapi/routes/stream_routes.py`)
- Stream delivery → Cloudflare streaming: uses proxy mode
- Stremio catalogs → Subtitle handling: provides subtitles (evidence: `Backend/fastapi/routes/stremio_routes.py`)
- WebDAV access → Stream delivery: reuses streaming (evidence: `Backend/fastapi/routes/webdav_routes.py`)
- Web administration → Server settings: updates settings (evidence: `Backend/fastapi/routes/api_routes.py`)
- Web administration → Media database: manages library (evidence: `Backend/fastapi/routes/api_routes.py`)
- Web administration → Activity analytics: shows activity (evidence: `Backend/fastapi/routes/api_routes.py`)
- Server settings → Telegram clients: configures clients (evidence: `Backend/helper/settings_manager.py`)
- Telegram contributors → Web administration: manages server
- Telegram contributors → Subscriptions: manages access
- Telegram clients → Announcements: announces content (evidence: `Backend/helper/announcer.py`)
