Generateur de projet FastAPI async + opinionated (auth JWT, admin UI, ARQ, tests)
Project description
Fabrik
Generateur de projet FastAPI async + opinionated.
En 60 secondes : auth JWT, admin UI auto-decouverte, tests isoles,
background tasks (ARQ), migrations Alembic, CORS strict, responsive.
Version : 1.0.1 ·
Auteur : Falandy Jean ·
Licence : MIT
Installation
pip install fabrik-fastapi
Verifier l'installation :
fabrik --help
Pre-requis : Python 3.13+.
60 secondes pour demarrer
fabrik new mon-api
cd mon-api
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/Mac
python create_superuser.py
python -m uvicorn main:app --reload
Ouvre :
- Admin UI : http://127.0.0.1:8000/admin
- Swagger : http://127.0.0.1:8000/docs
Ce que tu obtiens out-of-the-box
| Domaine | Choix par defaut |
|---|---|
| Framework | FastAPI 0.136 + Starlette |
| ORM | SQLAlchemy 2.0 async (AsyncSession) |
| Driver DB | aiosqlite (dev) / asyncpg (prod PostgreSQL) |
| Auth | JWT (access + refresh) avec bcrypt |
| Admin | UI auto-decouverte responsive, multi-search, bulk delete, CSV |
| Migrations | Alembic (autogenerate) |
| Background tasks | ARQ (Redis-backed, async-native) avec degradation gracieuse |
| Tests | pytest + pytest-asyncio + DB SQLite in-memory isolee |
| CORS | Strict via BACKEND_CORS_ORIGINS (pas de *) |
| Config | pydantic-settings (12-factor) |
| Docker | Dockerfile Python 3.13-slim + docker-compose.yml |
Les 4 commandes
| Commande | Effet |
|---|---|
fabrik new <nom> |
Genere un projet complet (venv + deps + migration initiale) |
fabrik add <module> |
Ajoute un module CRUD (auto-wire + migration + tests) |
fabrik upgrade |
Met a jour un projet existant a la derniere version |
fabrik test-self |
Meta-test : verifie que le scaffold genere un projet OK |
Detail complet dans docs/USAGE.md.
Pourquoi Fabrik ?
Fabrik couvre l'angle mort entre Django (rigide, monolithique, sync) et FastAPI nu (zero opinion, 2 jours de plomberie a chaque projet).
| FastAPI standard | Django | Fabrik | |
|---|---|---|---|
| Stack async | oui | non | oui |
| Auth JWT prete | non | tierce | oui |
| Admin UI auto-genere | non | oui (sync) | oui (async, responsive) |
| Background tasks | non | Celery (tiers) | oui (ARQ inclus) |
| Tests isoles fournis | non | oui | oui |
| Architecture modulaire | a faire | apps | src/<module>/ |
| Migration de projet | non | manuel | fabrik upgrade |
| Demarrage zero-config | 2j | 30 min | 60 secondes |
Detail des choix de conception : ARCHITECTURE.md.
Structure d'un projet genere
mon-api/
├── main.py FastAPI app + lifespan + pool ARQ
├── worker.py Entrypoint ARQ (python worker.py)
├── docker-compose.yml Redis + (PostgreSQL optionnel)
├── .env SECRET_KEY 256 bits + CORS + DB + Redis
├── .scaffold-version Trace de la version Fabrik (pour upgrade)
├── create_superuser.py
├── requirements.txt
├── pytest.ini
├── alembic.ini + alembic/
├── src/
│ ├── database.py AsyncEngine + get_db
│ ├── tasks.py ARQ tasks + WorkerSettings + get_arq dep
│ ├── core/ Config, security, mixins, pagination
│ ├── users/ Module exemple (models/schemas/service/router)
│ └── admin/ UI auto-decouverte (router + templates + static)
└── tests/
├── conftest.py Fixtures async (DB in-memory isolee)
├── test_users.py
└── test_tasks.py
Architecture du repo Fabrik
fabrik/ Repo GitHub
├── pyproject.toml Package metadata (PyPI)
├── MANIFEST.in
├── README.md, ARCHITECTURE.md, LICENSE
├── docs/
│ ├── USAGE.md Guide utilisateur
│ └── PUBLISHING.md Workflow de release PyPI
├── .github/workflows/ci.yml CI : lance test-self a chaque commit
└── fabrik/ Package Python
├── __init__.py
├── __main__.py Pour `python -m fabrik`
├── scaffold.py Moteur CLI
└── core/ Templates copies a chaque `new`
Developpement local
Si tu veux contribuer ou tester en local sans publier sur PyPI :
git clone https://github.com/FalandyJEAN/fabrik.git
cd fabrik
pip install -e . # installation en mode editable
fabrik test-self # verifie que tout fonctionne
Tout changement qui modifie la structure des projets generes doit :
- Bumper
SCAFFOLD_VERSIONdansfabrik/scaffold.py(etversiondanspyproject.toml) - Ajouter une fonction
patch_vN_to_vM(root)idempotente - L'enregistrer dans
PATCHES fabrik test-selfdoit passer en local et en CI
Publication PyPI
Workflow complet dans docs/PUBLISHING.md. En resume :
pip install -e ".[dev]"
python -m build
twine upload dist/*
Licence
MIT © 2026 Falandy Jean — voir LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fabrik_fastapi-1.0.1.tar.gz.
File metadata
- Download URL: fabrik_fastapi-1.0.1.tar.gz
- Upload date:
- Size: 65.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74ed203830e289a9bfa14484ab73eebbdf177257a296757bc6e6079179890e44
|
|
| MD5 |
3f1273b6acee85b24b61ce58b6056508
|
|
| BLAKE2b-256 |
336130c31e074f88c28a9c2ac5d15b862e09353c9aa7e5377ca992c3ca505cd7
|
File details
Details for the file fabrik_fastapi-1.0.1-py3-none-any.whl.
File metadata
- Download URL: fabrik_fastapi-1.0.1-py3-none-any.whl
- Upload date:
- Size: 57.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fea1d5744379cdd15649c2aec39034274bfbd5294b72af7b07e4f52e91abc764
|
|
| MD5 |
bd0727f2091ab4ee02af3253cb11373d
|
|
| BLAKE2b-256 |
33768a7e3751f3c282e16333e467b1e9faf128dc7bf3e6ac88cd27f8e729dbee
|