kieled / fastapi-aiopika-boilerplate

FastAPI, SQLAlchemy, aio_pika, RabbitMQ and Docker boilerplate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

๐Ÿ”บ FastAPI, SQLAlchemy 2, aio_pika, RabbitMQ boilerplate ๐Ÿ”บ

abstract rectangles colorful with ragged edges per (2)

โœ”๏ธ Features:

  1. Project fully async
  2. SqlAlchemy async session
  3. docker-compose and Dockerfiles
  4. RabbitConnection class. Path: src/config/rabbit_connection_py
  5. Base logging configuration
  6. FastAPI Cors base configuration
  7. FastAPI lifespan feature
  8. Poetry package manager
  9. Used hypercorn
  10. Configurated default BaseSettings instance
  11. PostgreSQL database and asyncpg driver used

๐Ÿ”’ Dependencies:

python = "^3.11"
fastapi = "^0.95.0"
hypercorn = "^0.14.3"
aio-pika = "^9.0.5"
sqlalchemy = "^2.0.8"
asyncpg = "^0.27.0"

๐Ÿ Setup

  1. Install Docker if not installed
  2. Rename .env.dev-example to .env.dev
  3. Run docker compose up -d --build command
  4. Open http://localhost:8000/docs in your browser

๐Ÿท๏ธ Tips:

  • Logs you can find by path src/logs
  • Also you can run command docker compose logs to check logs
  • You can disable logging to the files by removing/commenting this code in the consumer.py and main.py:
import logging

logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(levelname)s %(message)s',
    handlers=[
        logging.FileHandler("logs/fastapi.log"),
        logging.StreamHandler()
    ]
)

About

FastAPI, SQLAlchemy, aio_pika, RabbitMQ and Docker boilerplate


Languages

Language:Python 92.0%Language:Dockerfile 8.0%