"""Application entrypoint and router wiring.""" from fastapi import Depends, FastAPI from fastapi.middleware.cors import CORSMiddleware from api.v1.router import router as api_v1_router from core.config import Settings, get_settings from features.health.router import build_health_payload from features.health.schemas import HealthResponse def create_app() -> FastAPI: """Create and configure the FastAPI application.""" app = FastAPI( title="avaaz-backend", version="0.1.0", docs_url="/docs", redoc_url="/redoc", ) # CORS for local dev (frontend on 3000). Tighten/override in prod. app.add_middleware( CORSMiddleware, allow_origins=["http://localhost:3000", "http://127.0.0.1:3000"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) app.include_router(api_v1_router, prefix="/api/v1") @app.get("/healthz", tags=["health"], response_model=HealthResponse) def liveness(settings: Settings = Depends(get_settings)) -> HealthResponse: """Liveness probe: process is up.""" return build_health_payload(settings) @app.get("/readyz", tags=["health"], response_model=HealthResponse) def readiness(settings: Settings = Depends(get_settings)) -> HealthResponse: """ Readiness probe: instance can serve traffic. Extend to check dependencies (DB, cache, queues) when they are added. """ return build_health_payload(settings) return app app = create_app()