When the "Generate Workout" button is clicked in the onboarding section, the application makes two sequential POST requests:
Endpoint: POST /api/onboarding
{
"userId": "user_123",
"goal": "fat_loss",
"experience": "beginner",
"daysPerWeek": 3,
"minutesPerSession": 60,
"equipment": ["bodyweight", "dumbbells"],
"injuries": "Lower back pain when bending",
"location": "home"
}Endpoint: POST /api/ai/generate-plan
{
"userId": "user_123"
}"fat_loss"- Fat Loss"hypertrophy"- Muscle Growth"strength"- Strength"returning"- Return to Training"general_health"- General Health
"beginner"- Beginner"three_to_twelve_months"- 3–12 months"one_to_three_years"- 1–3 years"three_years_plus"- 3+ years
"bodyweight"- Bodyweight"bands"- Resistance Bands"dumbbells"- Dumbbells"barbell"- Barbell"machines"- Machines
"home"- Home"gym"- Gym
daysPerWeek: Integer between 1-7minutesPerSession: Integer between 30-180 (increments of 15)equipment: Array with at least one iteminjuries: Optional string, max 500 characters, no emojisuserId: Required string identifier
{
"userId": "clx123abc456def",
"goal": "hypertrophy",
"experience": "one_to_three_years",
"daysPerWeek": 4,
"minutesPerSession": 75,
"equipment": ["dumbbells", "barbell", "machines"],
"injuries": "Previous knee injury, avoid deep squats",
"location": "gym"
}The AI will generate workout plans in English with this structure:
{
"description": "This is a FBx4 program designed for muscle growth, adapted for gym training with dumbbells, barbell, machines. Each session includes compound movements and progressive overload within 75 minutes per session.",
"split": "FBx4",
"sessions": [
{
"dayOfWeek": 1,
"title": "Upper Body Strength (Gym)",
"estMinutes": 70,
"items": [
{
"name": "Barbell Bench Press",
"equipment": "barbell",
"sets": 4,
"reps": [8,8,6,6],
"notes": "Control the descent, full range of motion.",
"reference": "https://www.youtube.com/watch?v=VIDEO_ID"
}
]
}
],
"constraints": {
"minutesPerSession": 75,
"injuryNotes": "Previous knee injury, avoid deep squats"
},
"meta": {
"goal": "hypertrophy",
"experience": "one_to_three_years",
"location": "gym",
"equipment": ["dumbbells", "barbell", "machines"]
}
}This is a Next.js project bootstrapped with create-next-app.
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Inter, a font optimized for user interfaces.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.