AirGuide includes a TensorFlow.js neural network that predicts route congestion based on the current hour and a route’s historical usage patterns (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/luiss811/Backend-Airguide/llms.txt
Use this file to discover all available pages before exploring further.
contador_usos). The model produces a score between 0 and 1 — a score above 0.7 is considered congested. Three endpoints expose this functionality: one for checking a single route, one for generating a full heatmap overlay, and one admin endpoint for retraining the model when usage data has grown significantly.
POST /api/rutas/check-congestion
Predicts whether a specific route is congested at the current hour. No authentication is required.A score above
0.7 is classified as congested. The model uses the server’s current local hour (0–23) as its primary input alongside learned usage patterns for the route.Request body
The
id_ruta of the route to evaluate.Response — 200 OK
true if the predicted congestion score exceeds 0.7, false otherwise.Raw AI prediction score between 0 and 1. Higher values indicate heavier predicted congestion.
The current hour (0–23) used as input to the model. Useful for debugging or logging.
Error responses
| Status | Body | Cause |
|---|---|---|
400 | { "error": "Falta id_ruta" } | id_ruta was not included in the request body. |
500 | { "error": "Error analizando congestión" } | Model inference failed. |
Example
GET /api/rutas/heatmap
Returns congestion scores and waypoint paths for all active internal routes. Intended for rendering a color-coded congestion heatmap overlay on the campus map. No authentication is required. The server evaluates the AI model for every activeinterna route concurrently using the current hour, then returns the scores alongside each route’s waypoints formatted for direct use with mapping libraries.
Response — 200 OK
Array of objects, one per active internal route.Route identifier.
AI congestion score between 0 and 1 for this route at the current hour.
Ordered array of waypoints derived from the route’s
RutaDetalle records.Example
POST /api/analytics/train-congestion
Triggers retraining of the TensorFlow.js congestion model using all current route usage data. Admin access is required.Retrain the model after a significant volume of new route usage data has accumulated — for example, after a new semester begins or after deploying new routes. Retraining on sparse data produces an unreliable model. The returned
loss value indicates training accuracy; lower is better.Request headers
Bearer token for an admin account:
Bearer <token>.Response — 200 OK
Confirmation string:
"Modelo de congestión entrenado con éxito".Final training loss value. Lower values indicate a better-fitted model.
