A sample FastAPI project implemented using the MVC Pattern.
- [✔️] MIT License
- [✔️] FastApi + SQLAlchemy
- [✔️] Class Based Controller with fastapi-router-controller
- [✔️] Tests with unittest
- [✔️] Dockerfile with tiangolo/uvicorn-gunicorn-fastapi:python3.8
- [✔️] Configuration management with Environment Variables Interpolation
- [✔️] Centralized logging management
- [✔️] Log requests end-time
- [✔️] Formatted Exception Handler
- [✔️] Validation Exception Handler
- [✔️] Vscode dotfiles preconfigured
- [✔️] GitHub action for unit tests on PR
- [✔️] Sample Gunicorn Configuration
- Clone this repository or download it. Customize!
- Just click on 'Use this template' button on GitHub page
First install the dependencies
pip install -r requirements.txt
I included in the repository the VSCode configuration for tasks and debugging.
So, you can just use the VSCode shortcut to start the application:
- Start FastApi
- Start FastApi with Gunicorn
There are also two debug configurations:
- Debug FastApi
- Debug Python Current File
See more about VScode Tasks and Debug.
- Start with unicorn
pip install unicorn
uvicorn server/main:app --reload
- Start with gunicorn
pip install gunicorn
gunicorn server/main:app --config gunicorn_conf.py
Install tests requirements
pip install -r tests/requirements.txt
Run
python3 -m unittest discover -s tests -p '*_test.py'
I am open to suggestions and criticisms, please, if something seems wrong or can be improved, tell it through an issue on the project