π₯ by kevinmarch
Track Nutrition
Evening check-in on daily nutrition β protein and calories. Quick log, weekly trends, streak tracking.
Configuration
User defines their targets in config:
# config.env
PROTEIN_TARGET_GRAMS=100
CALORIE_TARGET=2000
CHECKIN_TIME=7pm
LOG_FILE=nutrition-log.csv
Defaults: 100g protein, 2000 calories.
When to Run
- Scheduled: 7pm daily
- On-demand: User says "log nutrition" or "track food"
1. Prompt for Today's Log
Send a friendly check-in:
π₯ Nutrition Check-In
How'd you do today?
Quick log options:
- "120g protein, 1800 cal" β I'll log it
- "good" β Hit your targets
- "skip" β Not tracking today
- "+" β Add to previous entry
Or tell me what you ate and I'll estimate.
2. Parse the Response
Numeric entry: "100g protein, 1500 cal" β Log both values
Relative entry: "good", "hit target", "crushed it" β Log target values
Food description: "had a protein shake and chicken breast" β Estimate macros
Skip: Don't log, don't break streak (grace day)
Estimation Mode
If user describes food, estimate using these methods:
Method 1: Nutritionix API (Free Tier)
Nutritionix offers a free API for natural language nutrition queries:
POST https://trackapi.nutritionix.com/v2/natural/nutrients
Headers:
x-app-id: YOUR_APP_ID
x-app-key: YOUR_API_KEY
Body: { "query": "1 chicken breast and a protein shake" }
Returns detailed nutrition data. Free tier: 200 requests/day.
Sign up: https://developer.nutritionix.com/
Method 2: USDA FoodData Central (Free, No Key)
USDA's free nutrition database:
GET https://api.nal.usda.gov/fdc/v1/foods/search?query=chicken+breast&api_key=DEMO_KEY
- Completely free, no registration required (DEMO_KEY works)
- Returns nutrition per 100g, you'll need to estimate portions
- Good for raw ingredients, less good for mixed dishes
Method 3: OpenFoodFacts (Free, Open Source)
Community-driven food database:
GET https://world.openfoodfacts.org/cgi/search.pl?search_terms=protein+bar&json=1
- Free, no API key needed
- Great for packaged foods with barcodes
- Less comprehensive for raw ingredients
Method 4: Estimation Heuristics
When APIs aren't available, use common values:
| Food | Protein | Calories |
|---|
| Chicken breast (6oz) | 54g | 280 |
| Protein shake (1 scoop) | 25g | 120 |
| Eggs (1 large) | 6g | 70 |
| Greek yogurt (1 cup) | 20g | 150 |
| Salmon (6oz) | 40g | 350 |
| Ground beef (4oz, 90% lean) | 23g | 200 |
| Tofu (1/2 block) | 20g | 180 |
| Black beans (1 cup) | 15g | 225 |
| Rice (1 cup cooked) | 4g | 200 |
| Bread (1 slice) | 3g | 80 |
Present estimate with breakdown:
Estimated from what you described:
- Chicken breast (6oz): 54g protein, 280 cal
- Protein shake: 25g protein, 120 cal
- Rice (1 cup): 4g protein, 200 cal
Total: 83g protein, 600 cal
Log this? (or adjust: "make it 90g protein")
3. Log the Entry
Store in a simple CSV or markdown file:
date,protein_g,calories,notes
2024-03-05,120,1850,good day
2024-03-04,95,2100,missed protein target
2024-03-03,110,1900,
Or markdown format:
## 2024-03-05
- Protein: 120g β
(target: 100g)
- Calories: 1850 β
(target: 2000)
- Notes: Good day
4. Give Immediate Feedback
Based on the entry:
Hit both targets:
β
Crushed it!
- Protein: 120g (target: 100g) πͺ
- Calories: 1850 (target: 2000) β
π₯ 5-day streak!
Hit one, missed one:
π Solid day!
- Protein: 95g β 5g shy β
- Calories: 1800 β
Close on protein! Tomorrow's a new day.
Missed both targets:
π Logged:
- Protein: 75g β 25g under target
- Calories: 2500 β 500 over target
No worries. Consistency > perfection.
Skip:
βΈοΈ Rest day logged. Streak preserved.
5. Weekly Summary (Sundays)
On Sundays (or after 7 days), generate a weekly report:
# π₯ Weekly Nutrition Report
Week of [Date]
## Protein
- Average: 105g/day (target: 100g) β
- Best day: Wednesday (140g)
- Days at target: 5/7
## Calories
- Average: 1,950/day (target: 2,000) β
- Range: 1,700 - 2,200
- Days at target: 6/7
## Streak
π₯ Current streak: 12 days
π Longest streak: 21 days
## Trend
Protein Calories
Mon β
95g β 2100
Tue β 110g β
1800
Wed β 140g β 1950
Thu β 100g β
1850
Fri β 115g β 2000
Sat β
90g β 2200
Sun β 105g β
1900
## Notes
- Protein strong this week πͺ
- Weekend calories trending higher β watch snacking
6. Streak Tracking
Track consecutive days of hitting BOTH protein and calorie targets:
- Current streak: Days in a row at or above protein target AND within calorie range
- Longest streak: All-time record
- Grace days: Skipped days don't break streak (1 per week max)
Celebrate milestones:
- 7 days: "π― One week strong!"
- 30 days: "π One month! You're building a habit."
- 100 days: "π― Triple digits!"
7. Smart Reminders
If user hasn't logged by 9pm:
Hey! Haven't heard from you today. Quick nutrition check?
(Reply "skip" to skip today)
If streak is at risk:
β οΈ 14-day streak on the line! How'd nutrition go today?
Data Storage
Store logs in user's workspace:
nutrition-log.csv
β Raw data
nutrition-summary.md
β Weekly summaries
Keep it simple so user can review/export anytime.
After Running
Confirm the log:
- "β
Logged: [Xg protein, Y cal]"
- "[Streak] days and counting"
- Or weekly summary on Sundays