How expressapp/bot-template works
This repository is a Copier template for building pybotx-based bots, rather than a single bot with a defined business use case. Its main runtime workflow receives BotX command and callback HTTP requests, forwards them to the bot runtime, and returns protocol responses; registered command handlers provide the user-facing behavior. The template also supplies health checks, PostgreSQL record persistence, Redis-backed repositories, logging, and configuration. The README documents these capabilities, but several implementations are unsampled; those branches are included without guessing their internal call paths.
Main entry points: main.py Application lifecycle · sqlalchemy.py Database sessions · botx.py BotX endpoints · repo.py Record repository
Components 22
HTTP entry
- BotX endpoints
app/api/endpoints/botx.py - Health endpoint
app/api/endpoints/healthcheck.py.jinja - Router registry
app/api/routers.py
Bot runtime
- Bot runtime
app/bot/bot.py.jinja - Common commands
app/bot/commands/common.py - Bot middleware
app/bot/middlewares - Bot error handlers
app/bot/error_handlers/internal_error.py - BotX user search
app/services/botx_user_search.py
Data services
- Record repository
app/db/record/repo.py - CRUD operations
app/db/crud.py - Record model
app/db/record/models.py - Record schema
app/schemas/record.py - PostgreSQL
- Redis repositories
app/caching/redis_repo.py - Callback repository
app/caching/callback_redis_repo.py - Redis
Application platform
- Application lifecycle
app/main.py - Database sessions
app/db/sqlalchemy.py - Settings
app/settings.py - Logging
app/logger.py - Health service
app/services/healthcheck.py
Other components
- BotX platform
Connections 20
- BotX platform → BotX endpoints: sends requests
README.md - BotX endpoints → Bot runtime: dispatches commands
app/api/endpoints/botx.py - BotX endpoints → Bot runtime: delivers callbacks
app/api/endpoints/botx.py - Application lifecycle → Router registry: mounts routes
app/main.py - Router registry → BotX endpoints: registers routes
app/api/routers.py - Router registry → Health endpoint: registers routes
app/api/routers.py - Bot runtime → Common commands: registers handlers
README.md - Record repository → CRUD operations: uses CRUD
app/db/record/repo.py - Record repository → Record model: uses model
app/db/record/repo.py - Record repository → Record schema: creates records
app/db/record/repo.py - CRUD operations → Database sessions: uses sessions
app/db/crud.py - Record model → Database sessions: uses base
app/db/record/models.py - Database sessions → PostgreSQL: connects to
app/db/sqlalchemy.py - Application lifecycle → Database sessions: builds sessions
app/main.py - Application lifecycle → Redis repositories: configures repository
app/main.py - Application lifecycle → Callback repository: starts callback worker
app/main.py - Redis repositories → Redis: uses Redis
- Callback repository → Redis: uses Redis
- Database sessions → Settings: reads DSN
app/db/sqlalchemy.py - Application lifecycle → Settings: reads configuration
app/main.py