fastapi-mvc icon indicating copy to clipboard operation
fastapi-mvc copied to clipboard

Developer productivity tool for making high-quality FastAPI production-ready APIs.


fastapi-mvc CI ❄️ Nix CI ❄️ codecov K8s integration Code style: black PyPI PyPI - Downloads PyPI - Python Version GitHub


Source Code:

Project scaffold:

Example generated project:

Fastapi-mvc is a developer productivity tool for FastAPI web framework. It is designed to make programming FastAPI applications easier by making assumptions about what every developer needs to get started. It allows you to write less code while accomplishing more. Core features:

  • Generated project based on MVC architectural pattern
  • WSGI + ASGI production server
  • Generated project comes with Sphinx documentation and 100% unit tests coverage
  • Kubernetes deployment with Redis HA cluster
  • Makefile, GitHub actions and utilities
  • Helm chart for Kubernetes deployment
  • Dockerfile with K8s and cloud in mind
  • Generate pieces of code or even your own generators
  • Uses Poetry dependency management
  • Includes set of Nix expressions
  • Virtualized reproducible development environment using Vagrant

Fastapi-mvc comes with a number of scripts called generators that are designed to make your development life easier by creating everything that’s necessary to start working on a particular task. One of these is the new application generator, which will provide you with the foundation of a fresh FastAPI application so that you don’t have to write it yourself.

Creating a new project is as easy as:

$ fastapi-mvc new /tmp/galactic-empire

This will create a fastapi-mvc project called galactic-empire in a /tmp/galactic-empire directory and install its dependencies using make install.

Once project is generated and installed lets run development uvicorn server (ASGI):

$ cd /tmp/galactic-empire
$ fastapi-mvc run

To confirm it’s actually working:

$ curl

Now let's add new API endpoints. For that we need to generate new controller:

$ fastapi-mvc generate controller death_star status load:post fire:delete

And then test generated controller endpoints:

$ curl
$ curl -X POST
$ curl -X DELETE

You will see it working in server logs as well:

INFO: - "GET /api/ready HTTP/1.1" 200 OK
INFO: - "GET /api/death_star/status HTTP/1.1" 200 OK
INFO: - "POST /api/death_star/load HTTP/1.1" 200 OK
INFO: - "DELETE /api/death_star/fire HTTP/1.1" 200 OK

You can get the project directly from PyPI:

pip install fastapi-mvc

Projects created with fastapi-mvc

If you have created a project with fastapi-mvc, feel free to open PR and add yourself to the list. Share your story and project. Your success is my success :)