from contextlib import asynccontextmanager from fastapi import FastAPI from sqlalchemy import select from app.api.auth import router as auth_router from app.api.protocols import router as protocols_router from app.api.recordings import router as recordings_router from app.api.templates import router as templates_router from app.database import async_session from app.models.prompt_template import PromptTemplate from app.prompts.defaults import DEFAULT_TEMPLATES async def seed_default_templates(): async with async_session() as db: result = await db.execute(select(PromptTemplate)) if result.scalars().first() is not None: return for tpl in DEFAULT_TEMPLATES: db.add(PromptTemplate(**tpl)) await db.commit() @asynccontextmanager async def lifespan(app: FastAPI): await seed_default_templates() yield app = FastAPI(title="Meeting Protocol Service", lifespan=lifespan) app.include_router(auth_router) app.include_router(recordings_router) app.include_router(protocols_router) app.include_router(templates_router) @app.get("/api/health") async def health(): return {"status": "ok"}