FitCoach AI is a full-stack workout tracking web app built for the 24-hour take-home assignment. It lets a user log workouts, review workout history and stats, receive AI-generated motivation grounded in real activity data, and chat with an AI fitness coach.
The assignment asked for a web app where a user can:
- Log daily workouts
- View workout history and basic stats
- Get AI-generated personalized motivational messages based on actual workout data
- Ask fitness-related questions to an AI chatbot
This repository implements those core requirements with a Next.js frontend, Express backend, MongoDB persistence, Firebase authentication, and OpenRouter-powered AI responses.
- Frontend: Next.js 16, React 19, TypeScript, Tailwind CSS v4
- Backend: Node.js, Express 5, Mongoose
- Database: MongoDB Atlas
- Authentication: Firebase Auth + Firebase Admin
- AI integration: OpenRouter LLM API
- Deployment target:
- Frontend: Vercel
- Backend: Render
- Database: MongoDB Atlas
Implemented:
- Workout form with 5 activity options:
- Running
- Yoga
- Cycling
- Gym
- Swimming
- Duration in minutes
- Date and time input with the current time as default
- Past dates allowed
- Workout data saved in MongoDB
- Logged workouts shown in reverse chronological order
- Paginated workout history API and UI
Implemented stats based on logged workouts:
- Current streak
- Workouts this week
- Most frequent activity
- Total workout minutes
Behavior:
- Dashboard data refreshes immediately after a workout is logged
- No full page refresh is required
Implemented:
- Backend endpoint to generate a motivation message from actual user workout data
- Prompt context includes streak, workout frequency, last workout timing, activity mix, and consistency patterns
- Daily motivation is stored and reused for the current day
Important note:
- The assignment mentions a
"Get AI Motivation"button - In this implementation, the motivation is automatically generated and shown on the dashboard instead of requiring a separate click
- The message is still personalized using the user's real data, which was the main scoring requirement
Implemented:
- Chat UI for user fitness questions
- User message plus recent chat history sent as AI context
- Scrollable conversation in the UI
- Chat history persisted in MongoDB so it survives refresh
- Mobile-responsive UI
- Persisted chat history
- Coach tone selection
- Real-time dashboard refresh after logging workouts
- Loading and error states
- Gamification extras: points, badges, leaderboard, tournament view
- Firebase email/password and Google sign-in
- First-login profile setup
- Unique username validation
- Avatar upload or preset avatar support
- Weekly goal tracking
- Coach tone preference
- Daily motivation card
- AI coach chat
- Workout history tab
- Rank and leaderboard UI
workout/
|-- backend/
| |-- controllers/
| |-- middleware/
| |-- models/
| |-- routes/
| |-- utils/
| |-- app.js
| |-- server.js
| `-- build.sh
|-- frontend/
| |-- public/
| |-- src/app/
| |-- src/components/
| |-- src/context/
| |-- src/lib/
| `-- src/types/
`-- README.md
All protected routes require a Firebase ID token in:
Authorization: Bearer <token>Available endpoints:
GET /api/healthGET /api/users/mePOST /api/users/profilePOST /api/workoutsGET /api/workouts?page=1&limit=10GET /api/statsPOST /api/ai/motivationPOST /api/chatGET /api/chat/history
Create backend/.env and add:
PORT=5000
MONGO_URI=
FIREBASE_PROJECT_ID=
FIREBASE_PRIVATE_KEY=
FIREBASE_CLIENT_EMAIL=
OPENROUTER_API_KEY=Install and run:
cd backend
npm install
npm run devCreate frontend/.env.local and add:
NEXT_PUBLIC_FIREBASE_CONFIG={"apiKey":"...","authDomain":"...","projectId":"...","storageBucket":"...","messagingSenderId":"...","appId":"..."}
NEXT_PUBLIC_API_BASE_URL=http://localhost:5000/apiInstall and run:
cd frontend
npm install
npm run devOpen:
http://localhost:3000- Frontend: Vercel
- Backend: Render
- Database: MongoDB Atlas
- Frontend app:
TBD - Backend API:
TBD - GitHub repository:
TBD
- Repository demo video file: frontend/Video/working_video.mp4
- Walkthrough video link:
TBD - Optional short product demo link:
TBD
Deployment and video links are still placeholders because publishing credentials and final hosted URLs were not available in this workspace.
- MongoDB was used instead of Supabase because the current backend is structured around Express + Mongoose and this kept development faster within the time limit.
- Daily motivation is persisted per user per day to avoid repeated LLM calls and to keep the dashboard stable during a single day.
- Avatar uploads are stored as data URLs for simplicity in the assignment scope instead of using object storage.
- The AI motivation flow is automatic on dashboard load instead of being behind a separate button. This is a UI tradeoff, but the generated content still uses real workout context.
- The backend includes fallback behavior so the app remains usable during local development if the AI provider is unavailable.
Completed locally:
- Frontend:
npm run lint - Frontend:
npm run build - Backend:
node --checkon backend source files