How wakaree/aiogram_bot_template works
This is a reusable aiogram Telegram bot template with FastAPI hosting, configurable polling/webhook startup, localization, persistence, and Redis-backed state/cache. Its principal user path is Telegram update → handler → flow → interactor/presenter → view renderer → Telegram response. The README documents this sequence; source evidence is sampled, so unsampled feature-level calls and repository wiring are not asserted. Major feature areas are represented at their exact tree paths.
Main entry points: handlers Update handlers · app.py App runner · flows Interaction flows · users.py Users gateway
Components 31
Runtime and delivery
- App runner
app/runners/app.py - Webhook API
app/presentation/fastapi/telegram.py - Health check
app/presentation/fastapi/healthcheck.py - Dispatcher setup
app/providers/telegram/dispatcher.py - Dependency wiring
app/providers/container.py - Bot lifecycle
app/infrastructure/telegram/lifespan.py - Settings provider
app/providers/infrastructure/app.py
Telegram interaction
- Update handlers
app/presentation/telegram/handlers - Interaction flows
app/presentation/telegram/flows - View presenters
app/presentation/telegram/presenters - View models
app/presentation/telegram/view/models.py - Bot renderer
app/presentation/telegram/view/renderer.py - Keyboard builders
app/presentation/telegram/keyboards - Callback data
app/presentation/telegram/callbacks - Update filters
app/presentation/telegram/filters - Request middleware
app/presentation/telegram/middlewares - Message helper
app/presentation/telegram/helpers/messages.py
Application and domain
- Use-case logic
app/application/interactors - User domain model
app/domain/user.py - User status use case
app/application/interactors/pm/user_status.py - Users gateway
app/application/ports/repositories/users.py - Application settings
app/application/models/config/env/app.py
Infrastructure
- Postgres user repository
app/infrastructure/postgres/repositories/users.py - Postgres unit of work
app/infrastructure/postgres/uow.py - PostgreSQL
- Redis key-value store
app/infrastructure/redis/repository.py - Redis
- Redis cache service
app/infrastructure/redis/cache/service.py - Localization manager
app/infrastructure/localization/manager.py
Other components
- Telegram user
- Telegram Bot API
Connections 34
- App runner → Webhook API: registers webhook
app/runners/app.py - App runner → Dispatcher setup: configures runtime
app/runners/app.py - App runner → Bot lifecycle: starts lifecycle
app/runners/app.py - App runner → Health check: sets up routes
- App runner → Dependency wiring: resolves dependencies
app/__main__.py - Settings provider → Application settings: constructs settings
app/providers/infrastructure/app.py - Telegram user → Webhook API: sends update
README.md - Webhook API → Dispatcher setup: dispatches update
README.md - Dispatcher setup → Update handlers: registers routers
app/providers/telegram/dispatcher.py - Update handlers → Interaction flows: calls flow
README.md - Interaction flows → Use-case logic: orchestrates use case
README.md - Interaction flows → View presenters: invokes presenter
README.md - View presenters → View models: builds view
README.md - Interaction flows → Bot renderer: calls renderer
README.md - Bot renderer → Telegram Bot API: sends response
README.md - Telegram user → Update handlers: sends update
README.md - Update handlers → Update filters: uses filters
- Update handlers → Request middleware: uses middleware
app/providers/telegram/dispatcher.py - View presenters → Keyboard builders: uses builders
- Update handlers → Callback data: processes callbacks
- Use-case logic → Users gateway: uses gateway
- Users gateway → Postgres user repository: implemented by
- Postgres user repository → Postgres unit of work: uses unit of work
- Postgres unit of work → PostgreSQL: reads and writes
- User domain model → Postgres user repository: persisted as entity
- User status use case → Users gateway: uses gateway
- Redis key-value store → Redis: reads and writes
- Redis cache service → Redis: reads and writes
app/infrastructure/redis/cache/service.py - Redis cache service → Redis key-value store: separate storage service
- Localization manager → Users gateway: saves locale
app/infrastructure/localization/manager.py - Localization manager → User domain model: reads and updates
app/infrastructure/localization/manager.py - Message helper → Telegram Bot API: messaging support
- Bot lifecycle → Telegram Bot API: configures bot
app/infrastructure/telegram/lifespan.py - Bot lifecycle → Redis key-value store: stores setup locks
app/infrastructure/telegram/lifespan.py