fastgram

Fastgram is a robust and scalable Telegram bot built with FastAPI, Aiogram3, SQLAlchemy, PostgreSQL, Redis, FastStream and Celery. It leverages modern web technologies and asynchronous programming to deliver high-performance and efficient bot interactions.

Fastgram template

Support Group - Telegram

Installation

  • 1 - clone repo
  • 2 - Setting up environment variables
    • cp .env.dist .env
  • 3 - RUN Project the following commands
    • make run.image - run with docker
  • 4 - Run the following commands without docker
    • python3 -m venv venv
    • source venv/bin/activate or ./venv/Scripts/activate
    • pip3 install -r requirements.txt
    • uvicorn main:app --port ${SERVICE_PORT} run bot
    • celery -A app.bot.services.external.celery.tasks worker -l INFO run celery worker
    • celery -A app.bot.services.external.celery.tasks beat -l INFO run celery beat

Architecture Overview

Fastgram is built using the following technologies:

  • FastAPI: A modern, fast (high-performance) web framework for building APIs with Python 3.6+ based on standard Python type hints.
  • aiogram 3: An asynchronous framework for Telegram Bot API based on asyncio and aiohttp.
  • SQLAlchemy: The Python SQL toolkit and Object-Relational Mapping (ORM) library.
  • PostgreSQL: A powerful, open-source object-relational database system.
  • Redis: An in-memory data structure store, used as a database, cache, and message broker.
  • Celery: An asynchronous task queue/job queue based on distributed message passing.
  • FastStream: For pub/sub messaging.

This combination of technologies ensures that Fastgram is robust, scalable, and ready for production environments.

(fastgram) šŸš€ fastgram % tree app/bot/services/external/aiogram
app/bot/services/external/aiogram
ā”œā”€ā”€ __init__.py
ā”œā”€ā”€ enum
ā”‚Ā Ā  ā”œā”€ā”€ __init__.py
ā”‚Ā Ā  ā””ā”€ā”€ state.py
ā”œā”€ā”€ filter
ā”‚Ā Ā  ā”œā”€ā”€ __init__.py
ā”‚Ā Ā  ā”œā”€ā”€ chat.py
ā”‚Ā Ā  ā”œā”€ā”€ payment.py
ā”‚Ā Ā  ā””ā”€ā”€ text.py
ā”œā”€ā”€ handler
ā”‚Ā Ā  ā”œā”€ā”€ __init__.py
ā”‚Ā Ā  ā”œā”€ā”€ echo.py
ā”‚Ā Ā  ā”œā”€ā”€ example.py
ā”‚Ā Ā  ā””ā”€ā”€ start.py
ā”œā”€ā”€ keyboard
ā”‚Ā Ā  ā”œā”€ā”€ __init__.py
ā”‚Ā Ā  ā”œā”€ā”€ inline
ā”‚Ā Ā  ā”‚Ā Ā  ā”œā”€ā”€ __init__.py
ā”‚Ā Ā  ā”‚Ā Ā  ā”œā”€ā”€ create.py
ā”‚Ā Ā  ā”‚Ā Ā  ā””ā”€ā”€ default.py
ā”‚Ā Ā  ā””ā”€ā”€ markup
ā”‚Ā Ā      ā”œā”€ā”€ __init__.py
ā”‚Ā Ā      ā”œā”€ā”€ create.py
ā”‚Ā Ā      ā””ā”€ā”€ default.py
ā”œā”€ā”€ middleware
ā”‚Ā Ā  ā”œā”€ā”€ __init__.py
ā”‚Ā Ā  ā””ā”€ā”€ lang.py
ā”œā”€ā”€ router
ā”‚Ā Ā  ā”œā”€ā”€ __init__.py
ā”‚Ā Ā  ā””ā”€ā”€ prepare.py
ā”œā”€ā”€ shortcut
ā”‚Ā Ā  ā”œā”€ā”€ __init__.py
ā”‚Ā Ā  ā”œā”€ā”€ action.py
ā”‚Ā Ā  ā””ā”€ā”€ schema.py
ā”œā”€ā”€ state
ā”‚Ā Ā  ā”œā”€ā”€ __init__.py
ā”‚Ā Ā  ā””ā”€ā”€ intro.py
ā””ā”€ā”€ storage
    ā”œā”€ā”€ __init__.py
    ā””ā”€ā”€ fsm.py