# bedolaga-dev/remnawave-bedolaga-telegram-bot architecture

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

- Interactive diagram: https://gitdiagram.com/bedolaga-dev/remnawave-bedolaga-telegram-bot
- Repository: https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot

## Overview

Bedolaga Bot is a Telegram platform for selling and operating Remnawave VPN subscriptions, with a companion web-cabinet API. The main journey is user entry and registration, tariff selection and pricing, payment or balance use, then subscription provisioning and renewal. Supporting product branches include administration, marketing, gifts, support, and monitoring. The README documents the capabilities and integrations; sampled source/index evidence shows the bot and web API entry points, payment aggregation, pricing, and persistence, but not every runtime connection.

Main entry points: [`app/bot.py`](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/bot.py) (Telegram bot), [`app/webapi/app.py`](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/webapi/app.py) (Cabinet API), [`app/handlers/subscription`](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/tree/main/app/handlers/subscription) (Subscription purchase), [`app/handlers/admin/main.py`](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/handlers/admin/main.py) (Bot administration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry"]
  node_telegram_bot["Telegram bot<br/>[bot.py]"]
  node_cabinet_api["Cabinet API<br/>[app.py]"]
  node_identity["Registration and auth"]
end

subgraph group_commerce["Subscription commerce"]
  node_subscription_flow["Subscription purchase"]
  node_pricing["Pricing engine<br/>[pricing_engine.py]"]
  node_balance["Balance and top-up<br/>[main.py]"]
  node_payments["Payment orchestration<br/>[payment_service.py]"]
  node_payment_verification["Payment verification"]
  node_gifts["Gift subscriptions"]
end

subgraph group_operations["VPN operations"]
  node_remnawave["Remnawave integration"]
  node_admin["Bot administration<br/>[main.py]"]
end

subgraph group_engagement["Growth and support"]
  node_campaigns["Marketing and referrals"]
  node_support["Support tickets<br/>[tickets.py]"]
  node_email["Email delivery<br/>[email_service.py]"]
end

subgraph group_platform["Runtime platform"]
  node_database[("Application database<br/>[database.py]")]
  node_models["Domain data models<br/>[models.py]"]
  node_runtime["Startup and background jobs<br/>[main.py]"]
end

node_telegram_user(("Telegram user"))
node_cabinet_user(("Cabinet user"))
node_operator(("Operator"))
node_payment_providers{{"Payment providers"}}
node_panel{{"Remnawave panel"}}

node_telegram_user -->|"uses"| node_telegram_bot
node_cabinet_user -->|"uses"| node_cabinet_api
node_operator -->|"manages"| node_admin
node_telegram_bot -->|"registers"| node_identity
node_cabinet_api -->|"authenticates"| node_identity
node_telegram_bot -->|"offers purchase"| node_subscription_flow
node_cabinet_api -->|"offers purchase"| node_subscription_flow
node_subscription_flow -->|"calculates price"| node_pricing
node_subscription_flow -->|"charges balance"| node_balance
node_balance -->|"creates payment"| node_payments
node_payments -->|"dispatches"| node_payment_providers
node_payment_providers -->|"reports status"| node_payment_verification
node_payment_verification -->|"verifies payment"| node_payments
node_subscription_flow -->|"provisions access"| node_remnawave
node_remnawave -->|"synchronizes"| node_panel
node_telegram_bot -->|"purchases gifts"| node_gifts
node_cabinet_api -->|"activates gifts"| node_gifts
node_operator -->|"configures"| node_campaigns
node_telegram_bot -->|"engages users"| node_campaigns
node_telegram_user -->|"opens ticket"| node_support
node_admin -->|"moderates"| node_support
node_email -->|"sends notifications"| node_cabinet_user
node_admin -->|"monitors panel"| node_remnawave
node_runtime -->|"starts"| node_telegram_bot
node_runtime -->|"starts"| node_cabinet_api
node_telegram_bot -.->|"reads and writes"| node_database
node_cabinet_api -.->|"reads and writes"| node_database
node_database -->|"persists"| node_models

click node_telegram_bot "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/bot.py"
click node_cabinet_api "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/webapi/app.py"
click node_identity "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/tree/main/app/cabinet/auth"
click node_subscription_flow "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/tree/main/app/handlers/subscription"
click node_pricing "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/pricing_engine.py"
click node_balance "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/handlers/balance/main.py"
click node_payments "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/payment_service.py"
click node_payment_verification "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/payment_verification_service.py"
click node_gifts "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/gift_purchase_service.py"
click node_remnawave "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/remnawave_service.py"
click node_admin "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/handlers/admin/main.py"
click node_campaigns "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/campaign_service.py"
click node_support "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/handlers/tickets.py"
click node_email "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/cabinet/services/email_service.py"
click node_database "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/database/database.py"
click node_models "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/database/models.py"
click node_runtime "https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/main.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_telegram_bot,node_cabinet_api,node_identity,node_telegram_user,node_cabinet_user toneBlue
class node_subscription_flow,node_pricing,node_balance,node_payments,node_payment_verification,node_gifts toneAmber
class node_remnawave,node_admin toneMint
class node_campaigns,node_support,node_email toneRose
class node_database,node_models,node_runtime,node_operator,node_payment_providers,node_panel toneIndigo
```

## Components

### User entry

- [Telegram bot](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/bot.py): `app/bot.py`
- [Cabinet API](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/webapi/app.py): `app/webapi/app.py`
- [Registration and auth](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/tree/main/app/cabinet/auth): `app/cabinet/auth`

### Subscription commerce

- [Subscription purchase](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/tree/main/app/handlers/subscription): `app/handlers/subscription`
- [Pricing engine](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/pricing_engine.py): `app/services/pricing_engine.py`
- [Balance and top-up](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/handlers/balance/main.py): `app/handlers/balance/main.py`
- [Payment orchestration](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/payment_service.py): `app/services/payment_service.py`
- [Payment verification](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/payment_verification_service.py): `app/services/payment_verification_service.py`
- [Gift subscriptions](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/gift_purchase_service.py): `app/services/gift_purchase_service.py`

### VPN operations

- [Remnawave integration](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/remnawave_service.py): `app/services/remnawave_service.py`
- [Bot administration](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/handlers/admin/main.py): `app/handlers/admin/main.py`

### Growth and support

- [Marketing and referrals](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/services/campaign_service.py): `app/services/campaign_service.py`
- [Support tickets](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/handlers/tickets.py): `app/handlers/tickets.py`
- [Email delivery](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/cabinet/services/email_service.py): `app/cabinet/services/email_service.py`

### Runtime platform

- [Application database](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/database/database.py): `app/database/database.py`
- [Domain data models](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/app/database/models.py): `app/database/models.py`
- [Startup and background jobs](https://github.com/bedolaga-dev/remnawave-bedolaga-telegram-bot/blob/main/main.py): `main.py`

### Other components

- **Telegram user**
- **Cabinet user**
- **Operator**
- **Payment providers**
- **Remnawave panel**

## Connections

- Telegram user → Telegram bot: uses
- Cabinet user → Cabinet API: uses
- Operator → Bot administration: manages
- Telegram bot → Registration and auth: registers
- Cabinet API → Registration and auth: authenticates
- Telegram bot → Subscription purchase: offers purchase (evidence: `app/bot.py`)
- Cabinet API → Subscription purchase: offers purchase
- Subscription purchase → Pricing engine: calculates price (evidence: `app/services/pricing_engine.py`)
- Subscription purchase → Balance and top-up: charges balance (evidence: `app/handlers/balance/main.py`)
- Balance and top-up → Payment orchestration: creates payment (evidence: `app/services/payment_service.py`)
- Payment orchestration → Payment providers: dispatches
- Payment providers → Payment verification: reports status
- Payment verification → Payment orchestration: verifies payment (evidence: `app/services/payment_verification_service.py`)
- Subscription purchase → Remnawave integration: provisions access
- Remnawave integration → Remnawave panel: synchronizes
- Telegram bot → Gift subscriptions: purchases gifts
- Cabinet API → Gift subscriptions: activates gifts
- Operator → Marketing and referrals: configures
- Telegram bot → Marketing and referrals: engages users
- Telegram user → Support tickets: opens ticket
- Bot administration → Support tickets: moderates
- Email delivery → Cabinet user: sends notifications (evidence: `app/cabinet/services/email_service.py`)
- Bot administration → Remnawave integration: monitors panel (evidence: `app/handlers/admin/main.py`)
- Startup and background jobs → Telegram bot: starts (evidence: `main.py`)
- Startup and background jobs → Cabinet API: starts
- Telegram bot → Application database: reads and writes
- Cabinet API → Application database: reads and writes
- Application database → Domain data models: persists (evidence: `app/database/database.py`)
