AI-assisted workout and meal planning with session tracking. Built with Next.js App Router, TypeScript, Tailwind, and MongoDB/Cosmos.
flowchart LR
browser[Browser] --> next[Next.js App Router]
next --> ui[Pages + Client Components]
next --> api[API Routes]
api --> db[(MongoDB / Cosmos)]
api --> ai[AI Providers]
ui --> analytics[GA4 + GTM]
- Use Node.js 20 (nvm recommended).
nvm use 20.19.6
- Install dependencies.
npm install
- Configure environment variables.
cp .env.example .env- Fill in required values.
- Start the dev server.
npm run dev
Required:
MONGODB_URI- MongoDB connection string.JWT_SECRET- secret used to sign auth cookies.
Optional (AI providers):
GEMINI_API_KEYOPENROUTER_API_KEYMISTRAL_API_KEYGROQ_API_KEYCEREBRAS_API_KEY
Optional (analytics):
NEXT_PUBLIC_GA_IDNEXT_PUBLIC_GTM_ID
Optional (OAuth):
GOOGLE_CLIENT_IDGOOGLE_CLIENT_SECRETFACEBOOK_CLIENT_IDFACEBOOK_CLIENT_SECRETAPPLE_CLIENT_IDAPPLE_CLIENT_SECRET
Auth:
POST /api/auth/signup- create account and set auth cookie.POST /api/auth/login- authenticate and set auth cookie.POST /api/auth/logout- clear auth cookie.GET /api/auth/oauth/:provider- start OAuth flow.GET /api/auth/oauth/:provider/callback- OAuth callback handler.
User:
GET /api/me/profile- fetch profile.PUT /api/me/profile- update or create profile.GET /api/me/settings- fetch settings.PUT /api/me/settings- update settings.POST /api/me/avatar- upload profile avatar.PUT /api/me/password- change password.
Plans:
GET /api/plans/active- fetch active workout/diet plan.POST /api/plans/generate-workout- generate workout plan.POST /api/plans/workout-image- regenerate exercise image.POST /api/plans/generate-diet- generate diet plan.POST /api/plans/diet-image- regenerate diet image.
AI models:
GET /api/ai-models- list AI models.POST /api/ai-models- create AI model config.GET /api/ai-models/:id- get model details.PUT /api/ai-models/:id- update model.DELETE /api/ai-models/:id- delete model.
Messages:
GET /api/messages- list AI messages.POST /api/messages- send message.POST /api/messages/rate- rate a response.
Workout sessions:
POST /api/workout-sessions- create a workout session.GET /api/workout-sessions- list sessions.GET /api/workout-sessions/:id- get a session.PATCH /api/workout-sessions/:id- update a session.
npm run dev- local dev server.npm run build- production build.npm run start- serve production build.npm run lint- lint.npm run test- Jest unit/API tests.npm run test:watch- Jest watch mode.npm run e2e- Playwright end-to-end tests (starts dev server).npm run e2e:ui- Playwright UI mode.
- Playwright uses a local dev server and sets
E2E_MOCKS=trueto avoid DB dependencies in some flows. - Install Playwright browsers once:
npx playwright install.