- Clone the repository:
git clone https://github.com/felixrowen/node-lcjs-openai.git
cd node-lcjs-openai
- Install dependencies:
npm install
- Set up environment variables:
Create a
.env
file in the root directory:
NODE_ENV=dev
PORT=8080
OPENAI_API_KEY=your_openai_api_key_here
Start the development server with hot reload:
npm run dev
The API will be available at http://localhost:8080
Build and start the production server:
npm start
POST /create
Creates a new workout plan generation job.
Request Body:
{
"goal": "fat_loss",
"level": "beginner",
"days_per_week": 3,
"session_minutes": 45,
"equipment": [
"bodyweight",
"dumbbells"
],
"constraints": [
"knee"
]
}
Response:
{
"id": "7c20a3a1-eacc-47ba-ad92-3f1d9b43b308"
}
GET /:id
Retrieves the generated workout plan by job ID.
Response:
{
"status": "done",
"plan": {
"overview": "This workout plan is designed for beginners focusing on fat loss while being mindful of knee constraints. Each session incorporates bodyweight and dumbbell exercises that are safe and effective.",
"schedule": [
{
"day": "Day 1",
"focus": "Full Body Strength",
"session_minutes": 45,
"exercises": [
{
"name": "Bodyweight Squats",
"sets": 3,
"reps": "10-12"
},
{
"name": "Dumbbell Chest Press",
"sets": 3,
"reps": "10-12"
},
{
"name": "Standing Dumbbell Shoulder Press",
"sets": 3,
"reps": "10-12"
},
{
"name": "Glute Bridges",
"sets": 3,
"reps": "12-15"
},
{
"name": "Plank",
"sets": 3,
"time": "30 seconds"
}
],
"notes": [
"Focus on form over speed.",
"Rest for 30-60 seconds between sets.",
"Modify exercises as needed to avoid knee discomfort."
]
},
{
"day": "Day 2",
"focus": "Cardio and Core",
"session_minutes": 45,
"exercises": [
{
"name": "Marching in Place",
"sets": 3,
"time": "5 minutes"
},
{
"name": "Seated Leg Lifts",
"sets": 3,
"reps": "10-12"
},
{
"name": "Dumbbell Side Bends",
"sets": 3,
"reps": "10-12 each side"
},
{
"name": "Wall Push-Ups",
"sets": 3,
"reps": "8-10"
},
{
"name": "Dead Bugs",
"sets": 3,
"reps": "10-12"
}
],
"notes": [
"Keep movements controlled to protect the knees.",
"Stay hydrated throughout the session.",
"Adjust the intensity based on your comfort level."
]
},
{
"day": "Day 3",
"focus": "Lower Body and Flexibility",
"session_minutes": 45,
"exercises": [
{
"name": "Chair Squats",
"sets": 3,
"reps": "10-12"
},
{
"name": "Dumbbell Deadlifts",
"sets": 3,
"reps": "10-12"
},
{
"name": "Calf Raises",
"sets": 3,
"reps": "12-15"
},
{
"name": "Side Leg Raises",
"sets": 3,
"reps": "10-12 each side"
},
{
"name": "Seated Forward Bend Stretch",
"sets": 1,
"time": "2 minutes"
}
],
"notes": [
"Focus on slow, controlled movements.",
"Incorporate stretching to improve flexibility.",
"Listen to your body and modify as necessary."
]
}
],
"general_tips": [
"Warm up for 5-10 minutes before each session.",
"Cool down and stretch after each workout.",
"Maintain a balanced diet to support your fat loss goals.",
"Stay consistent with your workouts for the best results."
]
}
}