feat(backend): initialisation du projet FastAPI

Structure en couches api / services / repositories / models, sens de
dependance unique, une session SQLAlchemy async injectee par dependance.

- Python 3.14, dependances gerees par uv et verrouillees dans uv.lock
- FastAPI expose par une factory : aucune configuration lue a l'import,
  ce qui rend tests et migrations independants de l'environnement
- Settings Pydantic, APP_SECRET_KEY et DATABASE_URL sans valeur par defaut
- Sondes /health/live et /health/ready, metriques Prometheus sur /metrics
- Lint et format ruff, mypy strict, pytest avec couverture
- Alembic branche sur DATABASE_URL et non sur alembic.ini
- Image Docker multi-stage, utilisateur non root, sonde de sante integree
This commit is contained in:
Johan LEROY
2026-09-14 12:26:20 +02:00
parent 26704831e4
commit 6161a432c3
36 changed files with 1795 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
BACKEND := apps/backend
.DEFAULT_GOAL := help
.PHONY: help install dev lint format typecheck test check docker-build
help: ## Liste les cibles disponibles
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-16s\033[0m %s\n", $$1, $$2}'
install: ## Installe les dependances du backend
cd $(BACKEND) && uv sync --all-groups
dev: ## Lance l'API en rechargement a chaud
cd $(BACKEND) && uv run uvicorn app.main:create_app --factory --reload --host 0.0.0.0 --port 8000
lint: ## Analyse statique du backend
cd $(BACKEND) && uv run ruff check .
format: ## Formate et corrige le backend
cd $(BACKEND) && uv run ruff format . && uv run ruff check --fix .
typecheck: ## Verifie le typage du backend
cd $(BACKEND) && uv run mypy app
test: ## Execute les tests backend
cd $(BACKEND) && uv run pytest
check: lint typecheck test ## Chaine de verification complete
docker-build: ## Construit l'image du backend
docker build -t enervision-backend:local $(BACKEND)