help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
fitness-coach-bot
RSK World
fitness-coach-bot
Fitness Coach Bot - Python + Flask + SQLAlchemy + Workout Plans + Exercise Guidance + Health Tracking + AI Fitness Coach
fitness-coach-bot
  • __pycache__
  • data
  • instance
  • models
  • static
  • templates
  • utils
  • .gitignore564 B
  • ADVANCED_FEATURES.md7.1 KB
  • HOW_TO_CREATE_RELEASE.md4.1 KB
  • LICENSE1.1 KB
  • PROJECT_CHECK_SUMMARY.md5.5 KB
  • README.md8.5 KB
  • RELEASE_NOTES_v1.0.0.md6.9 KB
  • app.py16.5 KB
  • config.py1.5 KB
  • demo_data.py2.5 KB
  • init_db.py12.7 KB
  • requirements.txt442 B
init_db.py
init_db.py
Raw Download
Find: Go to:
"""
Fitness Coach Bot - Database Initialization Script
Author: RSK World (https://rskworld.in)
Founded by: Molla Samser
Designer & Tester: Rima Khatun
Contact: help@rskworld.in, +91 93305 39277
Year: 2026
"""

import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from app import app, db
from models.fitness_models import User, WorkoutPlan, Exercise, WorkoutExercise, HealthTip
from datetime import datetime

def init_database():
    """Initialize the database with sample data"""
    with app.app_context():
        # Create all tables
        db.create_all()
        print("Database tables created successfully!")
        
        # Add sample exercises
        if Exercise.query.count() == 0:
            exercises = [
                # Bodyweight Exercises
                Exercise(
                    name="Push-ups",
                    description="Classic upper body exercise targeting chest, shoulders, and triceps",
                    category="strength",
                    muscle_group="chest",
                    equipment="None",
                    difficulty="beginner",
                    instructions="1. Start in plank position with hands slightly wider than shoulders\n2. Lower body until chest nearly touches floor\n3. Push back up to starting position\n4. Keep core engaged throughout",
                    tips="Keep your body in a straight line from head to heels. Modify by doing push-ups on knees if needed.",
                    calories_per_minute=7.0
                ),
                Exercise(
                    name="Squats",
                    description="Fundamental lower body exercise for legs and glutes",
                    category="strength",
                    muscle_group="legs",
                    equipment="None",
                    difficulty="beginner",
                    instructions="1. Stand with feet shoulder-width apart\n2. Lower body as if sitting in a chair\n3. Keep chest up and knees behind toes\n4. Return to starting position",
                    tips="Keep your weight on your heels. Go as low as comfortable while maintaining form.",
                    calories_per_minute=8.0
                ),
                Exercise(
                    name="Plank",
                    description="Core strengthening exercise",
                    category="strength",
                    muscle_group="core",
                    equipment="None",
                    difficulty="beginner",
                    instructions="1. Start in push-up position\n2. Hold body in straight line\n3. Engage core muscles\n4. Maintain position for specified time",
                    tips="Don't let hips sag or rise. Keep breathing steadily throughout.",
                    calories_per_minute=5.0
                ),
                Exercise(
                    name="Lunges",
                    description="Single-leg exercise for legs and glutes",
                    category="strength",
                    muscle_group="legs",
                    equipment="None",
                    difficulty="beginner",
                    instructions="1. Step forward with one leg\n2. Lower hips until both knees are bent at 90 degrees\n3. Push back to starting position\n4. Alternate legs",
                    tips="Keep front knee behind toes. Keep torso upright throughout movement.",
                    calories_per_minute=6.0
                ),
                Exercise(
                    name="Jumping Jacks",
                    description="Cardiovascular exercise for warm-up and conditioning",
                    category="cardio",
                    muscle_group="full_body",
                    equipment="None",
                    difficulty="beginner",
                    instructions="1. Start standing with feet together, arms at sides\n2. Jump while spreading legs and raising arms overhead\n3. Jump back to starting position\n4. Repeat rhythmically",
                    tips="Land softly to protect joints. Maintain steady pace for cardio benefits.",
                    calories_per_minute=10.0
                ),
                Exercise(
                    name="Burpees",
                    description="Full-body exercise combining strength and cardio",
                    category="cardio",
                    muscle_group="full_body",
                    equipment="None",
                    difficulty="advanced",
                    instructions="1. Start in standing position\n2. Drop to squat position\n3. Kick feet back to plank\n4. Do a push-up\n5. Jump feet back to squat\n6. Jump up with arms overhead",
                    tips="This is an advanced exercise. Start with modified version if needed. Focus on form over speed.",
                    calories_per_minute=12.0
                ),
                Exercise(
                    name="Mountain Climbers",
                    description="Cardio and core exercise",
                    category="cardio",
                    muscle_group="core",
                    equipment="None",
                    difficulty="intermediate",
                    instructions="1. Start in plank position\n2. Bring one knee toward chest\n3. Quickly switch legs\n4. Continue alternating rapidly",
                    tips="Keep hips level and core engaged. The faster you go, the more cardio benefit.",
                    calories_per_minute=11.0
                ),
                Exercise(
                    name="Crunches",
                    description="Abdominal strengthening exercise",
                    category="strength",
                    muscle_group="core",
                    equipment="None",
                    difficulty="beginner",
                    instructions="1. Lie on back with knees bent\n2. Place hands behind head (don't pull)\n3. Lift shoulders off floor\n4. Lower back down with control",
                    tips="Don't pull on your neck. Focus on using abdominal muscles to lift.",
                    calories_per_minute=4.0
                )
            ]
            
            for exercise in exercises:
                db.session.add(exercise)
            
            print("Sample exercises added successfully!")
        
        # Add sample workout plans
        if WorkoutPlan.query.count() == 0:
            workout_plans = [
                WorkoutPlan(
                    name="Beginner Full Body",
                    description="Perfect for beginners starting their fitness journey",
                    difficulty="beginner",
                    duration_weeks=4,
                    target_goal="general_fitness",
                    equipment_needed="None required, optional: dumbbells",
                    category="full_body"
                ),
                WorkoutPlan(
                    name="Weight Loss HIIT",
                    description="High-intensity interval training for effective weight loss",
                    difficulty="intermediate",
                    duration_weeks=8,
                    target_goal="weight_loss",
                    equipment_needed="None, optional: jump rope, dumbbells",
                    category="cardio"
                ),
                WorkoutPlan(
                    name="Muscle Building",
                    description="Progressive strength training for muscle gain",
                    difficulty="intermediate",
                    duration_weeks=12,
                    target_goal="muscle_gain",
                    equipment_needed="Dumbbells, resistance bands",
                    category="strength"
                )
            ]
            
            for plan in workout_plans:
                db.session.add(plan)
            
            db.session.commit()
            
            # Add workout exercises to plans
            beginner_plan = WorkoutPlan.query.filter_by(name="Beginner Full Body").first()
            if beginner_plan:
                exercises = Exercise.query.all()
                for i, exercise in enumerate(exercises[:5]):  # Add first 5 exercises
                    workout_exercise = WorkoutExercise(
                        workout_plan_id=beginner_plan.id,
                        exercise_id=exercise.id,
                        day_of_week=1,  # Monday
                        sets=3,
                        reps=10 if exercise.category == "strength" else 30,
                        rest_seconds=60,
                        order=i+1
                    )
                    db.session.add(workout_exercise)
            
            print("Sample workout plans added successfully!")
        
        # Add health tips
        if HealthTip.query.count() == 0:
            health_tips = [
                HealthTip(
                    title="Stay Hydrated Throughout the Day",
                    content="Drink at least 8 glasses of water daily. Proper hydration is essential for muscle function, energy levels, and overall health. Carry a water bottle with you and sip throughout the day.",
                    category="nutrition",
                    author="RSK World Fitness Team",
                    is_featured=True
                ),
                HealthTip(
                    title="Get Enough Quality Sleep",
                    content="Aim for 7-9 hours of quality sleep each night. Sleep is crucial for muscle recovery, hormone regulation, and overall health. Create a consistent sleep schedule and optimize your sleep environment.",
                    category="recovery",
                    author="RSK World Fitness Team",
                    is_featured=True
                ),
                HealthTip(
                    title="Include Protein in Every Meal",
                    content="Protein helps build and repair muscles. Include a source of lean protein in every meal - chicken, fish, eggs, beans, or plant-based alternatives. Aim for 1.6-2.2g per kg of bodyweight daily if you're active.",
                    category="nutrition",
                    author="RSK World Fitness Team",
                    is_featured=False
                ),
                HealthTip(
                    title="Warm Up Before Every Workout",
                    content="Always spend 5-10 minutes warming up before exercise. This increases blood flow to muscles, reduces injury risk, and improves performance. Include light cardio and dynamic stretching.",
                    category="safety",
                    author="RSK World Fitness Team",
                    is_featured=False
                ),
                HealthTip(
                    title="Listen to Your Body",
                    content="Pay attention to signals from your body. Distinguish between normal muscle soreness and pain that could indicate injury. Rest when needed and don't push through sharp pain.",
                    category="safety",
                    author="RSK World Fitness Team",
                    is_featured=False
                ),
                HealthTip(
                    title="Consistency Over Intensity",
                    content="Regular moderate exercise is better than occasional intense workouts followed by long breaks. Aim for consistency in your fitness routine for long-term results.",
                    category="motivation",
                    author="RSK World Fitness Team",
                    is_featured=True
                ),
                HealthTip(
                    title="Track Your Progress",
                    content="Keep a workout log to track your exercises, weights, reps, and how you feel. This helps you see progress over time and identify areas for improvement.",
                    category="exercise",
                    author="RSK World Fitness Team",
                    is_featured=False
                ),
                HealthTip(
                    title="Mix Up Your Routine",
                    content="Prevent boredom and plateaus by varying your workouts. Try new exercises, change your rep ranges, or try different types of cardio to keep challenging your body.",
                    category="exercise",
                    author="RSK World Fitness Team",
                    is_featured=False
                )
            ]
            
            for tip in health_tips:
                db.session.add(tip)
            
            print("Health tips added successfully!")
        
        # Commit all changes
        db.session.commit()
        print("\nDatabase initialization completed successfully!")
        print("Sample data has been added to help you get started.")

if __name__ == "__main__":
    try:
        init_database()
    except Exception as e:
        print(f"Error initializing database: {e}")
        sys.exit(1)
256 lines•12.7 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer