Skip to content
/ fast-template Public template

Modular Production-Ready FastApi Template

Notifications You must be signed in to change notification settings

peplxx/fast-template

Repository files navigation

FastAPI App Template

Python Tests Ruff License: MIT FastAPI PostgreSQL Prometheus Grafana Docker Nginx

A production-ready FastAPI template with comprehensive integrations for modern web development.

Overview

This template provides a solid foundation for building production-ready web services with FastAPI. It combines modern tools and best practices to help you get started quickly:

  • Core Stack: FastAPI + PostgreSQL + SQLAlchemy
  • Deployment: Docker + Nginx + Certs configuration ready to go
  • Monitoring: Prometheus metrics and Grafana dashboards
  • Development: Poetry for dependencies, Ruff for linting, pytest for testing
  • CI/CD: GitHub Actions workflow included
  • Tooling: Custom module system to automate routine tasks
  • Pre-configured: App-logging, api-limiter, openapi-specification, metrics and CORS middlewares, etc.
  • Testing: Container-free testing system

Everything is pre-configured and tested to work together. Just clone, customize, and start building your application.


Quick Start

Sections

  1. Requirements
  2. How to navigate
  3. How to run
  4. How to develop
  5. How to use dev tools

Requirements

You'll need these tools installed:

Quick Install: run ./deploy/dependencies.sh to install requirements


How to navigate in project

Use make help to see all available commands:

make help

How to run app

1. Setup .env file

make env # Creates .env from .env.example

Note: View supported env-variables in backend/app/config/default.py

Note: env.example contains minimal required variables

2. Run app

Choose your configuration:

  • run-local - Local development: backend[local] + database[docker]
  • run-dev1 - Basic deployment: nginx[http] + backend + database
  • run-dev2 - Full development: nginx[http] + backend + database + grafana + prometheus
  • run-prod - Production: nginx[https + http] + backend + database + grafana + prometheus + pgbackups
make <target-config>

Local setup: starts database, setup poetry and make migrations besides runing app itself.

Production: Also there is script to run prod setup as linux-unit: /deploy/deploy-service.sh.


3. Avaliability

Assume, that you run app on localhost:

  • Backend/Swagger : localhost/swagger
  • Backend/Scalar : localhost/scalar
  • Graphana : localhost:3333, admin/admin

How to develop

1. Setup poetry environment

make poetry  # Installs all dependency groups (test, dev)

2. Pre-commit hooks

pre-commit install

Note: ruff formatting works only for /backend dir

Now you're ready to develop!


How to use dev tools

Project Architecture & Tools

This project is built using layered architecture pattern, which provides clear separation of concerns and maintainable codebase.

To accelerate development process, I provide automated tools located in /backend/.utils/ directory.

Tools list:

1. Module Generator

Generate a new module:

make module name=<module-name>

The generator will:

  1. Create module structure in backend/app/src/modules/{module-name}
  2. Setup testsuite in backend/tests/testsuites/{module-name}
  3. Add necessary base classes and metadata

Note: Import your new module in backend/app/src/modules/__init__.py