An open API service indexing awesome lists of open source software.

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

โœจ 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! ๐Ÿš€๐Ÿ˜„
https://github.com/right-git/jessy

Last synced: 6 months ago
JSON representation

โœจ 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! ๐Ÿš€๐Ÿ˜„

Awesome Lists containing this project

README

          

# ๐Ÿค– Jessy

> A modern, production-ready template for creating Telegram bots using [Aiogram](https://docs.aiogram.dev/) ๐Ÿš€

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](docs/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
```bash
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:
```bash
# Bot Configuration
BOT_TOKEN=your_bot_token_here
ADMINS_ID=123456789,987654321

# Database Configuration
DB_URL_ASYNC=postgresql+asyncpg://user:password@localhost:5432/dbname
DB_URL=postgresql://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):
```bash
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:
```bash
docker-compose logs -f bot
```

### ๐Ÿ›‘ Stopping the Services
```bash
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:
```bash
pip install -r requirements.txt
```
or using `uv` (faster):
```bash
uv sync
```
or
```bash
uv add -r requirements.txt
```
3. ๐Ÿ”„ Apply database migrations:
```bash
alembic upgrade head
```
4. ๐Ÿš€ Start the bot:
```bash
bash run.sh
```

---

## ๐ŸŒ Deployment

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

- โ˜๏ธ [Heroku](https://www.heroku.com/)
- โ˜๏ธ [AWS](https://aws.amazon.com/)
- โ˜๏ธ [DigitalOcean](https://www.digitalocean.com/)
- โ˜๏ธ [Railway](https://railway.app/)
- โ˜๏ธ [Render](https://render.com/)

---

## ๐Ÿค Contributing

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

1. ๐Ÿด Fork the repository
2. ๐ŸŒฟ Create a feature branch:
```bash
git checkout -b feature/your-feature-name
```
3. ๐Ÿ’พ Commit your changes:
```bash
git commit -m "โœจ Add your commit message"
```
4. ๐Ÿ“ค Push to the branch:
```bash
git push origin feature/your-feature-name
```
5. ๐Ÿ”„ Create a Pull Request

### ๐Ÿ“‹ Contribution Guidelines
- ๐Ÿ“– Read our [CODE.md](docs/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`](LICENSE) file for details.

---

## ๐Ÿ™ Acknowledgments

- ๐Ÿ“š [Aiogram Documentation](https://docs.aiogram.dev/)
- ๐Ÿณ [Docker Documentation](https://docs.docker.com/)
- ๐Ÿ”„ [Alembic Documentation](https://alembic.sqlalchemy.org/)
- ๐Ÿ [Python Documentation](https://docs.python.org/)

---

## ๐Ÿ†˜ Support

Need help? Here's how to get support:

- ๐Ÿ› **Bug Reports:** Open an [issue](https://github.com/right-git/jessy/issues)
- ๐Ÿ’ก **Feature Requests:** Create a feature request issue
- ๐Ÿ“– **Documentation:** Check our [CODE.md](docs/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](https://img.shields.io/github/stars/right-git/jessy?style=social)](https://github.com/right-git/jessy)

---

**Made with โค๏ธ for the Telegram Bot Community**