/FastAPI-Template

This is a simple RESTful FastAPI template that uses PostgreSQL as the database and Redis as the cache. It's deployed on Kubernetes with Helm and features a complete CI/CD pipeline, testing, and various other tools for implementation.

Primary LanguagePythonMIT LicenseMIT

FastAPI Template

CI CD Coverage

A simple restful fastapi template, using PostgreSQL as database and Redis as cache, deployed on Kubernetes with Helm. There is a full CI/CD pipeline, testing and other more tools to implement it.

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

  • Python 3.8
  • Poetry 1.1.12
  • Docker 20.10.12
  • Make 3.81

Installation

  1. Init environment, which will help you init poetry and install dependencies, it will also copy a new .env file.
make init
  1. Install pre-commit hook, it will run make ci-bundle to ensure code quality when you commit.
poetry run pre-commit install
  1. Run migrate command to use alembic upgrade database.
make migrate
  1. Enter the environment and start developing
poetry shell
  1. Start related components of API service
make service_up
  1. run test to make sure project work correctly, this project use pytest and pyytest-cov for testing
make test
  1. Start development API service, the service will run at http://localhost:8000
cd api && poetry run uvicorn app:APP --reload --host 0.0.0.0

Formatting & Linting

  1. This project uses black, isort, flake8, pylint for formatting and linting, you can customize these settings in the setup.cfg file.
make format
make lint

Roadmap

  • Add Redis cache
  • User Docker multiple stage build

Contribution