Implement AI orchestration wedding demo

This commit is contained in:
pelpanagiotis
2026-06-27 13:50:11 +03:00
commit 55d4fe95b4
67 changed files with 4736 additions and 0 deletions

53
backend/app/main.py Normal file
View File

@@ -0,0 +1,53 @@
import logging
import time
from uuid import uuid4
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from pythonjsonlogger import jsonlogger
from app.api.routes import router
from app.config import get_settings
from app.infrastructure.database import init_db
def configure_logging() -> None:
handler = logging.StreamHandler()
handler.setFormatter(jsonlogger.JsonFormatter("%(asctime)s %(levelname)s %(name)s %(message)s %(request_id)s %(latency_ms)s"))
logging.basicConfig(level=logging.INFO, handlers=[handler], force=True)
def create_app() -> FastAPI:
configure_logging()
settings = get_settings()
app = FastAPI(title=settings.app_name, version="0.1.0")
app.add_middleware(
CORSMiddleware,
allow_origins=settings.cors_origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(router)
@app.on_event("startup")
def startup() -> None:
init_db()
@app.middleware("http")
async def request_logging(request: Request, call_next):
request_id = request.headers.get("x-request-id", str(uuid4()))
start = time.perf_counter()
response = await call_next(request)
latency_ms = round((time.perf_counter() - start) * 1000, 2)
logging.getLogger("app.request").info(
"request complete",
extra={"request_id": request_id, "latency_ms": latency_ms, "path": request.url.path, "status_code": response.status_code},
)
response.headers["x-request-id"] = request_id
return response
return app
app = create_app()