Cai food diary
A food diary for the way Filipinos eat, whether you want to lose weight, put it on, or build muscle. Snap a plate and an AI names each dish and counts the rice; sign up with your height, weight and goal and Cai works out a daily target and plans breakfast to dinner from Filipino dishes. Named after my daughter, Cairus.




- Photo calorie counting with Google's Gemini, falling back to a vision model on Workers AI when Gemini is busy. It matches what it sees to a list of about 140 Filipino dishes with calories and macros per household serving, so tapsilog, tinola and Bicol express come back as themselves. You fix any portion (or swap a dish) before it's saved, and Cai never stores the photo
- Dishes that aren't on the list keep the AI's own estimate and are saved to the person's "My foods", which search and later scans use. Typing a new dish asks the AI to check it's really food and estimate a serving, so "tsinelas, 5 kcal" can't get into the diary
- Three goals: lose weight, gain weight, or build muscle. The daily target is worked out in plain code, not by the AI: Mifflin-St Jeor resting burn, an activity multiplier, then a deficit or surplus from the pace you pick, shown line by line so you can check it
- Safety limits for each goal. Losing never goes under 1,200 kcal (1,500 for men) or faster than 1% of body weight a week, and there's no deficit for anyone pregnant, breastfeeding or underweight. Gaining tops out at half a kilo a week and a healthy weight for your height. A muscle build keeps the surplus near 350 kcal with 2 g of protein per kilo, and switches to building at maintenance once BMI reaches 25
- A meal planner that builds a week of breakfast, lunch, snack and dinner the way a Filipino household eats (a main dish, rice, a vegetable side), sizes the rice to hit each meal's target, rotates the dishes, leaves out pork, beef or seafood if you don't eat them, and lets you swap any meal. Gaining plans get a filling afternoon snack (milk, pandesal and eggs, or taho), and muscle plans lean to protein-heavy dishes like grilled fish, chicken and tuna sisig
- A Today view built on the DOH Pinggang Pinoy plate: the day fills up by food group, meals you haven't eaten yet are re-portioned to fit what's left, and logging a suggested meal is one tap. On a gaining plan it counts calories still to go instead of calories left
- Progress with weigh-ins against the plan's line, four weeks of calories against target, and a streak; it reads upward for gaining plans. A sample account with three weeks of history lets visitors look around without signing up
- Installs to the phone's home screen as an app, with an offline screen and sheets that stay above the keyboard while you type
- An admin page that shows who's actually using it (days logged, a 28-day chart, recent meals), sets each account's daily AI limit, and keeps or deletes accounts. As a demo, every other account is deleted three days after sign-up
- Accounts with hashed passwords and session cookies, all on Cloudflare's free tier. The browser shrinks photos before upload, and daily caps keep the AI inside its free allowance
Cloudflare Workers, Gemini API, Workers AI, D1 (SQLite), TypeScript