"""FastAPI application for ResearchLink AI.""" from __future__ import annotations from pathlib import Path from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import HTMLResponse from fastapi.staticfiles import StaticFiles from researchlink import __product__, __version__ from researchlink.api.routes.ingest import router as ingest_router from researchlink.api.routes.providers import router as providers_router from researchlink.api.routes.review import router as review_router from researchlink.api.routes.settings import router as settings_router from researchlink.api.routes.system import router as system_router app = FastAPI( title=__product__, version=__version__, description="Multi-agent research digest platform API", ) app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"], ) app.include_router(system_router) app.include_router(providers_router) app.include_router(ingest_router) app.include_router(settings_router) app.include_router(review_router) # Serve static files _static_dir = Path(__file__).parent.parent / "web" / "static" if _static_dir.exists(): app.mount("/static", StaticFiles(directory=str(_static_dir)), name="static") _templates_dir = Path(__file__).parent.parent / "web" / "templates" def _read_template(name: str) -> str: p = _templates_dir / name return p.read_text(encoding="utf-8") if p.exists() else f"

{name} not found

" @app.get("/", response_class=HTMLResponse) async def index(): # The new dashboard is the default entry point. return _read_template("dashboard.html") @app.get("/dashboard", response_class=HTMLResponse) async def dashboard_page(): return _read_template("dashboard.html") @app.get("/legacy", response_class=HTMLResponse) async def legacy_index(): # The previous single-page app, preserved. return _read_template("index.html") @app.get("/settings", response_class=HTMLResponse) async def settings_page(): return _read_template("settings.html") @app.get("/results", response_class=HTMLResponse) async def results_page(): return _read_template("results.html") @app.get("/history", response_class=HTMLResponse) async def history_page(): return _read_template("history.html") @app.get("/health") async def health(): return {"status": "ok", "product": __product__, "version": __version__}