# temirovuz/telegrambot_template_aiogram architecture

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

- Interactive diagram: https://gitdiagram.com/temirovuz/telegrambot_template_aiogram
- Repository: https://github.com/temirovuz/telegrambot_template_aiogram

## Overview

This repository is an Aiogram Telegram bot template. Its evidenced runtime workflow is Telegram polling through the application entry point and dispatcher, routing /start and /help to handlers that reply to users. The README also documents admin, profile, settings, registration, subscription checks, and a handler→service→database layering pattern. Those broader capabilities are represented, but their wiring is not established by the sampled source; the database lifecycle functions in main.py are placeholders.

Main entry points: [`services`](https://github.com/temirovuz/telegrambot_template_aiogram/tree/main/services) (Business services), [`main.py`](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/main.py) (Application entry), [`handlers/__init__.py`](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/__init__.py) (Handler router), [`handlers/admin/users.py`](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/admin/users.py) (Admin handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_main["Application entry<br/>[main.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_dispatcher["Aiogram dispatcher<br/>[main.py]"]
  node_logger["Logging setup<br/>[logger.py]"]
end

subgraph group_interaction["User interactions"]
  node_handler_router["Handler router<br/>[__init__.py]"]
  node_start["Start handler<br/>[start.py]"]
  node_help["Help handler<br/>[help.py]"]
end

subgraph group_domain["Bot capabilities"]
  node_admin_handlers["Admin handlers<br/>[users.py]"]
  node_profile["Profile handler<br/>[profile.py]"]
  node_settings["Settings handler<br/>[settings.py]"]
  node_registration["Registration states<br/>[register.py]"]
  node_keyboards["Bot keyboards"]
end

subgraph group_data["Data and policy"]
  node_subscription["Subscription filter"]
  node_admin_filter["Admin filter<br/>[is_admin.py]"]
  node_services["Business services"]
  node_crud["Database operations<br/>[crud.py]"]
  node_models["Database models<br/>[models.py]"]
end

node_user(("Telegram user"))
node_telegram(("Telegram API"))

node_user -->|"sends updates"| node_telegram
node_telegram -->|"polls updates"| node_dispatcher
node_main -->|"starts polling"| node_dispatcher
node_main -->|"reads settings"| node_config
node_main -->|"sets up"| node_logger
node_dispatcher -->|"dispatches updates"| node_handler_router
node_handler_router -->|"routes /start"| node_start
node_handler_router -->|"routes /help"| node_help
node_start -->|"sends reply"| node_telegram
node_help -->|"sends reply"| node_telegram
node_admin_handlers -.->|"checks admin"| node_admin_filter
node_admin_handlers -.->|"delegates logic"| node_services
node_profile -.->|"delegates logic"| node_services
node_settings -.->|"delegates logic"| node_services
node_services -.->|"uses operations"| node_crud
node_crud -.->|"uses models"| node_models

click node_main "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/main.py"
click node_config "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/core/config.py"
click node_dispatcher "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/main.py"
click node_handler_router "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/__init__.py"
click node_start "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/common/start.py"
click node_help "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/common/help.py"
click node_admin_handlers "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/admin/users.py"
click node_profile "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/user/profile.py"
click node_settings "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/user/settings.py"
click node_registration "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/states/register.py"
click node_keyboards "https://github.com/temirovuz/telegrambot_template_aiogram/tree/main/keyboards"
click node_subscription "https://github.com/temirovuz/telegrambot_template_aiogram/tree/main/filters"
click node_admin_filter "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/filters/is_admin.py"
click node_services "https://github.com/temirovuz/telegrambot_template_aiogram/tree/main/services"
click node_crud "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/db/crud.py"
click node_models "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/db/models.py"
click node_logger "https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/core/logger.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_main,node_config,node_dispatcher,node_logger,node_user toneBlue
class node_handler_router,node_start,node_help toneAmber
class node_admin_handlers,node_profile,node_settings,node_registration,node_keyboards,node_telegram toneMint
class node_subscription,node_admin_filter,node_services,node_crud,node_models toneRose
```

## Components

### Bot runtime

- [Application entry](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/main.py): `main.py`
- [Configuration](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/core/config.py): `core/config.py`
- [Aiogram dispatcher](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/main.py): `main.py`
- [Logging setup](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/core/logger.py): `core/logger.py`

### User interactions

- [Handler router](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/__init__.py): `handlers/__init__.py`
- [Start handler](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/common/start.py): `handlers/common/start.py`
- [Help handler](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/common/help.py): `handlers/common/help.py`

### Bot capabilities

- [Admin handlers](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/admin/users.py): `handlers/admin/users.py`
- [Profile handler](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/user/profile.py): `handlers/user/profile.py`
- [Settings handler](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/handlers/user/settings.py): `handlers/user/settings.py`
- [Registration states](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/states/register.py): `states/register.py`
- [Bot keyboards](https://github.com/temirovuz/telegrambot_template_aiogram/tree/main/keyboards): `keyboards`

### Data and policy

- [Subscription filter](https://github.com/temirovuz/telegrambot_template_aiogram/tree/main/filters): `filters`
- [Admin filter](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/filters/is_admin.py): `filters/is_admin.py`
- [Business services](https://github.com/temirovuz/telegrambot_template_aiogram/tree/main/services): `services`
- [Database operations](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/db/crud.py): `db/crud.py`
- [Database models](https://github.com/temirovuz/telegrambot_template_aiogram/blob/main/db/models.py): `db/models.py`

### Other components

- **Telegram user**
- **Telegram API**

## Connections

- Telegram user → Telegram API: sends updates
- Telegram API → Aiogram dispatcher: polls updates
- Application entry → Aiogram dispatcher: starts polling
- Application entry → Configuration: reads settings
- Application entry → Logging setup: sets up
- Aiogram dispatcher → Handler router: dispatches updates
- Handler router → Start handler: routes /start
- Handler router → Help handler: routes /help
- Start handler → Telegram API: sends reply
- Help handler → Telegram API: sends reply
- Admin handlers → Admin filter: checks admin
- Admin handlers → Business services: delegates logic
- Profile handler → Business services: delegates logic
- Settings handler → Business services: delegates logic
- Business services → Database operations: uses operations
- Database operations → Database models: uses models
