kanakkk789 commited on
Commit
7883aa8
Β·
verified Β·
1 Parent(s): d97a87b

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +161 -127
src/streamlit_app.py CHANGED
@@ -1,169 +1,203 @@
1
  import streamlit as st
2
  import time
3
-
4
- st.set_page_config(page_title="FitPlan AI", page_icon="πŸ’ͺ", layout="centered")
5
-
6
- # ------------------ CUSTOM CSS ------------------
 
 
 
 
 
 
 
 
 
 
7
  st.markdown("""
8
  <style>
9
- .main {
10
- background-color: #f8fafc;
 
 
 
 
 
 
 
 
 
 
 
 
11
  }
12
- .section-card {
13
- background-color: white;
 
14
  padding: 25px;
15
  border-radius: 15px;
16
- box-shadow: 0px 6px 18px rgba(0,0,0,0.05);
17
- margin-bottom: 25px;
18
- }
19
- h3 {
20
- margin-top: 0px;
21
  }
 
22
  .stButton>button {
23
- background-color: black;
24
  color: white;
25
  border-radius: 10px;
26
- padding: 10px 25px;
 
 
27
  font-weight: 600;
28
  }
 
29
  .stButton>button:hover {
30
- background-color: #333;
31
  }
32
- </style>
33
- """, unsafe_allow_html=True)
34
-
35
- # ------------------ HEADER ------------------
36
- st.title("πŸ’ͺ FitPlan AI")
37
- st.subheader("Complete Fitness Profile Setup")
38
 
39
- st.divider()
40
-
41
- # ------------------ USER PROFILE FORM ------------------
 
 
 
 
42
 
43
- with st.form("profile_form"):
 
44
 
45
- st.markdown("### πŸ‘€ Personal Information")
46
 
47
- col1, col2 = st.columns(2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
- with col1:
50
  name = st.text_input("Full Name")
51
- age = st.number_input("Age", 15, 70, 21)
52
- gender = st.selectbox("Gender", ["Female", "Male", "Other"])
53
-
54
- with col2:
55
- height = st.number_input("Height (cm)", 120, 220, 160)
56
- weight = st.number_input("Weight (kg)", 30, 150, 55)
57
- fitness_level = st.selectbox("Fitness Level", ["Beginner", "Intermediate", "Advanced"])
58
-
59
- st.divider()
60
-
61
- st.markdown("### 🎯 Fitness Goals")
62
 
63
- primary_goal = st.selectbox(
64
- "Primary Goal",
65
- ["Build Muscle", "Lose Weight", "Fat Loss", "Endurance", "Flexibility", "General Fitness"]
66
- )
67
 
68
- target_weight = st.number_input("Target Weight (kg)", 30, 150, 50)
69
- workout_days = st.slider("Workout Days per Week", 2, 7, 4)
70
 
71
- st.divider()
72
 
73
- st.markdown("### πŸ‹οΈ Workout Preferences")
 
 
 
74
 
75
- equipment = st.multiselect(
76
- "Available Equipment",
77
- ["No Equipment", "Dumbbells", "Resistance Bands", "Barbell", "Full Gym"]
78
- )
79
 
80
- workout_duration = st.selectbox(
81
- "Preferred Workout Duration",
82
- ["30 mins", "45 mins", "60 mins", "90 mins"]
83
- )
84
 
85
- preferred_time = st.selectbox(
86
- "Preferred Workout Time",
87
- ["Morning", "Afternoon", "Evening"]
88
- )
89
 
90
- st.divider()
 
 
 
91
 
92
- st.markdown("### πŸ₯— Lifestyle & Diet")
 
 
 
93
 
94
- diet_type = st.selectbox(
95
- "Diet Preference",
96
- ["Vegetarian", "Non-Vegetarian", "Vegan", "Keto", "No Preference"]
97
- )
98
 
99
- sleep_hours = st.slider("Average Sleep (hours)", 4, 10, 7)
 
 
 
 
 
 
 
100
 
101
- water_intake = st.slider("Water Intake (liters/day)", 1, 5, 2)
 
102
 
103
- stress_level = st.selectbox(
104
- "Stress Level",
105
- ["Low", "Moderate", "High"]
106
- )
107
 
108
- st.divider()
109
 
110
- st.markdown("### βš• Health Conditions")
111
 
112
- injuries = st.text_area("Any injuries or medical conditions?")
113
- medications = st.text_area("Are you on any medications?")
 
 
114
 
115
- st.divider()
 
116
 
117
- submitted = st.form_submit_button("Create My Fitness Profile")
118
-
119
- # ------------------ AFTER SUBMISSION ------------------
120
-
121
- if submitted:
122
-
123
- if name == "":
124
- st.error("Please enter your name.")
125
  else:
126
 
127
- with st.spinner("Creating your fitness profile..."):
128
- time.sleep(2)
129
-
130
- st.success(f"Profile Created Successfully, {name}! πŸ”₯")
131
-
132
- st.divider()
133
-
134
- # ------------------ PROFILE SUMMARY ------------------
135
-
136
- st.markdown("## πŸ“Š Your Fitness Summary")
137
-
138
- bmi = weight / ((height/100) ** 2)
139
-
140
- col1, col2 = st.columns(2)
141
-
142
- with col1:
143
- st.metric("BMI", round(bmi, 2))
144
- st.metric("Current Weight", f"{weight} kg")
145
- st.metric("Target Weight", f"{target_weight} kg")
146
-
147
- with col2:
148
- st.metric("Workout Days", workout_days)
149
- st.metric("Sleep Hours", sleep_hours)
150
- st.metric("Water Intake", f"{water_intake} L")
151
-
152
- st.divider()
153
-
154
- st.markdown("### πŸ“ Complete Profile Details")
155
 
156
- st.write({
157
- "Name": name,
158
- "Age": age,
159
- "Gender": gender,
160
- "Fitness Level": fitness_level,
161
- "Goal": primary_goal,
162
- "Equipment": equipment,
163
- "Workout Duration": workout_duration,
164
- "Preferred Time": preferred_time,
165
- "Diet": diet_type,
166
- "Stress Level": stress_level,
167
- "Injuries": injuries,
168
- "Medications": medications
169
- })
 
1
  import streamlit as st
2
  import time
3
+ import json
4
+
5
+ # -----------------------
6
+ # PAGE CONFIG
7
+ # -----------------------
8
+ st.set_page_config(
9
+ page_title="FitPlan AI",
10
+ page_icon="πŸ’ͺ",
11
+ layout="wide",
12
+ )
13
+
14
+ # -----------------------
15
+ # CUSTOM CSS (MODERN UI)
16
+ # -----------------------
17
  st.markdown("""
18
  <style>
19
+
20
+ body {
21
+ background-color: #0E1117;
22
+ }
23
+
24
+ .main-title {
25
+ font-size: 42px;
26
+ font-weight: 700;
27
+ color: white;
28
+ }
29
+
30
+ .subtitle {
31
+ font-size: 18px;
32
+ color: #A0AEC0;
33
  }
34
+
35
+ .card {
36
+ background-color: #1C1F26;
37
  padding: 25px;
38
  border-radius: 15px;
39
+ box-shadow: 0px 4px 20px rgba(0,0,0,0.4);
 
 
 
 
40
  }
41
+
42
  .stButton>button {
43
+ background: linear-gradient(90deg, #4F46E5, #7C3AED);
44
  color: white;
45
  border-radius: 10px;
46
+ height: 3em;
47
+ width: 100%;
48
+ font-size: 16px;
49
  font-weight: 600;
50
  }
51
+
52
  .stButton>button:hover {
53
+ background: linear-gradient(90deg, #6366F1, #8B5CF6);
54
  }
 
 
 
 
 
 
55
 
56
+ .plan-box {
57
+ background-color: #1F2937;
58
+ padding: 20px;
59
+ border-radius: 10px;
60
+ margin-bottom: 15px;
61
+ color: white;
62
+ }
63
 
64
+ </style>
65
+ """, unsafe_allow_html=True)
66
 
 
67
 
68
+ # -----------------------
69
+ # SIDEBAR NAVIGATION
70
+ # -----------------------
71
+ st.sidebar.title("πŸ’ͺ FitPlan AI")
72
+ page = st.sidebar.radio(
73
+ "Navigate",
74
+ ["🏠 Home", "πŸ‘€ User Profile", "πŸ“ Fitness Details", "πŸ“… Generated Plan"]
75
+ )
76
+
77
+
78
+ # -----------------------
79
+ # HOME PAGE
80
+ # -----------------------
81
+ if page == "🏠 Home":
82
+ st.markdown("<div class='main-title'>FitPlan AI</div>", unsafe_allow_html=True)
83
+ st.markdown("<div class='subtitle'>Your Personalized AI Fitness Planner</div>", unsafe_allow_html=True)
84
+ st.write("")
85
+
86
+ st.markdown("""
87
+ <div class='card'>
88
+ <h3 style='color:white;'>Why FitPlan AI?</h3>
89
+ <ul style='color:#A0AEC0;'>
90
+ <li>Personalized workout plans</li>
91
+ <li>AI-powered fitness recommendations</li>
92
+ <li>Structured sets, reps & rest periods</li>
93
+ <li>No expensive personal trainer needed</li>
94
+ </ul>
95
+ </div>
96
+ """, unsafe_allow_html=True)
97
+
98
+
99
+ # -----------------------
100
+ # USER PROFILE PAGE
101
+ # -----------------------
102
+ elif page == "πŸ‘€ User Profile":
103
+
104
+ st.markdown("<div class='main-title'>User Profile</div>", unsafe_allow_html=True)
105
+ st.write("")
106
+
107
+ with st.container():
108
+ st.markdown("<div class='card'>", unsafe_allow_html=True)
109
 
 
110
  name = st.text_input("Full Name")
111
+ age = st.number_input("Age", min_value=10, max_value=80)
112
+ gender = st.selectbox("Gender", ["Male", "Female", "Other"])
113
+ height = st.number_input("Height (cm)")
114
+ weight = st.number_input("Weight (kg)")
 
 
 
 
 
 
 
115
 
116
+ if st.button("Save Profile"):
117
+ st.success("Profile saved successfully!")
 
 
118
 
119
+ st.markdown("</div>", unsafe_allow_html=True)
 
120
 
 
121
 
122
+ # -----------------------
123
+ # FITNESS DETAILS PAGE
124
+ # -----------------------
125
+ elif page == "πŸ“ Fitness Details":
126
 
127
+ st.markdown("<div class='main-title'>Enter Your Fitness Details</div>", unsafe_allow_html=True)
128
+ st.write("")
 
 
129
 
130
+ with st.container():
131
+ st.markdown("<div class='card'>", unsafe_allow_html=True)
 
 
132
 
133
+ goal = st.selectbox(
134
+ "Fitness Goal",
135
+ ["Build Muscle", "Lose Weight", "Improve Cardio", "Increase Flexibility"]
136
+ )
137
 
138
+ fitness_level = st.selectbox(
139
+ "Fitness Level",
140
+ ["Beginner", "Intermediate", "Advanced"]
141
+ )
142
 
143
+ equipment = st.multiselect(
144
+ "Available Equipment",
145
+ ["No Equipment", "Dumbbells", "Barbell", "Resistance Bands", "Gym Access"]
146
+ )
147
 
148
+ days = st.slider("Workout Days per Week", 1, 7, 3)
 
 
 
149
 
150
+ if st.button("Generate Plan"):
151
+ if not equipment:
152
+ st.error("Please select at least one equipment option.")
153
+ else:
154
+ st.session_state["goal"] = goal
155
+ st.session_state["fitness_level"] = fitness_level
156
+ st.session_state["equipment"] = equipment
157
+ st.session_state["days"] = days
158
 
159
+ with st.spinner("AI is generating your personalized plan..."):
160
+ time.sleep(2)
161
 
162
+ st.success("Plan Generated! Go to 'Generated Plan' page.")
 
 
 
163
 
164
+ st.markdown("</div>", unsafe_allow_html=True)
165
 
 
166
 
167
+ # -----------------------
168
+ # GENERATED PLAN PAGE
169
+ # -----------------------
170
+ elif page == "πŸ“… Generated Plan":
171
 
172
+ st.markdown("<div class='main-title'>Your Weekly Workout Plan</div>", unsafe_allow_html=True)
173
+ st.write("")
174
 
175
+ if "goal" not in st.session_state:
176
+ st.warning("Please fill Fitness Details first.")
 
 
 
 
 
 
177
  else:
178
 
179
+ # MOCK PLAN (Replace with LLM output later)
180
+ plan = {
181
+ "Day 1": [
182
+ "Push-ups – 3 sets Γ— 12 reps",
183
+ "Dumbbell Squats – 3 sets Γ— 15 reps",
184
+ "Plank – 3 sets Γ— 30 sec"
185
+ ],
186
+ "Day 2": [
187
+ "Lunges – 3 sets Γ— 12 reps",
188
+ "Shoulder Press – 3 sets Γ— 10 reps",
189
+ "Jumping Jacks – 3 sets Γ— 20 reps"
190
+ ],
191
+ "Day 3": [
192
+ "Deadlifts – 3 sets Γ— 10 reps",
193
+ "Bicep Curls – 3 sets Γ— 12 reps",
194
+ "Mountain Climbers – 3 sets Γ— 30 sec"
195
+ ]
196
+ }
197
+
198
+ for day, exercises in plan.items():
199
+ st.markdown(f"<div class='plan-box'><h4>{day}</h4>", unsafe_allow_html=True)
200
+ for exercise in exercises:
201
+ st.write(f"β€’ {exercise}")
202
+ st.markdown("</div>", unsafe_allow_html=True)
 
 
 
 
203