- FastAPI
- SQLAlchemy and Alembic
- Pre-commit hooks (black, autoflake, isort, flake8, prettier)
- Github Action
- Dependabot config
- Docker images
Start a local development instance with docker-compose
docker-compose up -d
# Run database migration
docker-compose exec backend alembic upgrade head
# Create database used for testing
docker-compose exec postgres createdb apptest -U postgres
Now you can navigate to the following URLs:
- Backend OpenAPI docs: http://localhost:8000/docs/
Keep your code clean by using the configured pre-commit hooks. Follow the instructions here to install pre-commit. Once pre-commit is installed, run this command to install the hooks into your git repository:
pre-commit install
The backend setup of docker-compose is set to automatically reload the app whenever code is updated.
If you add a dependency, you'll need to rebuild your containers like this:
docker-compose up -d --build
These two are the most used commands when working with alembic. For more info, follow through Alembic's tutorial.
# Auto generate a revision
docker-compose exec backend alembic revision --autogenerate -m 'message'
# Apply latest changes
docker-compose exec backend alembic upgrade head
Backend uses a hardcoded database named apptest, first ensure that it's created
docker-compose exec postgres createdb apptest -U postgres
Then you can run tests with this command:
docker-compose exec backend pytest
Configure the build-push-action in .github/workflows/test.yaml
.
Created with FastAPI Starter