feat: scaffold FastAPI backend with ports-and-adapters layout
This commit is contained in:
parent
eee8195662
commit
c6a737db96
16 changed files with 685 additions and 0 deletions
0
backend/app/__init__.py
Normal file
0
backend/app/__init__.py
Normal file
0
backend/app/adapters/__init__.py
Normal file
0
backend/app/adapters/__init__.py
Normal file
0
backend/app/adapters/anthropic/__init__.py
Normal file
0
backend/app/adapters/anthropic/__init__.py
Normal file
0
backend/app/adapters/demo/__init__.py
Normal file
0
backend/app/adapters/demo/__init__.py
Normal file
0
backend/app/adapters/spotify/__init__.py
Normal file
0
backend/app/adapters/spotify/__init__.py
Normal file
0
backend/app/api/__init__.py
Normal file
0
backend/app/api/__init__.py
Normal file
23
backend/app/config.py
Normal file
23
backend/app/config.py
Normal 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()
|
||||
0
backend/app/domain/__init__.py
Normal file
0
backend/app/domain/__init__.py
Normal file
27
backend/app/main.py
Normal file
27
backend/app/main.py
Normal 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()
|
||||
0
backend/app/observability/__init__.py
Normal file
0
backend/app/observability/__init__.py
Normal file
0
backend/app/pipeline/__init__.py
Normal file
0
backend/app/pipeline/__init__.py
Normal file
0
backend/app/ports/__init__.py
Normal file
0
backend/app/ports/__init__.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue