4.9 KiB
Fitness Profile Feature
Overview
The Fitness Profile feature allows mobile app users to create and manage their personal fitness information, including physical metrics, fitness goals, activity levels, and health-related information.
Features
- Basic Information: Height, weight, age, and gender
- Fitness Goals: Primary fitness goal and activity level
- Health Information: Medical conditions, allergies, and injuries
- Auto-save: Automatically updates existing profile or creates new one
- Persistent Storage: Data saved to SQLite database
Database Schema
The fitness profile is stored in the fitness_profiles table with the following structure:
CREATE TABLE fitness_profiles (
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL UNIQUE,
height REAL, -- in cm
weight REAL, -- in kg
age INTEGER,
gender TEXT, -- male, female, other, prefer_not_to_say
fitness_goal TEXT, -- weight_loss, muscle_gain, endurance, flexibility, general_fitness
activity_level TEXT, -- sedentary, lightly_active, moderately_active, very_active, extremely_active
medical_conditions TEXT,
allergies TEXT,
injuries TEXT,
created_at INTEGER NOT NULL,
updated_at INTEGER NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
Mobile App Implementation
Location
- Screen:
apps/mobile/src/app/fitness-profile.tsx - Components:
apps/mobile/src/components/Input.tsxapps/mobile/src/components/Picker.tsx
Navigation
Accessible from the home screen's "Quick Actions" section with a "Fitness Profile" button.
User Flow
- User taps "Fitness Profile" from Quick Actions
- App fetches existing profile (if any) from API
- User fills in or updates fitness information
- User taps "Save Profile"
- Data is saved to database via API
- User receives success confirmation and returns to home screen
API Endpoints
GET /api/fitness-profile
Fetches the authenticated user's fitness profile.
Authentication: Required (Clerk Bearer token)
Response:
{
"profile": {
"id": "fp_...",
"userId": "user_...",
"height": 175,
"weight": 70,
"age": 25,
"gender": "male",
"fitnessGoal": "muscle_gain",
"activityLevel": "moderately_active",
"medicalConditions": "None",
"allergies": "Peanuts",
"injuries": "Previous knee injury",
"createdAt": 1234567890000,
"updatedAt": 1234567890000
}
}
POST /api/fitness-profile
Creates or updates the authenticated user's fitness profile.
Authentication: Required (Clerk Bearer token)
Request Body:
{
"height": 175,
"weight": 70,
"age": 25,
"gender": "male",
"fitnessGoal": "muscle_gain",
"activityLevel": "moderately_active",
"medicalConditions": "None",
"allergies": "Peanuts",
"injuries": "Previous knee injury"
}
Response (Create):
{
"message": "Fitness profile created successfully",
"profileId": "fp_..."
}
Response (Update):
{
"message": "Fitness profile updated successfully",
"profileId": "fp_..."
}
Field Options
Gender
- Male
- Female
- Other
- Prefer not to say
Fitness Goals
- Weight Loss
- Muscle Gain
- Endurance
- Flexibility
- General Fitness
Activity Levels
- Sedentary
- Lightly Active
- Moderately Active
- Very Active
- Extremely Active
Environment Variables
For mobile app to connect to the admin API:
EXPO_PUBLIC_API_URL=http://localhost:3000 # Development
EXPO_PUBLIC_API_URL=https://your-domain.com # Production
Testing
Manual Testing
-
Create Profile:
- Open mobile app and sign in
- Navigate to home screen
- Tap "Fitness Profile" in Quick Actions
- Fill in fitness information
- Tap "Save Profile"
- Verify success message
-
Update Profile:
- Return to Fitness Profile screen
- Verify existing data is loaded
- Modify some fields
- Tap "Save Profile"
- Verify success message
-
Persistence:
- Close and reopen app
- Navigate to Fitness Profile
- Verify data persists
Database Verification
# View fitness profiles in database
cd apps/admin
npm run db:studio
# Navigate to fitness_profiles table
Future Enhancements
- BMI calculation and display
- Progress tracking over time
- Integration with workout plans based on fitness goals
- Trainer access to client fitness profiles
- Health metrics charts and trends
- Photo upload for progress tracking
- Export fitness data
Dependencies
Mobile App
@react-native-picker/picker: For dropdown selectors@clerk/clerk-expo: For authenticationexpo-router: For navigation
Admin API
better-sqlite3: For database operations@clerk/nextjs/server: For authentication verification
Migration
To apply the database schema changes:
cd packages/database
npm run db:push
This will create the fitness_profiles table in the SQLite database.