# tgbot-collection/yyetsbot architecture

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

- Interactive diagram: https://gitdiagram.com/tgbot-collection/yyetsbot
- Repository: https://github.com/tgbot-collection/yyetsbot

## Overview

YYeTsBot combines a searchable film-and-TV resource website with a Telegram bot. The main user workflow is search or browse resources, view and share links, then sign in to save favorites or comment and report invalid links. The web server routes requests to feature handlers backed by MongoDB and Redis; search indexing and resource synchronization support discovery. Separate bot and resource-collection tools extend access and maintain catalog data. Relationships for sampled web routing and shared handler behavior are shown; unsampled integrations are omitted where their wiring is uncertain.

Main entry points: [`yyetsweb/server.py`](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/server.py) (HTTP server), [`yyetsweb/handlers/base.py`](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/base.py) (Handler base), [`yyetsweb/databases/base.py`](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/base.py) (MongoDB), [`yyetsweb/handlers/comment.py`](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/comment.py) (Comments and reports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_server["HTTP server<br/>[server.py]"]
  node_basehandler["Handler base<br/>[base.py]"]
  node_resources["Resource browsing<br/>[resources.py]"]
  node_comments["Comments and reports<br/>[comment.py]"]
  node_users["User accounts<br/>[user.py]"]
  node_oauth["Social sign-in<br/>[oauth.py]"]
  node_otherhandlers["Site features<br/>[other.py]"]
  node_doubanhandler["Douban features<br/>[douban.py]"]
  node_grafanahandler["Metrics API<br/>[grafana.py]"]
end

subgraph group_data["Data and discovery"]
  node_mongo[("MongoDB<br/>[base.py]")]
  node_redis[("Redis and caching<br/>[base.py]")]
  node_resource_data["Resource catalog<br/>[resources.py]"]
  node_comment_data["Comment data<br/>[comment.py]"]
  node_user_data["User data<br/>[user.py]"]
  node_oauth_data["OAuth records<br/>[oauth.py]"]
  node_search["Search indexing<br/>[base.py]"]
end

subgraph group_bot["Telegram bot"]
  node_bot["Telegram bot<br/>[yyetsbot.py]"]
  node_fansub["Resource search<br/>[fansub.py]"]
  node_botconfig["Bot configuration<br/>[config.py]"]
end

subgraph group_ops["Catalog operations"]
  node_sync["Resource synchronization<br/>[sync.py]"]
  node_comment_checks["Comment checks<br/>[comments_check.py]"]
  node_db_dump["Database export<br/>[dump_db.py]"]
  node_share_collector["Share-link collector<br/>[drag.py]"]
end

node_visitor(("Website user"))
node_telegram(("Telegram user"))
node_search_user(("Search user-submitted resources"))
node_oauth_provider(("OAuth providers"))

node_visitor -->|"uses website"| node_server
node_server -->|"routes requests"| node_resources
node_server -->|"routes requests"| node_comments
node_server -->|"routes requests"| node_users
node_server -->|"routes requests"| node_oauth
node_server -->|"routes requests"| node_otherhandlers
node_server -->|"routes requests"| node_doubanhandler
node_server -->|"routes requests"| node_grafanahandler
node_resources -->|"inherits"| node_basehandler
node_comments -->|"inherits"| node_basehandler
node_users -->|"inherits"| node_basehandler
node_oauth -->|"inherits"| node_basehandler
node_comments -.->|"checks spam"| node_comment_checks
node_oauth -->|"authenticates with"| node_oauth_provider
node_search_user -->|"searches via"| node_bot
node_telegram -->|"uses bot"| node_bot
node_bot -->|"delegates search"| node_fansub
node_fansub -->|"reads settings"| node_botconfig
node_basehandler -->|"creates data access"| node_mongo
node_basehandler -->|"uses cache"| node_redis
node_resources -.->|"loads resources"| node_resource_data
node_comments -.->|"handles comments"| node_comment_data
node_users -.->|"handles accounts"| node_user_data
node_oauth_data -->|"stores identities"| node_mongo
node_sync -->|"writes catalog"| node_mongo
node_search -->|"indexes catalog data"| node_mongo
node_server -->|"starts indexing"| node_search
node_server -->|"starts synchronization"| node_sync
node_server -->|"routes export"| node_db_dump
node_share_collector -.->|"stores collected data"| node_mongo

click node_server "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/server.py"
click node_basehandler "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/base.py"
click node_resources "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/resources.py"
click node_comments "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/comment.py"
click node_users "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/user.py"
click node_oauth "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/oauth.py"
click node_otherhandlers "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/other.py"
click node_doubanhandler "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/douban.py"
click node_grafanahandler "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/grafana.py"
click node_mongo "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/base.py"
click node_redis "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/base.py"
click node_resource_data "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/resources.py"
click node_comment_data "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/comment.py"
click node_user_data "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/user.py"
click node_oauth_data "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/oauth.py"
click node_search "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/base.py"
click node_sync "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/common/sync.py"
click node_comment_checks "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/common/comments_check.py"
click node_db_dump "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/common/dump_db.py"
click node_bot "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsbot/yyetsbot.py"
click node_fansub "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsbot/fansub.py"
click node_botconfig "https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsbot/config.py"
click node_share_collector "https://github.com/tgbot-collection/yyetsbot/blob/master/yyets/BagAndDrag/drag.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_server,node_basehandler,node_resources,node_comments,node_users,node_oauth,node_otherhandlers,node_doubanhandler,node_grafanahandler,node_visitor,node_telegram,node_search_user toneBlue
class node_mongo,node_redis,node_resource_data,node_comment_data,node_user_data,node_oauth_data,node_search toneAmber
class node_bot,node_fansub,node_botconfig toneMint
class node_sync,node_comment_checks,node_db_dump,node_share_collector toneRose
class node_oauth_provider toneIndigo
```

## Components

### Web application

- [HTTP server](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/server.py): `yyetsweb/server.py`
- [Handler base](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/base.py): `yyetsweb/handlers/base.py`
- [Resource browsing](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/resources.py): `yyetsweb/handlers/resources.py`
- [Comments and reports](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/comment.py): `yyetsweb/handlers/comment.py`
- [User accounts](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/user.py): `yyetsweb/handlers/user.py`
- [Social sign-in](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/oauth.py): `yyetsweb/handlers/oauth.py`
- [Site features](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/other.py): `yyetsweb/handlers/other.py`
- [Douban features](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/douban.py): `yyetsweb/handlers/douban.py`
- [Metrics API](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/handlers/grafana.py): `yyetsweb/handlers/grafana.py`

### Data and discovery

- [MongoDB](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/base.py): `yyetsweb/databases/base.py`
- [Redis and caching](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/base.py): `yyetsweb/databases/base.py`
- [Resource catalog](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/resources.py): `yyetsweb/databases/resources.py`
- [Comment data](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/comment.py): `yyetsweb/databases/comment.py`
- [User data](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/user.py): `yyetsweb/databases/user.py`
- [OAuth records](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/oauth.py): `yyetsweb/databases/oauth.py`
- [Search indexing](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/databases/base.py): `yyetsweb/databases/base.py`

### Telegram bot

- [Telegram bot](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsbot/yyetsbot.py): `yyetsbot/yyetsbot.py`
- [Resource search](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsbot/fansub.py): `yyetsbot/fansub.py`
- [Bot configuration](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsbot/config.py): `yyetsbot/config.py`

### Catalog operations

- [Resource synchronization](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/common/sync.py): `yyetsweb/common/sync.py`
- [Comment checks](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/common/comments_check.py): `yyetsweb/common/comments_check.py`
- [Database export](https://github.com/tgbot-collection/yyetsbot/blob/master/yyetsweb/common/dump_db.py): `yyetsweb/common/dump_db.py`
- [Share-link collector](https://github.com/tgbot-collection/yyetsbot/blob/master/yyets/BagAndDrag/drag.py): `yyets/BagAndDrag/drag.py`

### Other components

- **Website user**
- **Telegram user**
- **Search user-submitted resources**
- **OAuth providers**

## Connections

- Website user → HTTP server: uses website
- HTTP server → Resource browsing: routes requests (evidence: `yyetsweb/server.py`)
- HTTP server → Comments and reports: routes requests (evidence: `yyetsweb/server.py`)
- HTTP server → User accounts: routes requests (evidence: `yyetsweb/server.py`)
- HTTP server → Social sign-in: routes requests (evidence: `yyetsweb/server.py`)
- HTTP server → Site features: routes requests (evidence: `yyetsweb/server.py`)
- HTTP server → Douban features: routes requests (evidence: `yyetsweb/server.py`)
- HTTP server → Metrics API: routes requests (evidence: `yyetsweb/server.py`)
- Resource browsing → Handler base: inherits (evidence: `yyetsweb/handlers/base.py`)
- Comments and reports → Handler base: inherits (evidence: `yyetsweb/handlers/base.py`)
- User accounts → Handler base: inherits (evidence: `yyetsweb/handlers/base.py`)
- Social sign-in → Handler base: inherits (evidence: `yyetsweb/handlers/base.py`)
- Comments and reports → Comment checks: checks spam
- Social sign-in → OAuth providers: authenticates with (evidence: `yyetsweb/handlers/oauth.py`)
- Search user-submitted resources → Telegram bot: searches via
- Telegram user → Telegram bot: uses bot
- Telegram bot → Resource search: delegates search (evidence: `yyetsbot/yyetsbot.py`)
- Resource search → Bot configuration: reads settings (evidence: `yyetsbot/fansub.py`)
- Handler base → MongoDB: creates data access (evidence: `yyetsweb/handlers/base.py`)
- Handler base → Redis and caching: uses cache (evidence: `yyetsweb/handlers/base.py`)
- Resource browsing → Resource catalog: loads resources
- Comments and reports → Comment data: handles comments
- User accounts → User data: handles accounts
- OAuth records → MongoDB: stores identities (evidence: `yyetsweb/databases/oauth.py`)
- Resource synchronization → MongoDB: writes catalog (evidence: `yyetsweb/common/sync.py`)
- Search indexing → MongoDB: indexes catalog data (evidence: `yyetsweb/databases/base.py`)
- HTTP server → Search indexing: starts indexing (evidence: `yyetsweb/server.py`)
- HTTP server → Resource synchronization: starts synchronization (evidence: `yyetsweb/server.py`)
- HTTP server → Database export: routes export (evidence: `yyetsweb/server.py`)
- Share-link collector → MongoDB: stores collected data
