Skip to content

FastAPI, SQLAlchemy, aio_pika, RabbitMQ and Docker boilerplate

Notifications You must be signed in to change notification settings

kieled/fastapi-aiopika-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔺 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 https://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()
    ]
)