A training session in Blackterz is a complete snapshot of one workout: which routine was used, which exercises were performed, and the exact weight, reps, and completion status of every individual set. Sessions are written to three database tables in a single SQL transaction so a partial write can never occur. Once saved, sessions are permanent — they cannot be edited or deleted — forming a reliable training history.Documentation 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.
Starting a Session (Frontend Flow)
The Blackterz frontend pre-fills the training form from the routine’s planned data before the user touches a single input.Load routine exercises
When the user selects a routine,
GET /api/rutinas/:id returns the routine with its full nested exercises array. The frontend renders a card per exercise, each with one input row per planned set.Pre-fill from last session
GET /api/sesiones/ultima/:rutina_id is called immediately after loading the routine. If a previous session exists, each set row shows the previous weight and reps in a grey hint span (anterior-valor) — the foundation of progressive overload.User edits and checks sets
The user updates weights and reps freely, checks each set as completed, and can add extra exercises or additional set rows at any time without modifying the base routine.
Auto-save draft to localStorage
Every input change, checkbox toggle, and set addition triggers
guardarEstadoEntrenamiento(), which serializes the entire session state to localStorage under the key entrenamiento_draft. If the browser is closed or the page is refreshed, the session is fully restored on next load via restaurarEstadoEntrenamiento().Recording a Session
POST /api/sesiones is the core write endpoint. The controller extracts usuario_id from the JWT (never from the body) and validates the payload before handing it to the model.
Anti-spoofing
usuario_id, the model only ever sees the one from the verified JWT.
Request body
ID of the routine this session is based on.
Date of the workout in
YYYY-MM-DD format.Optional free-text notes for the overall session.
Total session duration in minutes, recorded by the in-app stopwatch.
Array of exercise objects. Must contain at least one item.
ID of the exercise from the catalog.
Per-exercise notes (e.g. “Keep elbow tucked”).
Array of set objects. Must contain at least one item.
Set number (1-indexed).
Repetitions performed in this set.
Weight in kilograms. Defaults to
0 if omitted.Whether the set was marked as completed by the user.
Sample request body
Response (201)
The 3-Table Atomic Transaction
The modelguardarSesionCompleta uses pool.getConnection() + beginTransaction / commit / rollback to guarantee that all three writes succeed or none of them persist.
Transaction flow — sesionModel.js
Transaction flow — sesionModel.js
sesiones_entrenamiento
One row per workout. Stores
usuario_id, rutina_id, fecha, notas, and duracion_minutos.sesion_ejercicios
One row per exercise performed. Foreign key to
sesiones_entrenamiento. Stores per-exercise notas.sesion_series
One row per set. Foreign key to
sesion_ejercicios. Stores numero_serie, repeticiones, peso, and completada.Session History
GET /api/sesiones returns all training sessions for the authenticated user, ordered by date descending. This powers the history table on the profile page.
Sum of
peso × repeticiones for all completed sets in the session. Used for the weekly volume chart.Count of completed sets across all exercises in the session.
Session Detail
GET /api/sesiones/:id returns the full hierarchical detail of a single session — all exercises and all sets. If the session does not belong to the authenticated user, the server returns 404 (not 403) to avoid revealing that the session ID exists.
Last Session for Progressive Overload
GET /api/sesiones/ultima/:rutina_id finds the most recent session for a given routine and returns the series grouped by ejercicio_id. The frontend uses this to pre-fill weight inputs and show grey hint values before a new workout begins.
data is null and a message field explains why — the frontend silently skips the hint injection.
API Reference — Sessions
View full request/response schemas, error codes, and live playground for all
/api/sesiones endpoints.