Week 9 Worklog

Week 9 Objectives:

  • Backend: Build the User Metric module — BodyMetric for recording physical measurements and HealthCalculation for computing BMI, BMR, and TDEE.
  • Frontend: Build HealthDashboardScreen with goal input + calculation, BodyMetricListScreen, BodyMetricFormScreen, and all health visualization chart components.
  • Give users clear, actionable insight into their physical health and calorie targets.

Tasks to be carried out this week:

DayTaskStart DateCompletion DateReference Material
2- Build BodyMetric entity (table body_metric)
  + Fields: user (@ManyToOne), heightCm (Float, min=50), weightKg (Float, min=20), age (Integer, min=10), gender (Gender enum), activityLevel (ActivityLevel enum)
  + BodyMetricController (/api/body-metrics): create, get by user (newest first), get latest, get/update/delete by ID
03/09/202603/09/2026
3- Build HealthCalculation entity (table health_calculation)
  + Fields: user, bodyMetric (optional snapshot FK), bmi, bmr, tdee, goalType (GoalTypes enum)
  + Calculation formulas:
   BMI = weight / (height in m)²
   BMR (Mifflin-St Jeor): Men = 10×w + 6.25×h - 5×age + 5; Women = −5
   TDEE = BMR × activity multiplier
03/10/202603/10/2026
3- Build HealthMetricsController (/api/metrics)
  + POST /calculate — compute & persist BMI/BMR/TDEE from CalculateMetricsRequest
  + GET /user/{userId} (full history), GET /user/{userId}/latest, GET /{id}
03/10/202603/10/2026
4- Build HealthDashboardScreen (Frontend)
  + WheelPicker for height (cm) and weight (kg) selection
  + ActivityLevel dropdown picker
  + Goal type selector: Cutting / Bulking / Maintain / UP_Power
  + On submit: createBodyMetric + calculateMetrics → display HealthResultCard (BMI, BMR, TDEE, Macros)
  + Redirect to Profile if gender/birthdate missing
03/11/202603/11/2026
5- Build health chart components (src/components/health/)
  + BMITrendChart: line chart with time range filter (7d/30d/90d/all) + color-coded BMI zones
  + WeightChart: line chart + optional 7-day moving average + distance to goal weight
  + CalorieEnergyCharts: dual-line BMR + TDEE with mode toggle
  + MacrosDisplay: 3 progress bars (protein/carbs/fat) with grams + % labels
  + HealthResultCard: summary card aggregating all computed values
03/12/202603/12/2026
6- Build BodyMetricListScreen (Frontend)
  + Lists all body metric history with formatted dates
  + WeightChart displayed at top of list
  + Edit (navigate to BodyMetricFormScreen) and delete with ConfirmModal
- Build BodyMetricFormScreen
  + Create or edit: height, weight, activity level, goal type
  + Derives gender + age from authSlice user state
03/13/202603/13/2026
7- Backend endpoint refinement phase 1
  + Add @Valid annotations and custom constraint validators to all request DTOs
  + Standardize pagination response: PageResponse<T> with page, size, totalPages, totalElements
  + Add time-range filter GET /api/sessions/user/{userId}?startDate=&endDate= for session history
03/14/202603/14/2026
8- Write unit tests (Spring Boot Test + JUnit 5 + Mockito)
  + UserWorkoutPlanServiceTest: clone method, activation logic, IDOR prevention
  + HealthCalculationServiceTest: BMI/BMR/TDEE formulas with edge case inputs
  + UserWorkoutSessionServiceTest: active session queries, deactivation behavior
03/15/202603/15/2026

Week 9 Achievements:

  • Backend — User Metric module:
    • BodyMetric records persisted with proper validation (height ≥ 50 cm, weight ≥ 20 kg, age ≥ 10).
    • AWS Secrets Manager integration implemented to securely load PostgreSQL credentials and JWT secrets at runtime, encrypted via AWS KMS.
    • BMR computed correctly using Mifflin-St Jeor equation; TDEE applies activity multipliers (1.2 – 1.9).
    • POST /api/metrics/calculate returns HealthCalculationResponse with BMI, BMR, TDEE, and derived macros (protein/carbs/fat grams for goal type).
    • History endpoints return records sorted by createdAt DESC.
    • Endpoint refinement phase 1 complete: all DTOs now have @Valid constraints, pagination standardized with PageResponse<T>, time-range filtering added to session history.
    • Unit tests written and passing: UserWorkoutPlanServiceTest, HealthCalculationServiceTest, UserWorkoutSessionServiceTest all cover edge cases with Mockito-based mocking.
  • Frontend — Health Dashboard:
    • HealthDashboardScreen wheel pickers provide smooth UX for entering height/weight.
    • Results display immediately in HealthResultCard after API response, with logic optimized to prevent redundant BMI/BMR recalculations on every render.
    • Built using react-native-gifted-charts, ensuring high performance and customizability.
    • BMITrendChart color-codes data points: underweight (blue), normal (green), overweight (yellow), obese (red).
    • WeightChart shows moving average trend line when user has ≥ 7 data points.
    • BodyMetricListScreen shows full measurement history with inline edit/delete.

AWS Knowledge Learned:

  • Learned to manage secrets with AWS Secrets Manager or SSM Parameter Store instead of relying on long-lived plaintext distribution.
  • Studied AWS KMS fundamentals including at-rest encryption, key policy boundaries, and the relationship between IAM and key usage rights.
  • Understood secret rotation workflows and the application-level considerations required when a value changes.
  • Reinforced environment isolation practices so dev, staging, and production credentials cannot be mixed accidentally.
  • Learned the audit value of CloudTrail for tracking changes to sensitive configuration and permission boundaries.
  • Applied the principle of minimizing long-lived credentials by favoring short-lived role-based access wherever possible.
  • Connected these controls directly to the protection of user profile and health-related information handled by the app.

In summary, week 9 focused on AWS security controls that protect both system access and sensitive application data.

Next Week Plan:

  • Backend: Deploy to AWS (Docker → ECR → ECS Fargate behind ALB), enable AWS WAF rate limiting and configuration review.
  • Frontend: Build ChatScreen with AWS Bedrock AI chat integration and ProfileScreen with user profile edit and account management.