🌟 Vision: Nutrition Agent
Sticking to a nutrition plan is incredibly hard, not because we don't know what to do, but because it requires constant cognitive load. Every time you want a snack or go out to eat, you have to mentally calculate your remaining calories, protein, and macros. Over time, this friction leads to giving up.
NutriAI solves this by acting as your personal, always-on AI nutrition agent. It’s designed to be the tool you don't even have to open to get value from. NutriAI shifts the paradigm from passive tracking to proactive guidance.
Here is what it does:
- Real-time Advisor: Instead of just logging food, you ask NutriAI: "Should I eat this?". By pulling real-time nutrition data from the Open Food Facts API and cross-referencing your daily logged totals, the agent uses Amazon Bedrock to give you a personalized verdict (e.g., "This 400-calorie muffin takes up 80% of your remaining budget. Skip it if you still want a big dinner!").
- The Always-On Daily Planner: Every morning at 6 AM, without you lifting a finger, NutriAI analyzes what you ate yesterday and generates a personalized daily meal plan for the current day. It looks at where you fell short (e.g., low protein yesterday) and proactively suggests meals to balance your diet.
🛠️ How I Built It (Process, Decisions, and Challenges)
The goal was to build an agent that was lightweight, incredibly fast, and completely serverless to take advantage of the AWS Free Tier.
Key Decisions:
- Vanilla JavaScript Frontend: To keep the footprint minimal and the deployment dead simple, I avoided heavy frameworks and built the frontend in vanilla HTML/JS/CSS. This allowed me to easily host it on a low-cost S3 bucket.
- Automated Deployment: I wrote a comprehensive one-click PowerShell deployment script (
deploy.ps1) that automatically provisions the CloudFormation stack, injects the new API endpoints into the frontend configuration, packages the Lambda functions, and syncs the frontend to S3 while invalidating the CloudFront cache.
- The "Always-On" Mechanism: To fulfill the challenge's core requirement of an agent that works while you're away, I implemented an AWS EventBridge Scheduler. This triggers the Planner Lambda function every morning to generate the daily plan so it's ready before the user even wakes up.
Challenges:
One interesting challenge I ran into was handling external API idiosyncrasies. When users typed a generic food like "pineapple", the external Open Food Facts database returned highly specific branded products (like a Spanish pineapple juice). The app originally forced these obscure brand names into the user's food log! I had to patch the logic to prioritize the user's intended input while still extracting the correct macronutrient data from the closest database match.
☁️ AWS Services Used and Architecture Overview
NutriAI is 100% serverless and leverages a robust suite of AWS services:
- Amazon Bedrock (Claude 3 Haiku): The brain of the agent. I used Claude 3 Haiku because it is extremely fast and cost-effective, making it perfect for rapid, real-time food verdicts and daily meal planning.
- AWS Lambda: Powers the backend compute. There are two independent functions:
-
advisor: Handles real-time API requests from the frontend to give instant food verdicts.
-
planner: Runs asynchronously to read historical data and generate the morning meal plan.
- Amazon API Gateway (HTTP API): Exposes the
advisorandplannerLambda functions to the frontend. I chose HTTP APIs over REST for lower latency and reduced cost.
- Amazon DynamoDB: Provides persistent, NoSQL storage for the daily food logs, enabling the agent to remember what the user ate yesterday.
- Amazon EventBridge Scheduler: The engine for the "always-on" agent, invoking the planner automatically via a cron expression (6 AM daily).
- Amazon S3 & CloudFront: S3 acts as the origin for the static frontend assets, while CloudFront provides a global CDN with HTTPS encryption and aggressive edge caching.
- AWS CloudFormation: Manages the entire infrastructure as code, ensuring repeatable and reliable deployments.
🧠 What I Learned
This challenge pushed me to think differently about how users interact with AI. Rather than building a traditional "chatbot" where the user has to initiate everything, I learned how to orchestrate AWS services (like EventBridge and Lambda) to create a system that works proactively in the background.
I also gained deep hands-on experience with AWS CloudFormation. Creating a template from scratch that wires up API Gateway routes to Lambda integrations, sets up proper IAM permissions, and configures CloudFront distributions gave me a profound appreciation for Infrastructure as Code. Finally, integrating Amazon Bedrock proved just how seamless it is to drop advanced LLM capabilities into a standard Node.js serverless stack without managing API keys or external vendor integrations.
🔗 Links
- Live Application: https://d2b06vipd3yd0r.cloudfront.net
- Repository: https://github.com/raunak222/nutriai
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article