AI System Details (docs/ai-system.md)

Zoar AI is powered by a modular, AI-driven architecture designed to deliver personalized fitness and nutrition plans, progress tracking, and habit reinforcement. This section details the system's components, technology stack, and functionality.

Core AI Modules

1. Fitness Advisor

Purpose: Generate personalized workout plans based on user inputs like fitness level, goals, and available time.

Inputs:

  • Age, weight, height, gender.

  • Fitness goals (e.g., weight loss, muscle gain, endurance).

  • Experience level (beginner, intermediate, advanced).

  • Available workout time (e.g., 30 minutes/day).

Outputs:

  • Tailored workout routines with exercises, sets, reps, and rest periods.

  • Progression plans for continual improvement.

Code Example:

pythonCopier le codeimport random

# Sample workout database
workouts = {
    "beginner": ["Push-ups", "Bodyweight Squats", "Plank"],
    "intermediate": ["Dumbbell Bench Press", "Lunges", "Deadlift"],
    "advanced": ["Barbell Squats", "Pull-ups", "Clean and Press"]
}

def generate_workout(goal, experience_level, duration_minutes):
    plan = []
    if goal == "muscle gain":
        exercises = random.sample(workouts[experience_level], 3)
        for exercise in exercises:
            plan.append({
                "exercise": exercise,
                "sets": 4,
                "reps": 8,
                "rest_seconds": 90
            })
    elif goal == "weight loss":
        exercises = random.sample(workouts[experience_level], 3)
        for exercise in exercises:
            plan.append({
                "exercise": exercise,
                "sets": 3,
                "reps": 12,
                "rest_seconds": 60
            })
    return plan

# Example usage
user_plan = generate_workout("weight loss", "beginner", 30)
print(user_plan)

2. Nutrition Planner

Purpose: Provide meal plans tailored to user dietary preferences and fitness goals.

Inputs:

  • Dietary preferences (e.g., vegetarian, keto).

  • Caloric requirements (calculated based on BMR and activity level).

  • Macronutrient distribution (carbs, protein, fats).

Outputs:

  • Daily meal plans with recipes, portion sizes, and nutritional breakdowns.

Code Example:

pythonCopier le code# Calorie and macronutrient calculator
def calculate_macros(calories, goal):
    if goal == "weight loss":
        return {"protein": 0.4 * calories, "carbs": 0.4 * calories, "fats": 0.2 * calories}
    elif goal == "muscle gain":
        return {"protein": 0.3 * calories, "carbs": 0.5 * calories, "fats": 0.2 * calories}

# Sample meal database
meals = [
    {"name": "Grilled Chicken Salad", "calories": 300, "protein": 35, "carbs": 10, "fats": 10},
    {"name": "Oatmeal with Berries", "calories": 250, "protein": 8, "carbs": 45, "fats": 5},
    {"name": "Salmon with Quinoa", "calories": 400, "protein": 30, "carbs": 35, "fats": 15},
]

def generate_meal_plan(calories, goal):
    macros = calculate_macros(calories, goal)
    plan = random.sample(meals, 3)
    return plan, macros

# Example usage
daily_plan, macros = generate_meal_plan(2000, "muscle gain")
print("Daily Plan:", daily_plan)
print("Target Macros:", macros)

3. Progress Tracker

Purpose: Monitor user activity, measure progress, and adjust recommendations dynamically.

Inputs:

  • Fitness data (e.g., steps, heart rate from wearables).

  • User-reported metrics (e.g., weight, workout adherence).

Outputs:

  • Visual charts of progress (e.g., weight trends, workout consistency).

  • Weekly/monthly adjustments to plans based on adherence and results.

Code Example:

pythonCopier le codeimport matplotlib.pyplot as plt

# User progress data
progress_data = {
    "week": [1, 2, 3, 4],
    "weight": [80, 78, 77, 76]  # Weight in kg
}

def plot_progress(data):
    plt.plot(data["week"], data["weight"], marker="o")
    plt.title("Weight Progress Over 4 Weeks")
    plt.xlabel("Week")
    plt.ylabel("Weight (kg)")
    plt.grid(True)
    plt.show()

# Plotting user progress
plot_progress(progress_data)

Technology Stack

  1. Frontend:

    • Framework: React Native (for cross-platform mobile apps).

    • Design: Minimalist UI/UX for ease of use.

  2. Backend:

    • Framework: Node.js with Express.js for API management.

    • Database: Firebase or PostgreSQL for real-time data storage.

  3. AI & Data Science:

    • Frameworks: Python with TensorFlow/Keras for AI models.

    • Pre-trained models: Leverage existing fitness and nutrition datasets to train AI.

  4. Wearable Integration:

    • APIs: Fitbit, Apple Health, Google Fit.


How It All Comes Together

User Journey:

  1. Onboarding:

    • Users input personal details and fitness goals.

  2. AI Processing:

    • Fitness Advisor generates workout plans.

    • Nutrition Planner calculates caloric needs and designs meal plans.

    • Progress Tracker visualizes user data and adjusts recommendations weekly.

  3. Engagement:

    • Daily reminders, tips, and challenges to keep users motivated.

Scalability:

  • The modular architecture allows easy addition of new features (e.g., advanced analytics or gamified rewards).

Last updated