A boilerplate RESTFul application code using FastAPI and PostgreSQL
The backend is a RESTful API application built in FastAPI and a PostgreSQL database.
To run the application you need to have Docker
and docker-compose
installed. So, just execute from the root directory:
docker-compose up
So, run the first migration:
docker-compose exec app alembic upgrade head
To run the tests:
docker-compose exec app pytest
To re-run the tests, firstly, we recreate the database because there are unit tests which create resources, so if it already exists the test will fail:
Remove the data files before recreate the container
rm -fr db_data/*
Recreate the db service:
docker-compose stop db
docker-compose rm db
docker-compose up -d db
Finally, re-run the migration and the tests:
docker-compose exec app alembic upgrade head
docker-compose exec app pytest