Self-hosted n8n automation powering food image analysis, personalized diet plans, and custom workout programs โ with a dual AI engine (Google Gemini + Ollama) and async job processing.
Base64 image โ calories, macros, 13 vitamins, allergens, quality score 1-10
User profile โ 7-day meal plan with recipes, prep times, calorie targets, grocery hints
Goals + fitness level โ 7-day program with sets, reps, form tips, warmup/cooldown
Same analysis, fully self-hosted โ zero API calls, zero cost, complete data privacy
3-day meal plan with nutritionist notes โ runs entirely on local hardware
Full week exercise program with trainer notes โ no GPU required
Frontend POSTs image/data + a UUID jobId to the n8n webhook endpoint. n8n returns 200 immediately.
Workflow sends the request to either Gemini API (cloud) or Ollama (LAN at 172.16.184.60:11434) based on which button the user clicked.
The model analyzes the input and returns structured JSON โ food nutrition data, meal plans, or workout programs.
n8n writes the result to the Python KV store (kvstore:3456) keyed by the jobId. Auto-cleanup after 30 minutes.
Frontend polls GET /food-result?jobId=xxx every 3-5 seconds. Returns "processing" until done, then the full result.
{
"success": true,
"food_items": [
{
"name": "Grilled Chicken Breast",
"quantity_g": 200,
"calories": 330,
"protein_g": 62.0,
"carbs_g": 0,
"fat_g": 7.2
},
{
"name": "Brown Rice",
"quantity_g": 150,
"calories": 165,
"protein_g": 3.5,
"carbs_g": 34.5,
"fat_g": 1.3
}
],
"totals": {
"calories": 495,
"protein_g": 65.5,
"carbs_g": 34.5,
"fat_g": 8.5,
"fiber_g": 2.1
},
"vitamins_minerals": {
"vitamin_b12_mcg": 1.2,
"iron_mg": 3.5,
"calcium_mg": 45,
"potassium_mg": 620,
"zinc_mg": 4.8
},
"meal_quality_score": 8,
"glycemic_index": "medium",
"allergens": [],
"health_notes": "Excellent high-protein meal with balanced macros"
}
| Aspect | โก Gemini (Fast) | ๐ฟ Ollama (Free) |
|---|---|---|
| Food Analysis Speed | ~15s | ~90s |
| Diet Plan Quality | 7-day detailed with recipes | 3-day with notes |
| Workout Detail | Full week + form tips + progression | Full week + exercises |
| Vision Model | gemini-2.5-flash-lite (multimodal) | llava:7b (7B params) |
| Text Model | gemini-2.5-flash-lite | phi3:mini (3.8B params) |
| JSON Reliability | Native response_mime_type | Prompt-engineered |
| Hosting | Google Cloud API | Self-hosted (Proxmox VM) |
| Cost | Free tier (rate limited) | $0 forever |
| Privacy | Data sent to Google | 100% on-premise |
| GPU Required | N/A (cloud) | No โ CPU inference |