547 lines
16 KiB
Markdown
547 lines
16 KiB
Markdown
# Customized Calorie Tracker - Filipino Food Edition
|
|
## Web Application for Weight Loss & Muscle Gain
|
|
|
|
---
|
|
|
|
## Your Specific Requirements
|
|
|
|
✅ **Interface**: Web Application (Flask-based)
|
|
✅ **Goals**: Weight Loss + Muscle Gain (Body Recomposition)
|
|
✅ **Tracking**: Calories, Macros (Protein/Carbs/Fat), Water Intake
|
|
✅ **Precision**: Approximate tracking (user-friendly)
|
|
✅ **Weight Tracking**: Daily weigh-ins with trend analysis
|
|
✅ **Diet**: No restrictions, Filipino food focus
|
|
✅ **Planning**: Meal planning ahead feature (not just logging)
|
|
|
|
---
|
|
|
|
## Enhanced Database Schema
|
|
|
|
### Additional Tables for Your Needs
|
|
|
|
```sql
|
|
-- Water intake tracking
|
|
CREATE TABLE water_logs (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
user_id INTEGER,
|
|
date DATE NOT NULL,
|
|
amount_ml INTEGER NOT NULL,
|
|
time TIME,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Weight tracking
|
|
CREATE TABLE weight_logs (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
user_id INTEGER,
|
|
date DATE NOT NULL UNIQUE,
|
|
weight_kg REAL NOT NULL,
|
|
body_fat_percentage REAL,
|
|
notes TEXT,
|
|
time TIME DEFAULT CURRENT_TIME,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Meal plans (future meals)
|
|
CREATE TABLE meal_plans (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
user_id INTEGER,
|
|
date DATE NOT NULL,
|
|
meal_type TEXT,
|
|
is_completed BOOLEAN DEFAULT 0,
|
|
notes TEXT,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Planned foods (linked to meal_plans)
|
|
CREATE TABLE planned_foods (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
meal_plan_id INTEGER NOT NULL,
|
|
food_id INTEGER NOT NULL,
|
|
quantity REAL NOT NULL,
|
|
FOREIGN KEY (meal_plan_id) REFERENCES meal_plans(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (food_id) REFERENCES food_items(id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Filipino food database (pre-populated)
|
|
CREATE TABLE filipino_foods (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
name_english TEXT,
|
|
name_tagalog TEXT,
|
|
category TEXT, -- 'ulam', 'kanin', 'meryenda', 'sabaw', etc.
|
|
is_common BOOLEAN DEFAULT 1,
|
|
calories REAL,
|
|
protein_g REAL,
|
|
carbs_g REAL,
|
|
fat_g REAL,
|
|
serving_description TEXT
|
|
);
|
|
|
|
-- User preferences and goals
|
|
CREATE TABLE user_goals (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
user_id INTEGER UNIQUE,
|
|
goal_type TEXT, -- 'weight_loss', 'muscle_gain', 'recomp'
|
|
target_weight_kg REAL,
|
|
weekly_goal_kg REAL,
|
|
target_protein_g INTEGER,
|
|
target_carbs_g INTEGER,
|
|
target_fat_g INTEGER,
|
|
target_water_ml INTEGER DEFAULT 2000,
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
);
|
|
```
|
|
|
|
---
|
|
|
|
## Body Recomposition Strategy
|
|
|
|
### Macro Targets for Weight Loss + Muscle Gain
|
|
|
|
**Protein Priority (Muscle Preservation/Growth)**
|
|
- Target: 2.0-2.4g per kg body weight
|
|
- Example: 70kg person = 140-168g protein/day
|
|
|
|
**Moderate Carbs (Energy for Workouts)**
|
|
- Target: 2-3g per kg body weight
|
|
- Example: 70kg person = 140-210g carbs/day
|
|
|
|
**Healthy Fats (Hormones & Satiety)**
|
|
- Target: 0.8-1.0g per kg body weight
|
|
- Example: 70kg person = 56-70g fat/day
|
|
|
|
**Calorie Cycling Option**
|
|
- Training days: Maintenance or slight surplus (+100-200 cal)
|
|
- Rest days: Deficit (-300-500 cal)
|
|
|
|
---
|
|
|
|
## Filipino Food Database
|
|
|
|
### Pre-populated Common Filipino Foods
|
|
|
|
**Kanin (Rice)**
|
|
- White rice (1 cup) - 206 cal, 45g carbs, 4g protein
|
|
- Fried rice - 280 cal, 40g carbs, 5g protein, 10g fat
|
|
- Sinangag - 250 cal, 42g carbs, 4g protein, 8g fat
|
|
|
|
**Ulam (Main Dishes)**
|
|
- Adobo (chicken, 1 serving) - 350 cal, 35g protein, 5g carbs, 20g fat
|
|
- Sinigang (pork, 1 bowl) - 280 cal, 25g protein, 10g carbs, 15g fat
|
|
- Tinola (chicken soup) - 200 cal, 28g protein, 8g carbs, 6g fat
|
|
- Bicol Express - 400 cal, 20g protein, 10g carbs, 30g fat
|
|
- Sisig (pork) - 450 cal, 25g protein, 8g carbs, 35g fat
|
|
- Menudo - 320 cal, 22g protein, 12g carbs, 20g fat
|
|
- Kare-kare - 380 cal, 24g protein, 18g carbs, 25g fat
|
|
- Lechon kawali - 500 cal, 30g protein, 2g carbs, 42g fat
|
|
|
|
**Gulay (Vegetables)**
|
|
- Pinakbet - 150 cal, 5g protein, 20g carbs, 6g fat
|
|
- Laing - 180 cal, 6g protein, 15g carbs, 12g fat
|
|
- Ginisang monggo - 200 cal, 12g protein, 30g carbs, 4g fat
|
|
|
|
**Meryenda (Snacks)**
|
|
- Pandesal (1 piece) - 120 cal, 3g protein, 22g carbs, 2g fat
|
|
- Turon - 180 cal, 2g protein, 35g carbs, 5g fat
|
|
- Bibingka - 220 cal, 5g protein, 38g carbs, 6g fat
|
|
- Puto - 90 cal, 2g protein, 18g carbs, 1g fat
|
|
- Lumpia (2 pieces) - 200 cal, 8g protein, 20g carbs, 10g fat
|
|
|
|
**Sabaw (Soups)**
|
|
- Bulalo - 350 cal, 32g protein, 8g carbs, 20g fat
|
|
- Nilaga - 280 cal, 28g protein, 12g carbs, 14g fat
|
|
|
|
**Breakfast**
|
|
- Tapsilog - 650 cal, 45g protein, 60g carbs, 25g fat
|
|
- Longsilog - 700 cal, 38g protein, 65g carbs, 32g fat
|
|
- Tocilog - 680 cal, 42g protein, 62g carbs, 28g fat
|
|
|
|
---
|
|
|
|
## Web Application Features
|
|
|
|
### Pages Structure
|
|
|
|
**1. Dashboard (Home)**
|
|
- Today's summary card
|
|
- Calories consumed vs target (progress bar)
|
|
- Macros breakdown (protein/carbs/fat) with color-coded bars
|
|
- Water intake tracker (glasses icon)
|
|
- Weight today vs yesterday
|
|
- Quick add meal button
|
|
- Quick add water button
|
|
- Weekly trend chart (calories & weight)
|
|
|
|
**2. Meal Planner**
|
|
- Calendar view (7-day week view)
|
|
- Click date to plan meals
|
|
- Drag-and-drop Filipino foods
|
|
- Copy previous day's meals
|
|
- Templates for common Filipino meal combos
|
|
- Calculate totals before committing
|
|
- Mark meals as completed
|
|
|
|
**3. Food Database**
|
|
- Search bar (English or Tagalog)
|
|
- Filter by category (Ulam, Kanin, Meryenda, etc.)
|
|
- Filipino food section (pre-populated)
|
|
- API search for international foods
|
|
- Add custom foods
|
|
- Favorite foods list
|
|
- Recent foods
|
|
|
|
**4. Tracking Log**
|
|
- Today's meals (editable)
|
|
- Add meal form
|
|
- Food search autocomplete
|
|
- Quick portions (1/2 serving, 1 serving, 2 servings)
|
|
- Edit/delete entries
|
|
|
|
**5. Progress**
|
|
- Weight chart (line graph)
|
|
- Body composition trends
|
|
- Weekly averages
|
|
- Monthly summaries
|
|
- Photo progress (optional upload)
|
|
- Measurements (waist, chest, arms)
|
|
|
|
**6. Goals & Settings**
|
|
- Set target weight
|
|
- Calculate TDEE
|
|
- Set macro targets
|
|
- Choose goal (weight loss, muscle gain, recomp)
|
|
- Water intake goal
|
|
- Activity level
|
|
- Profile info
|
|
|
|
---
|
|
|
|
## Tech Stack
|
|
|
|
### Backend
|
|
```
|
|
Flask==3.0.0
|
|
Flask-SQLAlchemy==3.1.1
|
|
Flask-Login==0.6.3
|
|
python-dotenv==1.0.0
|
|
requests==2.31.0
|
|
```
|
|
|
|
### Frontend
|
|
```
|
|
HTML5
|
|
CSS3 / Tailwind CSS
|
|
JavaScript (Vanilla)
|
|
Chart.js (for graphs)
|
|
FullCalendar.js (for meal planner)
|
|
```
|
|
|
|
### Database
|
|
```
|
|
SQLite3 (development)
|
|
PostgreSQL (production optional)
|
|
```
|
|
|
|
---
|
|
|
|
## UI Design Mockup
|
|
|
|
### Color Scheme (Filipino-inspired)
|
|
- Primary: #D62828 (Red - like Filipino flag)
|
|
- Secondary: #003F87 (Blue)
|
|
- Success: #06D6A0 (Green - for hitting goals)
|
|
- Warning: #FFB703 (Yellow/Gold)
|
|
- Background: #F8F9FA (Light gray)
|
|
|
|
### Dashboard Layout
|
|
```
|
|
┌─────────────────────────────────────────────────────┐
|
|
│ 🏠 Dashboard 📅 Meal Planner 🍽️ Foods 📊 Progress │
|
|
├─────────────────────────────────────────────────────┤
|
|
│ │
|
|
│ Today: January 30, 2026 ⚙️ Settings 👤 User │
|
|
│ │
|
|
│ ┌──────────────────────┐ ┌────────────────────┐ │
|
|
│ │ Calories │ │ Macros │ │
|
|
│ │ ████████░░ 1,645 │ │ Protein: 120g ✓ │ │
|
|
│ │ Target: 2,000 │ │ Carbs: 180g │ │
|
|
│ │ Remaining: 355 │ │ Fat: 55g │ │
|
|
│ └──────────────────────┘ └────────────────────┘ │
|
|
│ │
|
|
│ ┌──────────────────────┐ ┌────────────────────┐ │
|
|
│ │ Water Intake │ │ Weight │ │
|
|
│ │ 💧💧💧💧💧⚪⚪⚪ │ │ Today: 72.5 kg │ │
|
|
│ │ 1,250 / 2,000 ml │ │ Change: -0.3 kg ⬇│ │
|
|
│ └──────────────────────┘ └────────────────────┘ │
|
|
│ │
|
|
│ Today's Meals [+ Add Meal]│
|
|
│ ┌─────────────────────────────────────────────────┤
|
|
│ │ 🌅 Breakfast (7:30 AM) 520 cal│
|
|
│ │ • Tapsilog │
|
|
│ │ • Coffee with milk │
|
|
│ ├─────────────────────────────────────────────────┤
|
|
│ │ 🌞 Lunch (12:30 PM) 680 cal│
|
|
│ │ • Chicken Adobo │
|
|
│ │ • White rice (1.5 cups) │
|
|
│ │ • Pinakbet │
|
|
│ ├─────────────────────────────────────────────────┤
|
|
│ │ 🍪 Snack (3:00 PM) 180 cal│
|
|
│ │ • Turon (1 piece) │
|
|
│ ├─────────────────────────────────────────────────┤
|
|
│ │ 🌙 Dinner (Planned) [Edit] │
|
|
│ │ • Sinigang na baboy │
|
|
│ │ • White rice (1 cup) │
|
|
│ └─────────────────────────────────────────────────┘
|
|
│ │
|
|
│ Weekly Trend │
|
|
│ ┌─────────────────────────────────────────────────┤
|
|
│ │ [Chart: Calories & Weight] │
|
|
│ └─────────────────────────────────────────────────┘
|
|
│ │
|
|
└─────────────────────────────────────────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## Meal Planning Workflow
|
|
|
|
### Planning Mode
|
|
1. Navigate to Meal Planner
|
|
2. Select future date
|
|
3. Add meals for each time slot
|
|
4. Search Filipino foods or API
|
|
5. Adjust quantities
|
|
6. See macro totals update in real-time
|
|
7. Save meal plan
|
|
|
|
### Execution Mode
|
|
1. Dashboard shows today's planned meals
|
|
2. Check off meals as you eat them
|
|
3. Edit portions if needed (ate more/less)
|
|
4. Actual consumption updates automatically
|
|
5. Quick add water after meals
|
|
|
|
### Smart Features
|
|
- **Suggest meals based on remaining macros**
|
|
- Low on protein? Suggests Tinola, Grilled fish
|
|
- Need carbs? Suggests Rice, Pandesal
|
|
- Need fats? Suggests Sisig, Bicol Express
|
|
|
|
- **Common Filipino meal combos**
|
|
- Silog meals (Tapsilog, Longsilog, etc.)
|
|
- Typical lunch: Ulam + Rice + Gulay
|
|
- Merienda ideas
|
|
|
|
- **Copy from history**
|
|
- Yesterday's meals
|
|
- Last week's Tuesday
|
|
- Favorite meal combinations
|
|
|
|
---
|
|
|
|
## API Integration Strategy
|
|
|
|
### Primary: API Ninjas
|
|
- Use for international/branded foods
|
|
- Cache results in local database
|
|
- Fallback to Open Food Facts if not found
|
|
|
|
### Secondary: Open Food Facts
|
|
- Barcode scanning capability
|
|
- Community database
|
|
- Free, no rate limits
|
|
|
|
### Local Database Priority
|
|
1. Check Filipino foods table first (fastest)
|
|
2. Check cached API results
|
|
3. Query API Ninjas
|
|
4. Query Open Food Facts
|
|
5. Allow manual entry if not found
|
|
|
|
---
|
|
|
|
## Water Intake Tracking
|
|
|
|
### Quick Add Buttons
|
|
- Small glass (250ml)
|
|
- Medium glass (350ml)
|
|
- Large glass (500ml)
|
|
- Bottle (750ml)
|
|
- Custom amount
|
|
|
|
### Visual Progress
|
|
- Glass icons fill up (8 glasses = 2L goal)
|
|
- Progress bar
|
|
- Notifications/reminders (optional)
|
|
|
|
### Tracking Table
|
|
```
|
|
Time | Amount | Type
|
|
---------|--------|-------
|
|
07:30 AM | 250ml | Glass
|
|
12:45 PM | 500ml | Bottle
|
|
03:00 PM | 350ml | Glass
|
|
```
|
|
|
|
---
|
|
|
|
## Implementation Phases
|
|
|
|
### Phase 1: Core Backend (Week 1)
|
|
- [ ] Database setup with all tables
|
|
- [ ] User authentication (Flask-Login)
|
|
- [ ] API integration with caching
|
|
- [ ] Filipino food database population
|
|
- [ ] CRUD operations for meals, foods, water, weight
|
|
|
|
### Phase 2: Dashboard & Logging (Week 2)
|
|
- [ ] Dashboard page with cards
|
|
- [ ] Today's summary calculations
|
|
- [ ] Add meal form
|
|
- [ ] Food search with autocomplete
|
|
- [ ] Water logging
|
|
- [ ] Weight logging
|
|
|
|
### Phase 3: Meal Planner (Week 3)
|
|
- [ ] Calendar interface
|
|
- [ ] Plan future meals
|
|
- [ ] Copy meals functionality
|
|
- [ ] Meal templates
|
|
- [ ] Mark meals as completed
|
|
- [ ] Smart suggestions based on macros
|
|
|
|
### Phase 4: Progress & Polish (Week 4)
|
|
- [ ] Progress page with charts
|
|
- [ ] Weight trend analysis
|
|
- [ ] Weekly/monthly reports
|
|
- [ ] Goals page
|
|
- [ ] Settings page
|
|
- [ ] Mobile responsive design
|
|
- [ ] Testing and bug fixes
|
|
|
|
---
|
|
|
|
## Deployment
|
|
|
|
### Recommended: Heroku (Free/Hobby Tier)
|
|
```bash
|
|
# Free tier includes:
|
|
# - 550 dyno hours/month
|
|
# - PostgreSQL database
|
|
# - HTTPS by default
|
|
```
|
|
|
|
### Alternative: PythonAnywhere
|
|
```bash
|
|
# Free tier includes:
|
|
# - One web app
|
|
# - 512MB storage
|
|
# - Good for personal projects
|
|
```
|
|
|
|
### Alternative: DigitalOcean App Platform
|
|
```bash
|
|
# $5/month
|
|
# - More reliable
|
|
# - Better performance
|
|
# - PostgreSQL included
|
|
```
|
|
|
|
---
|
|
|
|
## Special Features for Filipino Users
|
|
|
|
### Language Support
|
|
- Search in English or Tagalog
|
|
- "Kanin" or "Rice" both work
|
|
- "Adobong manok" or "Chicken adobo"
|
|
|
|
### Common Portions
|
|
- Tagayan (ladle)
|
|
- Tasa (cup)
|
|
- Kutsara (tablespoon)
|
|
- Standard plate serving
|
|
|
|
### Meal Categories
|
|
- Almusal (Breakfast)
|
|
- Tanghalian (Lunch)
|
|
- Merienda (Snack)
|
|
- Hapunan (Dinner)
|
|
|
|
### Cultural Considerations
|
|
- Family-style eating (estimate portions)
|
|
- Typical Filipino meal structure
|
|
- Common food pairings
|
|
- Celebration foods (adjust for occasions)
|
|
|
|
---
|
|
|
|
## Starter Prompt for AI Code Generation
|
|
|
|
```
|
|
Create a Flask web application for calorie and macro tracking with these specifications:
|
|
|
|
1. Database (SQLite with Flask-SQLAlchemy):
|
|
- Users, food_items, meals, meal_foods, water_logs, weight_logs
|
|
- meal_plans, planned_foods (for meal planning)
|
|
- filipino_foods (pre-populated)
|
|
- user_goals (macro targets)
|
|
|
|
2. Filipino Food Support:
|
|
- Pre-populate database with 50+ common Filipino foods
|
|
- Categories: Ulam, Kanin, Meryenda, Sabaw, Gulay
|
|
- English and Tagalog names searchable
|
|
|
|
3. Pages:
|
|
- Dashboard (today's summary, macros, water, weight)
|
|
- Meal Planner (calendar view for planning future meals)
|
|
- Food Database (search Filipino + API foods)
|
|
- Tracking Log (add/edit today's meals)
|
|
- Progress (weight chart, trends)
|
|
- Goals/Settings
|
|
|
|
4. Features:
|
|
- Macro tracking (protein, carbs, fat)
|
|
- Water intake logging
|
|
- Daily weight tracking
|
|
- Meal planning (plan ahead, not just log)
|
|
- Copy previous meals
|
|
- Smart macro suggestions
|
|
- API Ninjas integration with caching
|
|
|
|
5. Frontend:
|
|
- Tailwind CSS for styling
|
|
- Chart.js for graphs
|
|
- Red/Blue color scheme (Filipino flag inspired)
|
|
- Mobile responsive
|
|
|
|
6. User Flow:
|
|
- Plan meals in advance
|
|
- Mark meals as completed when eaten
|
|
- Quick add water/weight
|
|
- See progress charts
|
|
|
|
Include:
|
|
- User authentication (Flask-Login)
|
|
- Form validation
|
|
- Error handling
|
|
- Responsive design
|
|
- Sample data
|
|
- Setup instructions
|
|
|
|
Generate complete code with folder structure.
|
|
```
|
|
|
|
---
|
|
|
|
## Next Steps
|
|
|
|
1. **Review this plan** - Make sure it matches your vision
|
|
2. **Start with backend** - Database and API integration
|
|
3. **Build dashboard** - Core tracking interface
|
|
4. **Add meal planner** - Planning ahead feature
|
|
5. **Test and iterate** - Use it yourself, refine
|
|
|
|
Ready to start building? Let's create the actual application! 🚀
|