Week 10 Worklog

Week 10 Objectives:

  • Backend:
    • Refine API endpoints — improve input validation, pagination, and write unit tests for core service methods.
    • Final API review, Docker Compose production-readiness, and complete environment variable documentation.
  • Frontend:
    • Build the ChatScreen with AWS Bedrock AI integration and ProfileScreen with user account management.
    • Deliver the AI-powered assistant feature as a differentiating value-add for the application.
    • Build HomeScreen as the central dashboard, resolve all outstanding bugs, and polish the overall UX across the app.
    • Achieve a fully functional, integrated application ready for final testing.

Tasks to be carried out this week:

Day Task Start Date Completion Date Reference Material
2 - Backend endpoint refinements
  + Add @Valid annotations and custom constraint validators to all request DTOs
  + Standardize paginated responses: PageResponse<T> with page, size, totalPages, totalElements
  + Add GET /api/sessions/user/{userId}?startDate=&endDate= date-range filter for session history
03/17/2026 03/17/2026
3 - Write unit tests (Spring Boot Test + JUnit 5 + Mockito)
  + UserWorkoutPlanServiceTest: clone method, activate logic, IDOR prevention
  + HealthCalculationServiceTest: BMI/BMR/TDEE formulas for various inputs
  + UserWorkoutSessionServiceTest: active session query, deactivate behavior
03/18/2026 03/18/2026
4 - Build chatService (Frontend)
  + Direct AWS Bedrock Runtime API call (no Lambda proxy)
  + Model: anthropic.claude-3-5-haiku-20241022-v1:0
  + Vietnamese system prompt: fitness coach persona
  + Send last 12 conversation turns as context (sliding window memory)
03/19/2026 03/19/2026 https://docs.aws.amazon.com/bedrock/
5 - Build ChatScreen (Frontend)
  + Full-screen chat UI with message bubble list (user / bot)
  + Animated “typing” indicator (3 bouncing dots) while waiting for response
  + 4 quick-option chips: “Suggest exercises”, “Today’s menu”, “Calorie goal”, “Weight loss advice”
  + Vietnamese initial greeting from the fitness bot
  + Animated keyboard avoidance
  + notifyAlert error handling via global alert proxy
03/20/2026 03/20/2026
6 - Build ProfileScreen (Frontend)
  + Display avatar (initial-letter fallback), name, email, username, birthdate, gender
  + Edit modal: update birthdate (YYYY-MM-DD) and gender via updateUserProfile API + dispatch(updateUserProfile)
  + Logout: signOut (Cognito revoke) + dispatch(logout) + clear secure storage
  + Delete account: deleteUserProfile + signOut — both gated by ConfirmModal
03/21/2026 03/21/2026
2 - Build HomeScreen (Frontend) — 5 parallel data fetches on mount
  + Today’s meals: sum MealFood calories → daily calorie progress bar vs. 2500 kcal target
  + Latest HealthCalculation → show BMI
  + Latest BodyMetric → show current height/weight
  + Active workout plan name → quick link to PlanDetail
  + This-week session count → weekly progress vs. 4 sessions target
03/24/2026 03/24/2026
3 - Backend Docker Compose final refinements
  + Add healthcheck to postgres service: pg_isready with interval, timeout, retries
  + Add depends_on.db.condition: service_healthy to API service
  + Verify Spring Actuator /actuator/health liveness + readiness probes
  + Complete .env.example with all required variables documented
03/25/2026 03/25/2026
4 - Comprehensive bug fix session across all Frontend screens
  + Fix WorkoutSessionScreen: edge case when all exercises completed before timer finishes
  + Fix DietScreen: ensure ensureDailyMeals not called on every render — move to useEffect with empty deps
  + Fix HealthDashboardScreen: loading state shown during calculateMetrics call
  + Fix BMITrendChart: empty state when user has fewer than 2 health calculations
03/26/2026 03/26/2026
5 - Response interceptor improvements (Axios client.ts)
  + Implement token refresh with request queue: concurrent 401 responses queued, one refresh attempted, all retried
  + On refresh failure: forceLogout clears tokens + dispatches Redux logout + navigates to Login
  + Handle code === 4040 “user not found for cognitoId” → auto forceLogout
03/27/2026 03/27/2026
6 - UX polish pass across all screens
  + Add NotificationBox global alert component (replaces native Alert.alert via installAlertProxy)
  + Add pull-to-refresh on HomeScreen
  + Ensure consistent loading spinners and error states across all screens
  + Add ActivityLevelLabels Vietnamese display names for all enum values
  + Vietnamese label consistency check across navigation tabs and headings
03/28/2026 03/28/2026

Week 10 Achievements:

  • Backend:
    • All request DTOs now have @Valid constraints — invalid inputs return structured ApiResponse field errors.
    • PageResponse<T> standardizes all paginated endpoints consistently.
    • Date-range session filter (?startDate=&endDate=) working with @DateTimeFormat parsing.
    • Unit tests pass for UserWorkoutPlanService clone, activate, and IDOR prevention scenarios.
    • BMI/BMR/TDEE formulas verified with edge case inputs (min/max allowed ranges).
    • Health check on PostgreSQL service ensures the API container waits for DB to be fully ready.
    • GET /actuator/health returns {status: UP} with liveness/readiness sub-probes.
    • .env.example fully documents all 10+ required environment variables with descriptions.
  • Frontend:
    • chatService.sendChatToBedrock calls AWS Bedrock Runtime directly using credentials from .env.
    • Sliding window of 12 turns maintains conversation context economically.
    • Quick-option chips provide instant first interaction without typing.
    • Typing indicator creates natural chat feel; keyboard avoidance works on both iOS and Android.
    • Profile data loaded from Redux authSlice — no extra API call needed on screen mount.
    • Edit modal updates local state optimistically and confirms via API.
    • Logout and delete account flows both require confirmation — no accidental data loss.
    • 5 parallel Promise.all API calls complete in under 1.5s on localhost.
    • Daily calorie + weekly session progress indicators give users clear at-a-glance goals.
    • BMI and body metric snapshot visible on home without navigating away.
    • Workout session completion edge case resolved — app no longer freezes on final set.
    • ensureDailyMeals called only once on first mount — eliminated 4 redundant API calls per render.
    • Token refresh queue prevents logged-out flash when multiple concurrent requests get 401.
    • NotificationBox replaces native alerts — consistent in-app notification style.
    • All loading states and error messages standardized across the application.
    • Vietnamese labels complete and consistent throughout the UI.

Next Week Plan:

  • Backend:
    • Final API review, Docker Compose refinement with health checks, environment variable documentation.
    • Write project documentation (README, API reference, architecture diagram).
  • Frontend:
    • Build HomeScreen dashboard with parallel data fetching, resolve remaining bugs, and polish overall UX.
    • Run full end-to-end integration test of the complete application (all features, all screens).
    • Prepare final demo and code cleanup for project handoff.