Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/jaimegayo/KERNDOCUMENTATION/llms.txt

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

KERN’s onboarding flow is linear by design: register to get a token, complete the quiz to generate a routine, then start training. The steps below walk you through the full sequence using real API calls. Every protected endpoint requires the Authorization: Bearer <token> header returned in step 1.
All examples below target the production API hosted on Vercel. Replace the base URL with http://localhost:8002 if you are running the backend locally.
1

Register and get your access token

Send a POST /register request with your username, email, and password. The API hashes the password with SHA-256, creates a user record, and returns a signed JWT immediately — no separate login step needed.
curl --request POST \
  --url https://your-kern-api.vercel.app/register \
  --header 'Content-Type: application/json' \
  --data '{
    "username": "alex",
    "email": "alex@example.com",
    "password": "strongpassword123"
  }'
Save the accessToken value. You will pass it as a Bearer token in every subsequent request. Tokens expire after 30 minutes — call POST /login with your email and password to refresh.
If the username or email is already taken, the API returns HTTP 400 with "El usuario o email ya existe".
2

Complete the fitness quiz

Send a POST /users/complete-quiz with your chosen routine type. This sets has_completed_quiz to true on your user record and triggers automatic routine generation: the backend reads ROUTINE_CONFIGS for the selected type, queries exercises_gym_id.json to select one exercise per movement pattern, and writes RoutineExercise rows to the database.Available routine values:
ValueExercises generated
"Full Body"5 exercises — horizontal push, vertical pull, squat, vertical push, hip hinge
"PPL (Push Pull Leg)"8 exercises — chest, upper chest, shoulders, back (vertical + horizontal), biceps, quads, hamstrings
"Torso-Pierna"6 exercises — chest (two patterns), back (two patterns), squat, hip hinge
curl --request POST \
  --url https://your-kern-api.vercel.app/users/complete-quiz \
  --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' \
  --header 'Content-Type: application/json' \
  --data '{
    "assigned_routine": "Full Body"
  }'
The assigned_routine string must match one of the three values exactly, including capitalisation and parentheses. An unrecognised value is saved to the user record but no exercises will be generated.
3

Fetch your generated routine

Retrieve all routines for the authenticated user with GET /users/my-routines. The response is an array of routine objects, each containing its id, name, creation timestamp, and a list of exercises with their default series (three sets at 0 kg × 10 reps).
curl --request GET \
  --url https://your-kern-api.vercel.app/users/my-routines \
  --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
Note the routine id — you will use it to start a workout in the next step.
4

Start a workout and view historical suggestions

Before recording a session, fetch the detailed routine view with GET /routines/{id}. This endpoint enriches each series with data from your most recent WorkoutSession for that routine: prev_kilos and prev_reps are numeric values for pre-filling input fields; anterior is a human-readable string (e.g. "60.0kg x 8") shown as a visual suggestion.
curl --request GET \
  --url https://your-kern-api.vercel.app/routines/7 \
  --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
On your very first session there is no history yet, so anterior will be "--" and both prev_kilos and prev_reps will be 0. Complete the workout to establish your baseline for next time.
5

Finish the workout and save your session

When all exercises are done, send POST /workouts/finish. Include the routine name, duration in seconds, total volume (kilograms × repetitions summed across all completed sets), step count recorded by the device sensor, and a data_json snapshot of every exercise and series.The data_json array becomes the source of truth for prev_kilos and prev_reps in all future sessions for this routine.
curl --request POST \
  --url https://your-kern-api.vercel.app/workouts/finish \
  --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' \
  --header 'Content-Type: application/json' \
  --data '{
    "routine_name": "Mi Rutina Full Body Inicial",
    "duration_seconds": 3600,
    "total_volume": 4200.0,
    "steps": 812,
    "data_json": [
      {
        "name": "Bench Press",
        "series": [
          { "numSerie": 1, "kilos": 60.0, "reps": 8 },
          { "numSerie": 2, "kilos": 62.5, "reps": 7 },
          { "numSerie": 3, "kilos": 62.5, "reps": 6 }
        ]
      },
      {
        "name": "Pull-Up",
        "series": [
          { "numSerie": 1, "kilos": 0.0, "reps": 10 },
          { "numSerie": 2, "kilos": 0.0, "reps": 9 },
          { "numSerie": 3, "kilos": 0.0, "reps": 8 }
        ]
      }
    ]
  }'
The session is now saved to workout_sessions. The next time you call GET /routines/7, each series will reflect the kilos and reps you just submitted.

What’s next

Architecture

Understand how the FastAPI backend, Android client, and PostgreSQL schema fit together.

API reference

Full endpoint documentation including avatar updates, username changes, and workout history.

Build docs developers (and LLMs) love