
Slim Edition
About 654 words
The FastAPI Best Architecture slim edition is built as a Copier template: it keeps the core layering and a minimal runnable codebase while feature switches trim unneeded modules, lowering the cost of secondary customization.
Tips
The slim edition is no longer a separately maintained static repository. It lives in the slim branch of the main repository and evolves with the trunk.
Create a Project
The template source is the slim branch of the main repository.
uvx --from copier copier copy \
--vcs-ref slim \
https://github.com/fastapi-practices/fastapi-best-architecture.git \
my-appFill in the project information and pick the feature switches when prompted. You can also pass them directly with --data key=value.
Feature Switches
| Switch | Default | Description |
|---|---|---|
enable_task | true | Celery worker / beat |
enable_flower | true | Celery Flower task monitoring (requires the Celery task module) |
enable_snowflake | false | Snowflake primary keys (database auto-increment when disabled) |
enable_monitor_online | true | Online user monitoring API (requires Socket.IO) |
enable_monitor | true | Server monitoring and Redis monitoring API (same switch) |
enable_metrics | true | Prometheus metrics collection |
enable_traces | true | OpenTelemetry tracing and Tempo |
enable_logs | false | Loki log aggregation (huge log volume, disabled by default) |
enable_docker | true | Dockerfile / docker-compose / Nginx / Supervisor deployment configuration |
enable_socketio | true | Socket.IO and task notifications |
enable_login_log | true | Login logs |
enable_opera_log | true | Operation logs |
enable_password_history | true | Password history validation and records |
enable_login_captcha | true | Graphical login captcha |
enable_plugin_dict | true | Data dictionary plugin |
enable_plugin_email | true | Email plugin and email binding changes |
enable_plugin_notice | true | Notice and announcement plugin |
enable_plugin_oauth2 | true | OAuth2 social login plugin |
Always kept: users, roles, departments, menus, RBAC, data permissions, the Config plugin, login lockout, password expiry, session management with multi-device login control, pytest test code, local file uploads, and backend plugin management.
Observability Layers
Observability is split into three layers that can be combined as needed (enable_logs is disabled by default because application logs pushed through OTLP into Loki produce a very large volume).
| Layer | Switch | Code | Deployment |
|---|---|---|---|
| Metrics | enable_metrics | Prometheus metrics middleware, /metrics endpoint | fba_prometheus container, Grafana metrics dashboards |
| Traces | enable_traces | OpenTelemetry tracer and probes | fba_tempo container, fba_alloy (OTLP gateway) |
| Logs | enable_logs | OpenTelemetry log export | fba_loki container, Grafana log data source |
The Grafana container is enabled automatically when any of the three layers is on. When all three are off, deploy/backend/grafana/ is not kept.
Primary Key Strategy
Database auto-increment primary keys are used by default. With enable_snowflake enabled, the project switches to Snowflake IDs, which requires SNOWFLAKE_DATACENTER_ID and SNOWFLAKE_WORKER_ID (or Redis-assigned node IDs), and plugins must also provide init_snowflake.sql / destroy_snowflake.sql scripts.
Docker and Supervisor
Nginx and Supervisor belong to the Docker deployment. When enable_docker is disabled, deploy/backend/nginx.conf and deploy/backend/supervisor/ are not kept.
Projects with enable_docker disabled ship no container or process management configuration, so start them with local commands:
uv run fba runStart the Project
cd my-app
cp backend/.env.example backend/.env
uv sync
uv run fba runSync Template Updates
A generated project can keep following slim branch changes with Copier (slim is updated along with the trunk).
uvx --from copier copier update --vcs-ref slimNote
The process for syncing the slim template branch itself with the trunk is described in the repository root SYNC.md. That file is not distributed with the template.
Legacy Slim Editions
Caution
The following slim editions are no longer updated in real time. We are currently looking for maintainers.
SQLAlchemy
fba-slimFastAPI enterprise backend architecture (simplified)
Tortoise-ORM
fastapi_tortoise_mysqlfastapi + pydantic-v2 + tortoise-orm + aerich + mysql + redis
Changelog
7d943-update docson8049d-update docsona764d-update docsona15a7-update docson9311a-update docsond0ae1-update docsonf3a62-update docsone87e5-update docson65467-update docsonf7dc6-update docson3e26b-update docsonc620d-update docson3722f-update docson8e390-update docson496d8-update docsonbde7c-update docson57b73-update docson1f3b6-update docsona2e52-update docson812d2-update docsone5b37-update docsonc6ced-update docson47f62-update docsonefeef-update docson4f58b-initial commit (#1)on