from typing import Dict from fastapi import APIRouter, Depends, status from sqlalchemy.orm import Session from sqlalchemy import text from app.api.deps import get_db from app.core.config import settings router = APIRouter() @router.get("/", status_code=status.HTTP_200_OK) def health_check(db: Session = Depends(get_db)) -> Dict[str, str]: """ Check the health of the application. Returns: Dict with status and version information. """ # Check database connection try: db.execute(text("SELECT 1")) db_status = "healthy" except Exception: db_status = "unhealthy" return { "status": "ok" if db_status == "healthy" else "error", "version": settings.PROJECT_VERSION, "database": db_status }