AWS Builder Center
Weekend Annoying Task Challenge: FitIntelligence

Weekend Annoying Task Challenge: FitIntelligence

AI fitness coach on AWS: real-time biomechanics feedback via Bedrock + YOLO pose tracking and geofenced gym check-ins verified by Rekognition.

AWS Community Builder - Dev Tools | 2× AWS Certified | Devops/Cloud Consultant
Every gym-goer knows the two silent killers of consistency: not knowing if your form is actually correct, and not showing up in the first place. I built FitIntelligence to kill both problems at once: an AI coach that watches how you move and a verification system that makes sure you're actually at the gym when you say you are. Here's how I built it on AWS in a weekend, and what it took to make it production-ready.

Vision & What the App Does

We've all been there: standing in the gym wondering if our squat depth is destroying our knees, or constantly second-guessing whether our deadlift form is flexing our spine instead of hinging at the hips. On top of that, manually tracking gym membership expiry dates, managing workout split routines, and fighting the urge to skip gym days altogether are daily micro-annoyances that derail fitness progress.
FitIntelligence is an AI-powered fitness coach and gym commitment ecosystem built to automate these exact headaches. It transforms two of the most annoying parts of personal fitness:
  1. Uncertainty in Exercise Form & Biomechanics: Instead of paying $100/hr for a personal trainer to watch your reps, FitIntelligence uses an edge computer vision pipeline coupled with Generative AI on AWS to deliver real-time, human-like biomechanical critique and injury prevention advice.
  1. Gym Absenteeism & Membership Friction: Instead of relying on willpower alone, FitIntelligence enforces accountability through strict geofenced GPS verification (within 300 meters) and AWS Rekognition biometric/environmental selfie verification. If you enable "Strict Mode," the app locks down full-screen reminders until you actually show up at the gym and verify your presence.

Core Features at a Glance:

  • AI Biomechanics Coach: Upload a video of your workout set. The backend extracts 17 body joint keypoints via YOLO11-Pose, computes joint angles, and feeds vector trajectory data to Amazon Bedrock (Meta Llama 3) for structured coaching.
  • Rekognition Gym Verification: Snaps a selfie at the gym. Amazon Rekognition scans the scene for gym equipment (dumbbells, squat racks, barbells) and high-confidence fitness context to grant check-in validation.
  • GPS Geofencing: Uses the Haversine formula to confirm physical proximity to your registered gym.
  • Smart Split Calendar & Expiry Tracker: Manages 5 workout split templates (Push-Pull-Legs, Arnold Split, Bro Split, Upper/Lower, Full Body) alongside dynamic membership countdown cards (Green: >7 days left, Yellow: 1-7 days, Red: expired).
  • Automated Task Engine: Powered by Celery Beat and Redis to dispatch push notification alerts and enforce check-in windows.

AWS Services Used & Architecture Overview

FitIntelligence is designed as a decoupled, multi-container cloud platform hosted on AWS infrastructure.

AWS Services Employed:

  • Amazon Bedrock (Meta Llama 3 70B & 8B Instruct): Generates natural, encouraging, and anatomically precise kinesiology critiques based on joint vector mathematical inputs.
  • Amazon Rekognition ( detect_labels  API): Performs real-time visual environment inspection to verify equipment and gym settings from user selfies.
  • Amazon EC2 (Ubuntu Linux): Hosts the production Docker Compose backend (FastAPI, PostgreSQL 16, Redis 7, Celery Worker & Beat) behind a tuned Uvicorn application server.
  • Amazon ECR (Elastic Container Registry): Stores immutable container images built during CI workflows tagged with Git commit SHAs.
  • Amazon S3: Serves as secure object storage for user verification media, gym photos, and avatar assets.
  • AWS IAM Instance Profiles: Secures service-to-service communication between EC2, Bedrock, S3, and Rekognition without hardcoding secret keys into codebase files.

System Architecture Diagram



Trigger & Data Flow Sequence:

  1. User Action: The mobile user records a 5-second squat video and hits "Analyze Form".
  1. Ingestion Layer: FastAPI on EC2 receives the multipart payload.
  1. Local Vector Extraction: YOLO11-Pose detects 17 keypoint $(X, Y)$ coordinates per frame. Vector trigonometry calculates knee flexion, hip hinge, and spine tilt angles.
  1. Bedrock AI Reasoning: The computed angle trajectory (e.g.  Left Knee: 85° ,  Hip: 90° ) is sent to Amazon Bedrock (Meta Llama 3 70B) via  boto3 . Bedrock acts as a master coach, evaluating depth, injury risk, and generating targeted drill suggestions.
  1. Biometric Check-in: When a user arrives at the gym, the app sends GPS coordinates and a photo. FastAPI verifies Haversine distance ≤ 300m and calls Amazon Rekognition  detect_labels . Rekognition searches for labels like  Dumbbell ,  Barbell ,  Gym , or  Treadmill  with >70% confidence before clearing the strict workout lock.

How I Built It & Engineering Challenges

Building a high-throughput, low-latency fitness app on AWS required navigating several architectural trade-offs and resolving unexpected edge cases.

1. Cost & Latency Optimization: Keypoint Extraction vs. Video Tokens

  • Challenge: Sending full video files directly to multimodal LLMs is prohibitively expensive and introduces high latency (often taking 15+ seconds per prompt).
  • Solution: I implemented a 2-stage hybrid pipeline. Stage 1 extracts lightweight $(X, Y)$ coordinate vectors using a server-side YOLO11-Pose model. Stage 2 converts those coordinate arrays into scalar joint angles using trigonometric vector math:

Only these concise scalar angle summaries are sent to Amazon Bedrock. This reduced prompt token count by over 95%, dropped API costs down to fractions of a cent per analysis, and cut evaluation response time to under 2 seconds!

2. High Availability Bedrock Model Fallback

  • Challenge: Rate limits or regional quota spikes on high-parameter models like Meta Llama 3 70B can cause sudden 429 throttling errors.
  • Solution: I engineered an automatic fallback circuit breaker pattern using  boto3 . The backend first attempts high-fidelity critique via  meta.llama3-70b-instruct-v1:0 . If a quota error occurs, it seamlessly intercepts the exception and falls back to  meta.llama3-8b-instruct-v1:0  without breaking the client request.
def _call_bedrock_llama3(prompt_text: str) -> str | None:
try:
bedrock = boto3.client("bedrock-runtime", region_name="us-east-1")
# Primary: Llama 3 70B
try:
body = json.dumps({"prompt": prompt_text, "max_gen_len": 1024, "temperature": 0.3})
response = bedrock.invoke_model(
body=body, modelId="meta.llama3-70b-instruct-v1:0",
accept="application/json", contentType="application/json"
)
return json.loads(response.get("body").read()).get("generation", "").strip()
except Exception as e70:
print(f"Llama 3 70B throttled ({e70}). Falling back to Llama 3 8B...")
# Fallback: Llama 3 8B
body = json.dumps({"prompt": prompt_text, "max_gen_len": 1024, "temperature": 0.3})
response = bedrock.invoke_model(
body=body, modelId="meta.llama3-8b-instruct-v1:0",
accept="application/json", contentType="application/json"
)
return json.loads(response.get("body").read()).get("generation", "").strip()
except Exception as e:
print(f"Bedrock invocation failed: {e}")
return None


3. Verification Accuracy with Amazon Rekognition

  • Challenge: Simple GPS check-ins can easily be spoofed using mock location tools on Android.
  • Solution: I paired GPS distance calculation with Amazon Rekognition Label Detection. When users take a check-in photo, Rekognition checks for specific gym equipment and training room indicators.
GYM_LABELS = {
"gym", "gymnasium", "exercise", "workout", "barbell",
"dumbbell", "kettlebell", "treadmill", "squat rack", "sportswear"
}

async def verify_selfie_at_gym(image_bytes: bytes) -> bool:
client = boto3.client("rekognition", region_name="us-east-1")
response = client.detect_labels(
Image={"Bytes": image_bytes}, MaxLabels=30, MinConfidence=70.0
)
detected = [label["Name"].lower() for label in response.get("Labels", [])]
return any(label in GYM_LABELS for label in detected)


4. Zero-Downtime EC2 Deployment with GitHub Actions

  • Challenge: Deploying updates manually to EC2 led to container downtime during push events.
  • Solution: I wrote a two-stage CI/CD pipeline using GitHub Actions, Amazon ECR, and Docker Compose.
  •  ci.yml : Lints code with ruff , runs pytest unit tests, builds the Docker image, and pushes it to Amazon ECR.
  •  cd.yml : Connects to EC2 over SSH, pulls the latest image, executes docker compose up -d --remove-orphans , applies Alembic DB migrations, and conducts health checks with automated rollback on failure.

What I Learned

Participating in the Weekend Annoying Task Challenge was an incredible accelerator. Key takeaways include:
  1. Leveraging Bedrock for Domain-Specific AI: Amazon Bedrock makes it easy to experiment with different models (Meta Llama 3 70B/8B) without managing GPU infrastructure. Framing prompt instructions with explicit JSON contracts allows deterministic parsing of complex advice.
  1. Combining Computer Vision at Edge/Server with Cloud AI: Passing raw pixels into an LLM is rarely optimal. Pre-processing video frames into structural geometric abstractions (angles, trajectories) yields faster response times and drastically lower cloud bills.
  1. Environmental Context Verification with Amazon Rekognition: Rekognition isn't just for face comparison —  detect_labels  is a superpower for real-world contextual validation (e.g., verifying that a photo was taken inside a gym).
  1. Resilient Production Guardrails: Infrastructure as code, instance roles, keep-alive tuning on Uvicorn servers, and automated GitHub Actions rollbacks are essential for maintaining production stability on AWS.

Link to App & Source Code



Built with ❤️ for the AWS Weekend Annoying Task Challenge.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article