https://github.com/peplxx/fast-template
Modular Production-Ready FastApi Template
https://github.com/peplxx/fast-template
api docker-compose fastapi fastapi-template grafana nginx production-ready prometheus starter-template web web-development
Last synced: 26 days ago
JSON representation
Modular Production-Ready FastApi Template
- Host: GitHub
- URL: https://github.com/peplxx/fast-template
- Owner: peplxx
- Created: 2024-11-11T18:53:45.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-04-25T08:28:31.000Z (6 months ago)
- Last Synced: 2025-04-25T09:38:59.268Z (6 months ago)
- Topics: api, docker-compose, fastapi, fastapi-template, grafana, nginx, production-ready, prometheus, starter-template, web, web-development
- Language: Python
- Homepage:
- Size: 209 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI App Template
[](https://www.python.org)
[](https://github.com/peplxx/fast-template/actions/workflows/main.yaml)
[](https://github.com/astral-sh/ruff)
[](https://opensource.org/licenses/MIT)
[](https://fastapi.tiangolo.com)
[](https://www.postgresql.org)
[](https://prometheus.io)
[](https://grafana.com)
[](https://www.docker.com)
[](https://nginx.org)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 systemEverything is pre-configured and tested to work together. Just clone, customize, and start building your application.
---
## Quick Start
### Sections
1. [Requirements](#requirements)
2. [How to navigate](#how-to-navigate-in-project)
3. [How to run](#how-to-run-app)
4. [How to develop](#how-to-develop)
5. [How to use dev tools](#how-to-use-dev-tools)---
### RequirementsYou'll need these tools installed:
- [Docker](https://docs.docker.com/engine/install/)
- [Docker Compose](https://docs.docker.com/compose/install/)
- [Make](https://www.gnu.org/software/make/)>**Quick Install:** run `./deploy/dependencies.sh` to install requirements
---
### How to navigate in projectUse `make help` to see all available commands:
```bash
make help
```
---
### How to run app#### 1. Setup `.env` file
```bash
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````bash
make
```
> **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
```bash
make poetry # Installs all dependency groups (test, dev)
```#### 2. Pre-commit hooks
```bash
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](https://www.oreilly.com/library/view/software-architecture-patterns/9781491971437/ch01.html) 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:
```bash
make 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`
---