Home

Awesome

fastapi-gino-arq-uvicorn

High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (powered by Redis & PostgreSQL).

Contents

Get Started

Setup

  1. Clone this Repository. git clone https://github.com/leosussan/fastapi-gino-arq-uvicorn.git
  2. Install Python 3.8 and poetry.
    • Recommended Method: asdf - a universal version manager (think nvm or pyenv)
      • Follow these instructions to install asdf.
      • Run the following commands from the project root:
        • asdf plugin add python
        • asdf plugin add poetry
        • asdf install -- will download & configure this project's Python + poetry setup
      • ~NOTE: your machine must have a system version of Python installed. If you don't, run the following: asdf install python 3.8.2 && asdf global python 3.8.2
    • If you have Python 3.8 and poetry installed already, please feel free to skip.
  3. Install dependencies (poetry install).
  4. Activate pre-commit hooks (in poetry shell, run pre-commit install).
  5. Make a copy of .dist.env, rename to .env. Fill in PostgreSQL, Redis, Sentry (optional) variables.
  6. Generate DB Migrations: in poetry shell, run alembic revision --autogenerate.
    • Apply migrations manually with alembic upgrade head.
    • If using the Dockerfile, migrations are applied at startup.

Run

Run Locally

NOTE: You must have PostgreSQL & Redis running locally.

  1. Make sure PostgreSQL & Redis are running locally.
  2. Run:
    • FastAPI Application:
      • For Active Development (w/ auto-reload): Run locally with poetry run task app
      • For Debugging (compatible w/ debuggers, no auto-reload): Configure debugger to run python app/main.py.
    • Background Task Worker:
      • For Active Development: Run poetry run task worker

Run Locally with Docker-Compose.

  1. Make sure Docker is running locally.
  2. Run poetry run task compose-up*.
    • Run poetry run task compose-down to spin down, clean up.

*app/settings/prestart.sh will run migrations for you before the app starts.

Build Your Application

Features

Core Dependencies

Additional Dependencies