I’ve recently done a lot of reading and experimenting with different FastAPI features, and decided to document that in a cookiecutter recipe for future references. The idea is to use this to bootstrap future FastAPI projects instead of copying bits and pieces from the documentation and from past projects.
Currently, this support examples for e.g.
Taskfileas a modern alternative toMakefileto perform e.g. the common build tasks- Test suite, including mocking DB connections following
best practices - A simple
Dockerfileto run the FastAPI app in a container - Various examples for
middleware, including HTTPS redirection, CORS, and rate limiting - Proper project setup for larger projects, following
the official FastAPI documentation
I’m sure there’ll be a lot more topics to cover and to improve; some of the features that I’d like to add in the near future are
- A basic security setup
- GitHub Actions for basic CI/CD setup
- Proper logging setup
- Examples for websocket connections
- …and more
Links