Skip to content

ilkersigirci/api-template

Repository files navigation

api-template

FastAPI Template with Industry Standard Observability

Logfire

  • Logfire is Uncomplicated Observability for Python by Pydantic Team.

  • Create a new project in Logfire with name api-template

  • Setup logfire in your project

# Authenticate with Logfire, one time operation
logfire auth

# Initialize your local project to use Logfire
logfire projects use api-template
  • Set in your .env file: OLTP_LOG_METHOD=logfire

Taskiq

  • Taskiq is distributed task queue with full async support.

  • Like celery but better with async support and more broker support like Redis, RabbitMQ, Kafka, etc.

  • The official docs recommend taskiq-aio-pika as the broker and taskiq-redis as the result backend for production use.

  • Test taskiq with RabbitMQ and Redis

# Run Redis and RabbitMQ in docker
make run-taskiq-services

# Run the taskiq workers
make run-taskiq-workers

# Test the taskiq workers
make run-taskiq-main

# (Optional) Run taskiq scheduler for periodic tasks
make run-taskiq-scheduler

Migrations

If you want to migrate your database, you should run following commands:

# To run all migrations until the migration with revision_id.
alembic upgrade "<revision_id>"

# To perform all pending migrations.
alembic upgrade "head"

Reverting migrations

If you want to revert migrations, you should run:

# revert all migrations up to: revision_id.
alembic downgrade <revision_id>

# Revert everything.
alembic downgrade base

Migration generation

To generate migrations you should run:

# For automatic change detection.
alembic revision --autogenerate

# For empty file generation.
alembic revision

About

FastAPI Template with Industry Standard Observability

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •