NutriAgenda AI Project
This document details the development journey of NutriAgenda AI, from its conception to technical implementation and the lessons learned during the Hackathon.
Inspiration
The inspiration for NutriAgenda AI was born from the difficulty many people face when trying to maintain a healthy routine: the lack of a clear and personalized plan. Often, generic diets do not consider biological individuality, and hiring constant professional guidance can be expensive.
We wanted to create a tool that democratized access to quality health planning, using the power of Artificial Intelligence to act as a personal coach available 24 hours a day. The challenge of creating a habit in 21 days served as the perfect framework to motivate users to take the first step towards a better life.
What it does
NutriAgenda AI is a mobile-first application that generates complete 21-day plans focused on nutrition and exercise.
- Dynamic Plans: Based on the user's profile (weight, gender, objective), the IA generates a unique daily schedule.
- Meal Management: Automatic organization of Breakfast, Lunch, Dinner, and Snacks.
- Exercise Monitoring: Dashboard to track calorie burn and daily goals.
- Interactive Calendar: Monthly and weekly views to track progress.
- Local Privacy: All data and plans are stored directly on the user's device through Local Storage.
How we built it
The project was built using modern web and mobile development technologies:
- Frontend: Developed with React 18 and Vite for maximum performance. Tailwind CSS was used to create a clean, responsive interface focused on the mobile user experience.
- Artificial Intelligence: We used the Google Gemini API (gemini-1.5-flash model). The AI receives a structured prompt with user data and returns the complete plan in JSON format.
- Mobile: Through Capacitor, we transformed the web application into a native app for Android and iOS.
- State Management: We used the React Context API to maintain data consistency for the challenge and user progress throughout the application.
Personalization Logic (LaTeX)
To ensure the plan is appropriate, the system considers variables such as initial weight ($W$) and the user's objective. While the AI processes most of the logic, the fundamental concept follows the principle of Energy Balance ($EB$):
$$EB = CI - CO$$
Where:
- $CI$ (Calorie Intake) is the calorie intake.
- $CO$ (Calorie Output) is the calorie expenditure (Basal Metabolism + Physical Activity).
The AI is instructed to adjust $CI$ and $CO$ in the 21-day plan so that:
- For weight loss: $EB < 0$
- For muscle gain: $EB > 0$
Challenges we ran into
- JSON Structuring: Ensuring the AI always returned a valid JSON strictly following the defined TypeScript interface was a challenge. We solved this with a rigorous system prompt and string handling to clean markdown delimiters (
`json). - Data Persistence: Keeping the challenge state synchronized between different screens (Agenda, Stats, Home) using only Local Storage required a robust service architecture to avoid progress loss.
- Mobile Experience: Optimizing complex components like the calendar for small smartphone screens without losing usability.
Accomplishments that we're proud of
- Fluid AI Integration: We achieved extremely fast and accurate plan generation using the Gemini Flash model.
- Scalable Architecture: The code is modularized, making it easy to add new features like water tracking or health sensor integration in the future.
- Intuitive Interface: We created a design that focuses on what matters: the user's daily progress.
What we learned
We learned deeply about the capability of language models to act as structured content generators (JSON). Additionally, we improved our skills in transforming PWAs (Progressive Web Apps) into native applications using Capacitor, dealing with mobile app lifecycles and local persistent storage.
What's next for nutriagenda
- Google Fit/Apple Health Integration: To automatically capture exercise data.
- Meal Recognition by Photo: Use Gemini's multimodal capabilities to analyze plate photos and suggest nutritional adjustments.
- Community and Social Challenges: Allow users to share their progress and participate in group challenges.
- Push Notifications: Personalized reminders for meals and workouts.
Log in or sign up for Devpost to join the conversation.