|
1 | 1 | # fastapi-gino-arq-uvicorn |
2 | 2 | High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (powered by Redis & PostgreSQL). |
3 | 3 |
|
4 | | -## Get Started |
5 | | -### Run Locally |
6 | | -_NOTE: You must have PostgreSQL & Redis running locally._ |
| 4 | +## Contents |
| 5 | +* [Get Started](#get-started) |
| 6 | + * [Setup](#setup) |
| 7 | + * [Run](#run) |
| 8 | + * [Run Locally](#run-locally) |
| 9 | + * [Run Locally with Docker-Compose](#run-locally-with-docker-compose) |
| 10 | + * [Build Your Application](#build-your-application) |
| 11 | +* [Features](#features) |
| 12 | + * [Core Dependencies](#core-dependencies) |
| 13 | + * [Additional Dependencies](#additional-dependencies) |
7 | 14 |
|
| 15 | +## Get Started |
| 16 | +### Setup |
8 | 17 | 1. Clone this Repository. `git clone https://github.com/leosussan/fastapi-gino-arq-uvicorn.git` |
9 | 18 | 2. Install `Python 3.8` and `poetry`. |
10 | | - * _RECOMMENDED_: use `asdf`, which is like `pyenv` / `nvm` / `gvm` for everything. |
11 | | - * [Install](https://asdf-vm.com/#/core-manage-asdf-vm?id=install-asdf-vm), then run `asdf plugin add python`, `asdf plugin add poetry`, and `asdf install` |
12 | | -3. Run `poetry install` from root. |
13 | | -4. Make a copy of `.dist.env`, rename to `.env`. Fill in PostgreSQL, Redis connection vars. |
14 | | -5. Generate DB Migrations: `alembic revision --autogenerate`. It will be applied when the application starts. You can trigger manually with `alembic upgrade head`. |
15 | | -6. Run: |
| 19 | + * Recommended Method: `asdf` - a universal version manager (think `nvm` or `pyenv`) |
| 20 | + * Follow [these instructions](https://asdf-vm.com/#/core-manage-asdf-vm?id=install-asdf-vm) to install `asdf`. |
| 21 | + * Run the following commands from the project root: |
| 22 | + * `asdf plugin add python` |
| 23 | + * `asdf plugin add poetry` |
| 24 | + * `asdf install` -- will download & configure this project's `Python` + `poetry` setup |
| 25 | + * If you have `Python 3.8` and `poetry` installed already, please feel free to skip. |
| 26 | +3. Install dependencies (`poetry install`). |
| 27 | +4. Activate pre-commit hooks (in `poetry shell`, run `pre-commit install`). |
| 28 | +5. Make a copy of `.dist.env`, rename to `.env`. Fill in PostgreSQL, Redis, Sentry (optional) variables. |
| 29 | +6. Generate DB Migrations: in `poetry shell`, run `alembic revision --autogenerate`. |
| 30 | + * Apply migrations manually with `alembic upgrade head`. |
| 31 | + * If using the Dockerfile, migrations are applied at startup. |
| 32 | + |
| 33 | +### Run |
| 34 | + |
| 35 | +#### Run Locally |
| 36 | +_NOTE: You must have PostgreSQL & Redis running locally._ |
| 37 | + |
| 38 | +1. Make sure PostgreSQL & Redis are running locally. |
| 39 | +2. Run: |
16 | 40 | - FastAPI Application: |
17 | 41 | * _For Active Development (w/ auto-reload):_ Run locally with `poetry run task app` |
18 | 42 | * _For Debugging (compatible w/ debuggers, no auto-reload):_ Configure debugger to run `python app/main.py`. |
19 | 43 | - Background Task Worker: |
20 | 44 | * _For Active Development:_ Run `poetry run task worker` |
21 | 45 |
|
22 | | -### Run Locally with Docker-Compose |
23 | | -1. Clone this Repository. `git clone https://github.com/leosussan/fastapi-gino-arq-uvicorn.git` |
24 | | -2. Generate a DB Migration: `alembic revision --autogenerate`.* |
25 | | -3. Run locally using docker-compose. `poetry run task compose-up`. |
26 | | - * Run `poetry run task compose-down` to spin down, clean up. |
| 46 | +#### Run Locally with Docker-Compose. |
| 47 | +1. Make sure `Docker` is running locally. |
| 48 | +2. Run `poetry run task compose-up`*. |
| 49 | + - Run `poetry run task compose-down` to spin down, clean up. |
27 | 50 |
|
28 | 51 | *`app/settings/prestart.sh` will run migrations for you before the app starts. |
29 | 52 |
|
@@ -53,4 +76,5 @@ _NOTE: You must have PostgreSQL & Redis running locally._ |
53 | 76 | * **Alembic:** Handles database migrations. Compatible with GINO. |
54 | 77 | * **SQLAlchemy_Utils:** Provides essential handles & datatypes. Compatible with GINO. |
55 | 78 | * **Sentry:** Open-source, cloud-hosted error + event monitoring. |
| 79 | +* **Pre-Commit:** automatic formatting (`black` + `isort`) and linting (`flake8`). |
56 | 80 | * **Taskipy:** Small, flexible task runner for Poetry. |
0 commit comments