Inspiration
Ever since I was young, I have loved fitness. But I couldn't go to a gym because of my parents' restrictions and because we couldn't afford the fees. I also didn't know the answers to simple questions: Which local foods are good for my health? Which exercises should I do right now? How can I stay fit at home, without a gym?
I realized many students and families have the same problem. They don't need an expensive membership. They need clear guidance that fits their food, their budget, and their space. So I built FitAI: an AI coach that helps you stay fit without going to the gym.
What it does
- Meal log: type what you ate, like
2 roti, 150g daal, 1 egg, and FitAI estimates calories and protein, including common local foods. - Home workouts: pick how much time you have, and get a simple plan with a checklist, a progress bar, and a rest timer.
- AI coach: ask questions like "What should I eat after a workout?" and get short, friendly guidance.
- Interactive dashboard: a macros chart, a 7-day calorie chart, and a breakdown of where today's calories came from.
- Age-aware safety: the app asks for an age group. For users under 18, the coach never gives weight-loss or calorie-target advice.
- Privacy controls: old data is deleted automatically, and users can download or delete everything.
How I built it
The backend is Python with FastAPI and a SQLite database. The website uses HTML, CSS, and JavaScript with Chart.js for the interactive charts. The Gemini API reads meal descriptions and writes the coach's answers.
One design rule shaped the whole project: the AI should not invent numbers. Calories come from a nutrition table, and the AI only turns text into foods and portions. For each food item:
$$\text{kcal} = \frac{\text{grams}}{100} \times \text{kcal per 100 g}$$
For example, 2 rotis of about \( 80\,\text{g} \) at \( 297\,\text{kcal}/100\,\text{g} \) gives \( \frac{80}{100} \times 297 \approx 238\,\text{kcal} \).
Workouts come from simple rules (time, level, equipment), not from the AI, so they stay predictable and safe. Each user also has a daily limit on AI questions, so the free API quota lasts. The code is on GitHub and the site is deployed on Vercel. I built it with help from AI assistants for code and guidance, and I tested and designed the app myself.
Challenges I ran into
- Free limits: the free AI tier has usage caps, so I added per-user and total daily limits.
- Changing AI models: the model name I first used was about to be retired, and I got
502errors. I learned to read the server logs, and I switched to the "latest" model name. - Honest nutrition data: calorie numbers are only estimates, since portions and cooking vary. I used a nutrition table instead of AI guesses and labeled every value as an estimate.
- Safety: health advice can hurt people, especially teenagers, so I added age-based rules and a clear "not medical advice" note.
- Deploying for the first time: I learned Git, GitHub, and hosting. I also found that free serverless hosting doesn't keep files, so saved data needs a hosted database.
What I learned
- How to build and connect a FastAPI backend, a database, and a web page.
- That a good AI app splits the work: AI for language, normal code for numbers and safety rules.
- That free tools have limits, and a real product has to plan for them.
- How to debug from logs, and how to ship a project with GitHub and Vercel.
What's next
- Check every nutrition value against USDA FoodData Central and add many more Pakistani and South Asian dishes.
- Add Urdu support and local portion sizes, such as a roti or a katori.
- Move to a hosted database, add optional login so data syncs across devices, and make the app installable on phones. -making strong data base and signup