Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Pierrot-01/Hackathon_epis_2026/llms.txt

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

The /api/stats endpoint aggregates student risk classifications into a compact summary used by the admin.html dashboard to populate the four top-level statistics cards: total students, high risk count, medium risk count, and low risk count. It is designed to be fast regardless of dataset size.

GET /api/stats

Returns global risk-level counts and percentages for all students in the dataset. No parameters are required.

Caching Behavior

The endpoint checks whether the in-memory session cache (_resultados_cache) is populated:
  • Cache available — reads nivel_riesgo directly from the cached EstudianteResultado objects. This is essentially instantaneous.
  • Cache empty — loads the full dataset from data/estudiantes.json and runs clasificar_estudiante() on each record synchronously, without calling the AI service. This makes the cold-start path significantly faster than GET /api/estudiantes, at the cost of not populating the AI explanation cache.
In both cases the counts and percentages returned are consistent with the classifier’s current rule set.

Response Fields

total
integer
required
Total number of student records in the dataset. Example: 20.
alto
integer
required
Count of students classified as 🔴 high risk.
medio
integer
required
Count of students classified as 🟡 medium risk.
bajo
integer
required
Count of students classified as 🟢 low risk.
insuficiente
integer
required
Count of students classified as ⚪ insufficient data — too many variables were null to produce a meaningful risk level.
pct_alto
float
required
Percentage of students at 🔴 high risk, rounded to one decimal place. Calculated as alto / total * 100. Returns 0 if total is 0.
pct_medio
float
required
Percentage of students at 🟡 medium risk, rounded to one decimal place.
pct_bajo
float
required
Percentage of students at 🟢 low risk, rounded to one decimal place.

Example

curl http://localhost:8000/api/stats
{
  "total": 20,
  "alto": 4,
  "medio": 7,
  "bajo": 7,
  "insuficiente": 2,
  "pct_alto": 20.0,
  "pct_medio": 35.0,
  "pct_bajo": 35.0
}
pct_alto + pct_medio + pct_bajo will not equal 100% when insuficiente > 0, because ⚪ students are counted in total but not included in any percentage field.

Dashboard Integration

The admin.html frontend calls GET /api/stats on page load to populate the summary statistics cards at the top of the administration view. Because the stats endpoint uses the classifier-only fast path when the cache is cold, these cards load quickly even on a fresh server start — before the full AI-enriched student list has been fetched.

GET /api/health

The health endpoint provides a simple liveness check for the server. It is typically called on startup to confirm the API is running before the frontend attempts any data requests. No parameters are required.

Response

{
  "status": "ok",
  "version": "1.0.0"
}
status
string
required
Always "ok" when the server is running and able to handle requests.
version
string
required
Current API version string. Value: "1.0.0".

Example

curl http://localhost:8000/api/health
This endpoint is safe to call repeatedly — it performs no I/O and returns in under 1 ms. Use it for:
  • Startup probes: confirm the server is ready before loading the dashboard.
  • Health monitoring: integrate with process managers (e.g., systemd, PM2) or uptime monitors to detect server crashes.
  • Development: quickly verify the API is reachable after a code change or restart.

Build docs developers (and LLMs) love