Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/geremyjampiersalasgarcia-eng/Caso_Practico_Semillero_IA/llms.txt

Use this file to discover all available pages before exploring further.

The health endpoint provides a lightweight readiness check for the Mesa de Ayuda IA backend. It tests connectivity to each critical dependency — the PostgreSQL database and the Gemini LLM client — and aggregates the results into a single status field. Use this endpoint for uptime monitoring, Docker health checks, Kubernetes readiness probes, or quick manual diagnostics when troubleshooting connectivity issues between services.

Method and Path

GET /api/v1/health/

Parameters

None. The endpoint takes no query parameters, path parameters, or request body.

Response

status
string
Overall health status of the service. Possible values:
  • "healthy" — all components passed their checks
  • "degraded" — one or more components returned an error; the API is still running but may produce incomplete responses
version
string
API version string. Current value: "1.0.0".
components
object
A map of component names to their individual status objects. The current implementation checks two components:

Examples

curl http://localhost:8000/api/v1/health/

Health Check Logic

The endpoint is implemented in backend/app/api/v1/endpoints/health.py. It runs two independent checks sequentially. If either check raises an exception, overall_status is set to "degraded" and the exception message is captured in the details field of that component — the other check still runs.
# Check 1: PostgreSQL connectivity
try:
    with engine.connect() as conn:
        pass  # Connection succeeds → status "ok"
    components["database"] = ComponentStatus(status="ok")
except Exception as e:
    components["database"] = ComponentStatus(status="error", details=str(e))
    overall_status = "degraded"

# Check 2: Gemini LLM client availability
try:
    llm = get_llm()
    if not llm:
        raise ValueError("No LLM instance")
    components["llm"] = ComponentStatus(status="ok")
except Exception as e:
    components["llm"] = ComponentStatus(status="error", details=str(e))
    overall_status = "degraded"
The HTTP response status code is always 200 OK regardless of status — parse the status field in the JSON body to determine whether the service is fully operational.
You can use this endpoint as a readiness probe in container orchestration environments:Docker Compose — add a healthcheck to the backend service in docker-compose.yml:
healthcheck:
  test: ["CMD", "curl", "-f", "http://localhost:8000/api/v1/health/"]
  interval: 30s
  timeout: 5s
  retries: 3
  start_period: 15s
Kubernetes — add a readinessProbe to the backend pod spec:
readinessProbe:
  httpGet:
    path: /api/v1/health/
    port: 8000
  initialDelaySeconds: 15
  periodSeconds: 30
  failureThreshold: 3
If the database component reports "error", the backend will fall back to SQLite for conversation persistence, but cost metrics (which require PostgreSQL’s audit_logs table) will not be recorded.

Build docs developers (and LLMs) love