from pathlib import Path

import logfire
from fastapi import FastAPI

from .routes import router


PROJECT_ROOT = Path(__file__).resolve().parents[1]
FRONTEND_DIR = PROJECT_ROOT / "frontend"

app = FastAPI()

logfire.configure(send_to_logfire="if-token-present")
logfire.instrument_fastapi(app)

app.include_router(router)

# FastAPI routes are checked first. If no route matches, files from frontend/
# are served as the static app shell and assets.
app.frontend("/", directory=FRONTEND_DIR, fallback=None)
