feat: scaffold FastAPI backend with ports-and-adapters layout

This commit is contained in:
Justin Visser 2026-08-09 20:58:10 +02:00
parent eee8195662
commit c6a737db96
16 changed files with 685 additions and 0 deletions

0
backend/app/__init__.py Normal file
View file

View file

View file

View file

View file

23
backend/app/config.py Normal file
View file

@ -0,0 +1,23 @@
"""Typed application settings: the only reader of environment variables."""
from enum import StrEnum
from pydantic_settings import BaseSettings, SettingsConfigDict
class AppMode(StrEnum):
"""Runtime mode: live Spotify + Anthropic, or fixture-replay demo."""
LIVE = "live"
DEMO = "demo"
class Settings(BaseSettings):
"""Application settings, loaded from the environment or a .env file."""
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
app_mode: AppMode = AppMode.DEMO
settings = Settings()

View file

27
backend/app/main.py Normal file
View file

@ -0,0 +1,27 @@
"""Application factory and wiring. No logic lives here."""
from pathlib import Path
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from app.config import settings
FRONTEND_DIST = Path(__file__).parent / "static"
def create_app() -> FastAPI:
"""Build the FastAPI app: API routes plus the built SPA on one port."""
app = FastAPI(title="discovery-by-llm", docs_url=None, redoc_url=None)
@app.get("/api/health")
def health() -> dict[str, str]:
return {"status": "ok", "mode": settings.app_mode}
if FRONTEND_DIST.is_dir():
app.mount("/", StaticFiles(directory=FRONTEND_DIST, html=True), name="spa")
return app
app = create_app()

View file

View file

View file