Calories

1,450 / 2,100

Steps

8,432 / 10k

Protein

120g / 160g

Water

2.1L / 3L

Quick Log

Weekly Activity Trend

Badges & Achievements

Progress Photos

``` #### FILE 2: `titan_health_analytics.html` ```html Titan Health Analytics

Health Insights

User: Alexander Smith

Weight Trajectory & Projection

Target Date: Oct 12, 2024

Based on current loss rate of 0.45kg/week

Average Macro Distribution

Protein: 30%
Carbs: 45%
Fats: 25%

Caloric Deficit/Surplus (Last 30 Days)

Engagement Metrics

Activity Streak 14 Days 🔥
Goal Completion (Monthly) 88%

Data Engine (SQL Logic)

-- 1. Calorie Deficit Analysis (Daily)
SELECT date, 
       SUM(calories_burned) - SUM(calories_consumed) AS net_balance
FROM daily_stats 
JOIN nutrition_logs ON daily_stats.date = nutrition_logs.date
GROUP BY date;

-- 2. Workout Frequency/Intensity Trend
SELECT DATE_TRUNC('week', timestamp) as week, 
       AVG(intensity_rpe) as avg_intensity, 
       COUNT(*) as session_count
FROM workouts 
GROUP BY 1 ORDER BY 1 DESC;

-- 3. Weight Projection (Linear Trend)
WITH stats AS (
    SELECT recorded_at, weight_kg, 
           ROW_NUMBER() OVER (ORDER BY recorded_at) as rn
    FROM weight_history
)
SELECT (current_weight - target_weight) / (current_weight - FIRST_VALUE(weight_kg) OVER (ORDER BY recorded_at)) as days_to_target...

-- 4. Macro Distribution
SELECT 
    SUM(protein_g * 4) / SUM(calories) * 100 as protein_pct,
    SUM(carbs_g * 4) / SUM(calories) * 100 as carb_pct,
    SUM(fat_g * 9) / SUM(calories) * 100 as fat_pct
FROM nutrition_logs;

-- 5. Activity Streaks (Consecutive Days)
SELECT user_id, COUNT(*) as streak_days
FROM (
    SELECT user_id, date, 
           date - INTERVAL '1 day' * ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY date) as grp
    FROM daily_stats
    WHERE steps > 5000
) t
GROUP BY user_id, grp;