Skip to content

✨ Jessy: Your go-to template for Telegram bots with Aiogram! πŸ€– Get up and running fast with Docker, PostgreSQL, and Alembic for database migrations. Perfect for bootstrapping your next project! πŸš€πŸ˜„

License

Notifications You must be signed in to change notification settings

right-git/jessy

Repository files navigation

πŸ€– Jessy

A modern, production-ready template for creating Telegram bots using Aiogram πŸš€

This template includes essential setup for Docker 🐳, PostgreSQL 🐘, and Alembic for database migrations, making it easy to bootstrap your next Telegram bot project with best practices and clean architecture.


✨ Features

  • πŸ€– Aiogram Framework: A modern and efficient async framework for Telegram bots
  • πŸ—„οΈ Database Integration: Pre-configured with PostgreSQL and SQLAlchemy ORM
  • πŸ”„ Database Migrations: Integrated with Alembic for schema migrations
  • 🐳 Dockerized Setup: Docker Compose configuration for easy deployment
  • πŸ”§ Environment Variables: Centralized configuration using a .env file
  • πŸ“Š Structured Logging: Loguru-based logging with file rotation
  • πŸ›‘οΈ Anti-Flood Protection: Built-in middleware to prevent spam
  • πŸ‘₯ User Management: Automatic user tracking and activity monitoring
  • πŸ” Admin Panel: Built-in admin commands and user management
  • 🎯 Clean Architecture: Modular design with separation of concerns

πŸ“ Project Structure

jessy/
β”œβ”€β”€ πŸ“‚ app/                  # Main application code
β”‚   β”œβ”€β”€ πŸ€– bot.py            # Bot entry point and dispatcher setup
β”‚   β”œβ”€β”€ πŸ”˜ buttons/          # Telegram keyboard/button definitions
β”‚   β”œβ”€β”€ βš™οΈ config/           # Configuration and environment loading
β”‚   β”œβ”€β”€ πŸ—„οΈ database/         # Database models, access, and admin/user logic
β”‚   β”œβ”€β”€ πŸ“ handlers/         # Message handlers for users and admins
β”‚   β”œβ”€β”€ πŸ”— middlewares/      # Custom aiogram middlewares
β”‚   └── πŸ› οΈ utils/            # Filters, states, and utility code
β”œβ”€β”€ πŸ“‚ migrations/           # Alembic migration scripts
β”œβ”€β”€ πŸ“‚ logs/                 # Log files (created at runtime)
β”œβ”€β”€ πŸ“‚ docs/                 # Documentation
β”‚   └── πŸ“„ CODE.md           # Code principles and project structure
β”œβ”€β”€ πŸš€ main.py               # Simple hello-world entry (for testing)
β”œβ”€β”€ 🐚 run.sh                # Shell script to run the bot
β”œβ”€β”€ πŸ“‹ requirements.txt      # Python dependencies
β”œβ”€β”€ βš™οΈ pyproject.toml        # Project metadata and dependencies
β”œβ”€β”€ 🐳 Dockerfile            # Docker build instructions
β”œβ”€β”€ πŸ™ docker-compose.yml    # Docker Compose setup for bot and DB
β”œβ”€β”€ πŸ”„ alembic.ini           # Alembic configuration
β”œβ”€β”€ πŸ“– README.md             # Main project documentation
└── πŸ“„ LICENSE               # License file

πŸ“š Want to learn more about the code structure? Check out our πŸ“„ CODE.md for detailed code principles and architecture guidelines!


πŸš€ Getting Started

πŸ“‹ Prerequisites

  • 🐍 Python 3.10+
  • 🐳 Docker & Docker Compose
  • 🐘 PostgreSQL (if running locally without Docker)

βš™οΈ Setup

1️⃣ Clone the Repository

git clone https://github.com/right-git/jessy.git
cd jessy

2️⃣ Create a .env File

Create a .env file in the project root with your configuration:

# Bot Configuration
BOT_TOKEN=your_bot_token_here
ADMINS_ID=123456789,987654321

# Database Configuration
DATABASE_URL_ASYNC=postgresql+asyncpg://user:password@localhost:5432/dbname
DB_USERNAME=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=your_db_name
DB_PORT=5432

3️⃣ Build and Start the Project

Using Docker Compose (recommended):

docker-compose up --build

This will:

  • πŸ—οΈ Build the bot service
  • 🐘 Spin up a PostgreSQL database
  • πŸ€– Run the Telegram bot automatically

🎯 Usage

πŸ€– Starting the Bot

The bot starts automatically when the bot container is running.

πŸ“Š Accessing Logs

To view logs:

docker-compose logs -f bot

πŸ›‘ Stopping the Services

docker-compose down

πŸ’» Development

πŸ“¦ Install Dependencies

If you prefer running the bot locally:

  1. 🐘 Set up PostgreSQL database and configure .env file
  2. πŸ“¦ Install dependencies:
    pip install -r requirements.txt
    or using uv (faster):
    uv sync
    or
    uv add -r requirements.txt
  3. πŸ”„ Apply database migrations:
    alembic upgrade head
  4. πŸš€ Start the bot:
    bash run.sh

🌐 Deployment

This template is designed for easy deployment via Docker. You can use platforms like:


🀝 Contributing

We welcome contributions! Here's how you can help:

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch:
    git checkout -b feature/your-feature-name
  3. πŸ’Ύ Commit your changes:
    git commit -m "✨ Add your commit message"
  4. πŸ“€ Push to the branch:
    git push origin feature/your-feature-name
  5. πŸ”„ Create a Pull Request

πŸ“‹ Contribution Guidelines

  • πŸ“– Read our CODE.md for coding standards
  • πŸ§ͺ Write tests for new features
  • πŸ“ Update documentation when needed
  • 🎨 Follow the existing code style

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.


πŸ™ Acknowledgments


πŸ†˜ Support

Need help? Here's how to get support:

  • πŸ› Bug Reports: Open an issue
  • πŸ’‘ Feature Requests: Create a feature request issue
  • πŸ“– Documentation: Check our CODE.md for detailed guides
  • πŸ’¬ Discussions: Use GitHub Discussions for questions

⭐ Show Your Support

If this project helped you, please give it a star! ⭐

Stars


Made with ❀️ for the Telegram Bot Community

About

✨ Jessy: Your go-to template for Telegram bots with Aiogram! πŸ€– Get up and running fast with Docker, PostgreSQL, and Alembic for database migrations. Perfect for bootstrapping your next project! πŸš€πŸ˜„

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published