KiraPC / fastapi-mvc-boilerplate

A sample FastAPI project implemented using the MVC Pattern.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🧰 fastapi-mvc-boilerplate

A sample FastAPI project implemented using the MVC Pattern.

πŸ’‘ Features

  • [βœ”οΈ] 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

πŸ”¨ How to use

  • Clone this repository or download it. Customize!
  • Just click on 'Use this template' button on GitHub page

🌞 How to start app

First install the dependencies

pip install -r requirements.txt

πŸ“˜ If you are using VSCode

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.

βœ‹ Manually

  • 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

πŸ”¨ How to run tests

Install tests requirements

pip install -r tests/requirements.txt

Run

python3 -m unittest discover -s tests -p '*_test.py'

πŸ“” Notes

I am open to suggestions and criticisms, please, if something seems wrong or can be improved, tell it through an issue on the project

About

A sample FastAPI project implemented using the MVC Pattern.

License:MIT License


Languages

Language:Python 99.0%Language:Dockerfile 1.0%