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! ๐๐
- Host: GitHub
- URL: https://github.com/right-git/jessy
- Owner: right-git
- License: mit
- Created: 2024-12-18T18:03:11.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-01-09T08:42:36.000Z (over 1 year ago)
- Last Synced: 2025-01-25T14:29:10.492Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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! โญ
[](https://github.com/right-git/jessy)
---
**Made with โค๏ธ for the Telegram Bot Community**