A routine in Blackterz is a named, ordered collection of exercises. Each exercise slot in a routine carries its own planned sets, reps, weight, and rest time. Users can own up to 4 active personalized routines at a time; the database also ships with seeded recommended routines that are visible to every user. Deleting a routine is a soft-delete — the row is markedDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Blackterz2/Proyecto_5to_Semestre/llms.txt
Use this file to discover all available pages before exploring further.
activa = false so that training history referencing that routine is never lost.
Listing Routines
GET /api/rutinas returns all active routines for the authenticated user, ordered by creation date descending. The list response is lightweight — it does not include the nested exercises array, only the routine metadata and a computed total_ejercicios count.
Routines with
es_recomendada = true are seeded by the database and appear in every user’s list. They count toward the user’s view but not toward the 4-routine personal limit (the contarRutinasUsuario query filters es_recomendada = FALSE).Creating a Routine
POST /api/rutinas/crear creates a new routine and optionally attaches an initial exercise list.
Extract the user from the JWT
usuario_id is read from req.usuario.usuario_id (injected by verificarToken). It is never taken from the request body to prevent ID spoofing.Validate input
nombre must be a non-empty string. descripcion is optional. If ejercicios_ids is provided it must be a non-empty array of numeric IDs.Enforce the 4-routine limit
contarRutinasUsuario(usuario_id) runs SELECT COUNT(*) FROM rutinas WHERE usuario_id = ? AND activa = TRUE AND es_recomendada = FALSE. If the result is >= 4, the server returns 403 Forbidden.Insert the routine
insertarRutina(usuario_id, nombre, descripcion) inserts the row and returns { id, nombre, descripcion, usuario_id }.Request body
The routine’s display name, e.g.
"Push Day".Optional free-text description of the routine.
Optional array of exercise IDs to attach at creation time. Order in the array becomes the exercise order in the routine.
Viewing a Routine (with Exercises)
GET /api/rutinas/:id returns a single routine with its full nested exercises array. The model performs a single LEFT JOIN across three tables (rutinas → ejercicios_rutinas → ejercicios), restructuring the flat SQL result into a hierarchical JSON object.
Sample response
The routine’s primary key.
The routine’s display name.
Ordered list of exercises. Empty array if no exercises have been assigned yet.
Position of this exercise within the routine (1-indexed, ascending).
Planned number of sets for this exercise in the routine.
Planned repetitions per set.
Planned weight in kilograms.
Editing a Routine
PUT /api/rutinas/:id updates a routine’s name and description, and optionally replaces its entire exercise list in a single atomic transaction.
New display name for the routine.
Updated description. Pass
null to clear it.If provided, replaces all current exercises with this ordered list. The model runs
DELETE on the existing ejercicios_rutinas rows then re-inserts the new IDs with sequential orden values, all inside a BEGIN / COMMIT / ROLLBACK transaction.How exercise replacement works
How exercise replacement works
The model function If any insert fails, the whole transaction is rolled back — the routine retains its previous exercise list.
reemplazarEjerciciosDeRutina wraps the delete + insert in a MySQL transaction:GET /api/rutinas/:id response).
Deleting a Routine (Soft-Delete)
DELETE /api/rutinas/:id sets activa = FALSE on the routine row. The routine disappears from the user’s list (because all queries filter WHERE activa = TRUE) but the row — and all associated training sessions — remain in the database.
Training history is linked to
rutinas.id via a foreign key on sesiones_entrenamiento.rutina_id. Soft-deleting a routine preserves the integrity of all past sessions — they still show the routine name in the history view because the sesionModel uses a LEFT JOIN that returns the row even when activa = FALSE.Recommended Routines
The database is seeded with routines wherees_recomendada = TRUE. These are created either via the seed.sql file or automatically by the onboarding flow (POST /api/usuarios/onboarding) when a new beginner user requests a recommendation. Recommended routines are visible to the user who owns them but do not count toward the 4-routine personal limit.
Bajo Impacto
Assigned to beginners with BMI ≥ 25. Focuses on mobility and low-impact exercises.
Fuerza Base
Assigned to male beginners with BMI < 25. Upper-body strength focus.
Tonificación
Assigned to female beginners with BMI < 25. Lower-body and glute focus.
API Reference — Routines
View full request/response schemas, error codes, and live playground for all
/api/rutinas endpoints.