Professional CLI scaffolding tool for aiogram 3.x Telegram bots
Project description
๐ค Aiogram Part
Professional CLI scaffolding tool for Telegram bots with aiogram 3.x
5 daqiqada production-ready bot yarating! Database, Redis, Testing, Deployment - hammasi tayyor! ๐
โก Quick Start
# Install
pip install aiogram-part
# Create bot with database (SQLite/PostgreSQL/MySQL)
mkdir my-bot && cd my-bot
aiogram-part init-project --with-db --type postgresql
# Setup
cp .env.example .env # Edit BOT_TOKEN
make install # Install dependencies
# Run
make run # Or: docker-compose up -d
Tayyor! Bot ishlayapti! โ
๐ฏ Features
| Feature | Description | Commands |
|---|---|---|
| ๐๏ธ Clean Architecture | Scoped handlers (user/admin), services, filters | 20+ commands |
| ๐๏ธ Database | SQLite/PostgreSQL/MySQL + Aerich migrations | init-project --with-db --type |
| โก Redis | Caching & FSM storage with fallback | Auto-configured |
| ๐ณ Docker | Database-specific docker-compose | docker-compose up |
| ๐งช Testing | pytest + fixtures + test generator | aiogram-part test |
| ๐ Health Check | Environment validator with auto-fix | aiogram-part check --fix |
| ๐ Statistics | Project metrics with Rich tables | aiogram-part stats |
| ๐ Webhook | Setup & status commands | aiogram-part webhook |
| ๐ Deployment | Systemd service generator | aiogram-part deploy |
| ๐ Logging | Rotating logs with levels | Built-in |
| ๐ i18n | Multi-language with Babel | aiogram-part i18n |
| ๐ Type Safe | Pydantic settings + OOP keyboards | All templates |
๐ฆ Commands
๐ Project Initialization
# Basic project
aiogram-part init-project
# With database (choose type)
aiogram-part init-project --with-db --type sqlite # SQLite (default)
aiogram-part init-project --with-db --type postgresql # PostgreSQL + Docker
aiogram-part init-project --with-db --type mysql # MySQL + Docker
Creates 38+ directories, 41+ files: handlers, services, filters, keyboards, middlewares, models, tests, Docker configs.
๐ฏ Code Generators
Handlers - Command, Message, Callback
aiogram-part handler user command start # /start command
aiogram-part handler admin command stats # Admin-only command
aiogram-part handler user message photo # Photo messages
aiogram-part handler user callback confirm # Callback handler
Creates: handlers/{users|admins}/{commands|messages|callbacks}/name.py + auto-registers router
Models - Database models with Tortoise ORM
aiogram-part model User # Model only
aiogram-part model Product --with-crud # Model + CRUD operations
Creates: database/models/name.py + optional database/crud/name.py
Keyboards - OOP Builder pattern
aiogram-part keyboard --scope user --build-keyboard inline menu
aiogram-part keyboard --scope admin --build-keyboard reply settings --str-params status
aiogram-part keyboard --scope common --build-keyboard inline language \
--str-params lang --int-params user_id
Creates: keyboards/{users|admins|common}/name.py with Builder pattern class
Filters - Custom filters
# Common filters (IsAdmin, IsPremium, etc)
aiogram-part filter --scope common --type common admin
# Callback filters (structured button data)
aiogram-part filter --scope user --type callback product \
--str-params action --int-params product_id
Creates: filters/{users|admins|common}/{common|callback}/name.py
Middlewares - Request interceptors
aiogram-part middleware --scope user throttling --types message
aiogram-part middleware --scope admin logger --types all
aiogram-part middleware --scope common auth --types message callback_query
Creates: middlewares/{users|admins|common}/name.py
Services - Business logic layer
aiogram-part service --scope user payment # User payment service
aiogram-part service --scope admin analytics # Admin analytics
aiogram-part service --scope common notification # Common notification
Creates: services/{users|admins|common}/name.py with service class
States - FSM state machines
aiogram-part state Registration # User registration flow
aiogram-part state OrderCheckout # Checkout process
Creates: states/name.py with StatesGroup
Validators - Input validation
aiogram-part validator phone --type regex # Phone number regex
aiogram-part validator email --type custom # Custom email validator
Creates: utils/validators/name.py
Enums - Database enums
aiogram-part enum UserRole --values admin --values user --values moderator
aiogram-part enum OrderStatus --values pending --values completed
Creates: database/enums/name.py with enum class
๐๏ธ Database Management (Aerich - Prisma-like)
aiogram-part db migrate # Initialize migrations
aiogram-part db update model # Auto-detect model changes
aiogram-part db upgrade # Apply migrations
aiogram-part db downgrade # Rollback migration
aiogram-part db history # View migration history
aiogram-part db heads # Show current version
aiogram-part db reset # Reset database
aiogram-part db generate description # Generate custom migration
aiogram-part db inspect # Inspect database schema
๐งช Testing & Quality
Test Generator
aiogram-part test --type handler start # Handler test
aiogram-part test --type service payment # Service test
aiogram-part test --type generic utils # Generic test
Creates: tests/{handlers|services}/test_name.py with pytest fixtures
Environment Checker
aiogram-part check # Check project health
aiogram-part check --fix # Auto-fix issues
Checks: dependencies, .env file, migrations, Python version
Project Statistics
aiogram-part stats # Rich table with metrics
Shows: handlers, services, models, filters, middlewares, states, files, LOC
๐ Deployment & Operations
Webhook Management
aiogram-part webhook setup https://bot.example.com # Configure webhook
aiogram-part webhook status # Check status
Systemd Service
aiogram-part deploy --user botuser --python /path/to/python3
Generates systemd service file for Linux servers
Multi-language Support
aiogram-part i18n # Setup i18n + Babel
Creates: locales/ + middleware + Makefile commands
๐ Project Structure
bot/
โโโ handlers/
โ โโโ users/ # User handlers
โ โ โโโ commands/ # /start, /help
โ โ โโโ messages/ # Text, photo messages
โ โ โโโ callbacks/ # Callback queries
โ โโโ admins/ # Admin-only handlers
โ โโโ errors/ # Error handlers
โโโ services/
โ โโโ users/ # User business logic
โ โโโ admins/ # Admin business logic
โ โโโ common/ # Shared services
โโโ filters/
โ โโโ users/ # User filters
โ โโโ admins/ # Admin filters
โ โโโ common/ # Shared filters
โโโ keyboards/
โ โโโ users/ # User keyboards (OOP)
โ โโโ admins/ # Admin keyboards
โ โโโ common/ # Shared keyboards
โโโ middlewares/
โ โโโ users/ # User middlewares
โ โโโ admins/ # Admin middlewares
โ โโโ common/ # Global middlewares
โโโ database/
โ โโโ models/ # Tortoise ORM models
โ โโโ crud/ # CRUD operations
โ โโโ enums/ # Database enums
โ โโโ migrations/ # Aerich migrations
โโโ states/ # FSM states
โโโ utils/
โ โโโ validators/ # Input validators
โ โโโ decorators/ # Custom decorators
โ โโโ formatters/ # Data formatters
โโโ tests/
โ โโโ handlers/ # Handler tests
โ โโโ services/ # Service tests
โ โโโ conftest.py # pytest fixtures
โโโ core/ # Bot initialization
โโโ config/ # Settings & logging
โโโ locales/ # i18n translations
โโโ docker-compose.yml # Database + Redis
โโโ Dockerfile # Bot container
โโโ Makefile # Dev commands
โโโ .env.example # Environment template
๐ก Quick Examples
E-commerce Bot
aiogram-part init-project --with-db --type postgresql
aiogram-part model Product --with-crud
aiogram-part model Order --with-crud
aiogram-part enum OrderStatus --values pending --values paid --values shipped
aiogram-part service --scope user payment
aiogram-part handler user command catalog
aiogram-part keyboard --scope user --build-keyboard inline products --int-params page
aiogram-part filter --scope user --type callback product --str-params action --int-params product_id
aiogram-part test --type handler catalog
Multi-language Bot
aiogram-part init-project --with-db
aiogram-part i18n
aiogram-part model User --with-crud
aiogram-part state Registration
aiogram-part handler user command start
aiogram-part keyboard --scope common --build-keyboard inline language --int-params user_id
aiogram-part validator phone --type regex
make translate
Admin Panel Bot
aiogram-part init-project --with-db
aiogram-part filter --scope common --type common admin
aiogram-part handler admin command stats
aiogram-part handler admin command users
aiogram-part service --scope admin analytics
aiogram-part keyboard --scope admin --build-keyboard inline admin_panel
aiogram-part test --type service analytics
More examples: EXAMPLES.md
๐ ๏ธ Development Workflow
# Setup
make install # Install dependencies
make dev # Install dev tools
# Development
make run # Run bot locally
make test # Run tests
aiogram-part check # Health check
aiogram-part stats # View project stats
# Database
aiogram-part db update model # Detect changes
aiogram-part db upgrade # Apply migrations
aiogram-part db history # View history
# Production
aiogram-part webhook setup https://bot.example.com
aiogram-part deploy --user botuser
docker-compose up -d
๐ณ Docker Deployment
# SQLite (no external database needed)
docker-compose up -d
# PostgreSQL (recommended for production)
aiogram-part init-project --with-db --type postgresql
cp .env.example .env
docker-compose up -d # Starts bot + postgres + redis
# View logs
docker-compose logs -f bot
๐ Documentation
- ๐ Full README - Complete documentation
- ๐ก Examples - Real bot examples
- โ FAQ - Common questions๐ License
MIT ยฉ Sattorbek
๐ Links
- ๐ฆ PyPI
- ๐ GitHub
- ๐ Aiogram Docs
โญ Star on GitHub โข ๐ Documentation โข ๐ก Examples
Made with โค๏ธ for aiogram community
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiogram_part-1.0.1.tar.gz.
File metadata
- Download URL: aiogram_part-1.0.1.tar.gz
- Upload date:
- Size: 28.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1027e0746fd677ffae97b7cb16910a4575505f16c6d1840720075f0106e592d6
|
|
| MD5 |
b1301f444beb57f18a07116f38b4e2d2
|
|
| BLAKE2b-256 |
29a1fa5787b9b37fb3a97e8485f3ece848c4ee4249690ab184ca37c51c0bb307
|
File details
Details for the file aiogram_part-1.0.1-py3-none-any.whl.
File metadata
- Download URL: aiogram_part-1.0.1-py3-none-any.whl
- Upload date:
- Size: 35.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b501aa94a2735275a99cede4f1888ddc39def5ef8adf5fe89d400cdf65fadfd2
|
|
| MD5 |
38f665900e6369fe0ef5b16a507a6e77
|
|
| BLAKE2b-256 |
1f47a407775f269667254c32948c1a1a8dac274cd12c539c7f032db57b3dfc8e
|