Skip to main content

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.

Routes (rutas) describe pre-defined navigation paths on campus. Each route connects an origin to a destination using one of four location types — edificio, salon, cubiculo, or evento — and carries an ordered list of waypoints (RutaDetalle) that a client renders as turn-by-turn instructions. Routes can be internal (on-campus) or external.

GET /api/rutas

Returns all routes matching the supplied filters. Waypoints are included and ordered by their orden field.

Query parameters

tipo
string
Filter by route type. Accepted values: interna, externa.
activo
string
Filter by active status. Accepted values: "true", "false".
origen_tipo
string
Filter by origin location type. Accepted values: edificio, salon, cubiculo, evento.
destino_tipo
string
Filter by destination location type. Accepted values: edificio, salon, cubiculo, evento.

Response — 200 OK

Array of route objects, each including a detalles array of waypoints.
id_ruta
integer
Unique route identifier.
tipo
string
Route type: interna or externa.
origen_tipo
string
Origin location type: edificio, salon, cubiculo, or evento.
origen_id
integer
ID of the origin location in its respective table.
destino_tipo
string
Destination location type: edificio, salon, cubiculo, or evento.
destino_id
integer
ID of the destination location in its respective table.
tiempo_estimado
integer
Estimated travel time in minutes. May be null if not set.
contador_usos
integer
Number of times this route has been looked up via POST /api/rutas/find.
activo
boolean
Whether the route is active.
detalles
object[]
Ordered waypoints for the route.

Example

curl http://localhost:3001/api/rutas?tipo=interna&activo=true

GET /api/rutas/:id

Returns a single route by its id_ruta. Waypoints are included and ordered by orden.

Path parameters

id
integer
required
The id_ruta of the route to retrieve.

Response — 200 OK

A single route object with the same shape as described in GET /api/rutas.

Error responses

StatusBodyCause
404{ "error": "Ruta no encontrada" }No route exists with the given ID.

Example

curl http://localhost:3001/api/rutas/3

POST /api/rutas/find

Finds an active route by matching origin and destination type and ID. Use this endpoint to retrieve a route for real-time navigation rather than browsing all routes.
Every successful call to this endpoint increments the route’s contador_usos field by one. This counter drives the congestion prediction model — see POST /api/rutas/check-congestion.

Request body

origen_tipo
string
required
Origin location type: edificio, salon, cubiculo, or evento.
origen_id
integer
required
ID of the origin location in its respective table.
destino_tipo
string
required
Destination location type: edificio, salon, cubiculo, or evento.
destino_id
integer
required
ID of the destination location in its respective table.

Response — 200 OK

The matching active route object including its detalles array, with the same shape as described in GET /api/rutas.

Error responses

StatusBodyCause
400{ "error": "Se requieren origen y destino" }One or more required body fields are missing.
404{ "error": "No se encontró una ruta" }No active route matches the given origin/destination.

Example

curl --request POST \
  --url http://localhost:3001/api/rutas/find \
  --header 'Content-Type: application/json' \
  --data '{
    "origen_tipo": "edificio",
    "origen_id": 1,
    "destino_tipo": "salon",
    "destino_id": 12
  }'

POST /api/rutas

Creates a new route. You may optionally include waypoints (detalles) in the same request body.
Requires a valid admin Bearer token. Requests without a valid token or with a non-admin role are rejected.

Request headers

Authorization
string
required
Bearer token for an admin account: Bearer <token>.

Request body

tipo
string
required
Route type: interna or externa.
origen_tipo
string
required
Origin location type: edificio, salon, cubiculo, or evento.
origen_id
integer
required
ID of the origin location.
destino_tipo
string
required
Destination location type: edificio, salon, cubiculo, or evento.
destino_id
integer
required
ID of the destination location.
tiempo_estimado
integer
Estimated travel time in minutes.
activo
boolean
default:"true"
Whether the route should be active immediately.
detalles
object[]
Optional array of waypoints to create together with the route.

Response — 201 Created

The newly created route object including any supplied detalles, ordered by orden.

Example

curl --request POST \
  --url http://localhost:3001/api/rutas \
  --header 'Authorization: Bearer <admin-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "tipo": "interna",
    "origen_tipo": "edificio",
    "origen_id": 1,
    "destino_tipo": "salon",
    "destino_id": 5,
    "tiempo_estimado": 4,
    "detalles": [
      { "orden": 1, "instruccion": "Sal por la puerta principal", "latitud": 19.43260, "longitud": -99.13320 },
      { "orden": 2, "instruccion": "Gira a la derecha en el pasillo B", "latitud": 19.43280, "longitud": -99.13300 }
    ]
  }'

PUT /api/rutas/:id

Updates an existing route’s fields. Only the fields included in the request body are changed. Waypoints are not replaced by this endpoint — use POST /api/rutas/:id/detalles and DELETE /api/rutas/detalles/:id to modify waypoints individually.
Requires a valid admin Bearer token.

Path parameters

id
integer
required
The id_ruta of the route to update.

Request headers

Authorization
string
required
Bearer token for an admin account: Bearer <token>.

Response — 200 OK

The updated route object including its detalles, ordered by orden.

Example

curl --request PUT \
  --url http://localhost:3001/api/rutas/3 \
  --header 'Authorization: Bearer <admin-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "tiempo_estimado": 6,
    "activo": false
  }'

DELETE /api/rutas/:id

Permanently deletes a route and all of its associated waypoints.
Requires a valid admin Bearer token. Deletion is irreversible and cascades to all RutaDetalle records for the route.

Path parameters

id
integer
required
The id_ruta of the route to delete.

Request headers

Authorization
string
required
Bearer token for an admin account: Bearer <token>.

Response — 200 OK

message
string
Confirmation string: "Ruta eliminada".

POST /api/rutas/:id/detalles

Adds a single waypoint to an existing route.
Requires a valid admin Bearer token.

Path parameters

id
integer
required
The id_ruta of the route to add the waypoint to.

Request headers

Authorization
string
required
Bearer token for an admin account: Bearer <token>.

Request body

orden
integer
required
Step order for this waypoint. Lower values appear first.
instruccion
string
required
Navigation instruction displayed to the user at this step.
latitud
number
required
Latitude coordinate (decimal, up to 8 decimal places).
longitud
number
required
Longitude coordinate (decimal, up to 8 decimal places).

Response — 201 Created

The newly created RutaDetalle object.

Example

curl --request POST \
  --url http://localhost:3001/api/rutas/3/detalles \
  --header 'Authorization: Bearer <admin-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "orden": 3,
    "instruccion": "Sube las escaleras al piso 2",
    "latitud": 19.43290,
    "longitud": -99.13310
  }'

DELETE /api/rutas/detalles/:id

Permanently removes a single waypoint from its route.
Requires a valid admin Bearer token.

Path parameters

id
integer
required
The id_detalle of the waypoint to delete.

Request headers

Authorization
string
required
Bearer token for an admin account: Bearer <token>.

Response — 200 OK

message
string
Confirmation string: "Detalle eliminado".

Build docs developers (and LLMs) love