Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions TalkHeal.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

import streamlit as st
from auth.auth_utils import init_db
from components.login_page import show_login_page
from core.utils import save_conversations, load_conversations
from components.onboarding import onboarding_flow


# HANDLES ALL SESSION STATE VALUES
Expand Down Expand Up @@ -38,11 +40,17 @@ def init_session_state():
if "show_signup" not in st.session_state:
st.session_state.show_signup = False


# --- LOGIN PAGE ---
if not st.session_state.authenticated:
show_login_page()
st.stop()

# --- ONBOARDING FOR FIRST-TIME USERS ---
if not st.session_state.get("has_onboarded", False):
onboarding_flow()
st.stop()

# --- TOP RIGHT BUTTONS: THEME TOGGLE & LOGOUT ---
if st.session_state.get("authenticated", False):
col_spacer, col_theme, col_emergency, col_about, col_logout = st.columns([0.7, 0.1, 0.35, 0.2, 0.2])
Expand Down
101 changes: 101 additions & 0 deletions components/onboarding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
"""
Onboarding component for first-time users.
Guides through profile setup, AI tone selection, and a quick app tour.
"""

import streamlit as st
from components.profile import initialize_profile_state, render_profile_settings
from core.peer_matching import MENTAL_HEALTH_CONCERNS, INTERESTS, save_user_profile

AI_TONES = [
"Empathetic",
"Motivational",
"Calm",
"Friendly",
"Professional"
]

FEATURE_TOUR = [
{"title": "Mood Tracker", "desc": "Log and visualize your mood over time."},
{"title": "Self-Help Tools", "desc": "Access exercises and resources for well-being."},
{"title": "Focus Sessions", "desc": "Guided sessions to help you concentrate and relax."},
{"title": "Profile & Personalization", "desc": "Customize your experience and preferences."},
{"title": "Peer Groups", "desc": "Connect with others who share similar interests and experiences."}
]

def onboarding_flow():
initialize_profile_state()
if "onboarding_step" not in st.session_state:
st.session_state.onboarding_step = 0
if "user_profile" not in st.session_state:
st.session_state.user_profile = {}

step = st.session_state.onboarding_step

if step == 0:
st.title("πŸ‘‹ Welcome to TalkHeal!")
st.write("Let's set up your profile to personalize your experience.")
render_profile_settings()
if st.button("Next: Choose AI Tone", type="primary"):
st.session_state.onboarding_step = 1
st.rerun()
elif step == 1:
st.title("πŸ€– Choose Your AI Tone")
st.write("How would you like the AI to interact with you?")
tone = st.radio("Select a tone:", AI_TONES, key="ai_tone_radio")
if st.button("Next: Interests & Concerns", type="primary"):
st.session_state.user_profile["ai_tone"] = tone
st.session_state.onboarding_step = 2
st.rerun()
elif step == 2:
st.title("🧠 Your Interests & Concerns")
st.write("This helps us connect you with like-minded peers.")

col1, col2 = st.columns(2)
with col1:
st.subheader("Mental Health Areas")
selected_concerns = st.multiselect(
"Select areas you'd like support with:",
options=MENTAL_HEALTH_CONCERNS,
default=[],
help="Choose topics you're interested in discussing"
)

with col2:
st.subheader("Personal Interests")
selected_interests = st.multiselect(
"Select your interests:",
options=INTERESTS,
default=[],
help="Activities and topics you enjoy"
)

if st.button("Next: App Tour", type="primary"):
# Save to user profile
if selected_concerns or selected_interests:
st.session_state.user_profile["concerns"] = selected_concerns
st.session_state.user_profile["interests"] = selected_interests

# If authenticated, save to database
if st.session_state.get("authenticated", False):
save_user_profile(
email=st.session_state.user_email,
name=st.session_state.user_name,
concerns=selected_concerns,
interests=selected_interests
)

st.session_state.onboarding_step = 3
st.rerun()
elif step == 3:
st.title("πŸš€ Quick App Tour")
st.write("Here's what you can do in TalkHeal:")
for feature in FEATURE_TOUR:
st.markdown(f"**{feature['title']}**: {feature['desc']}")
if st.button("Finish Onboarding", type="primary"):
st.session_state.onboarding_step = 4
st.session_state.has_onboarded = True
st.success("You're all set! Enjoy using TalkHeal.")
st.rerun()
else:
st.success("Onboarding complete! You can update your profile or preferences anytime from the sidebar.")
3 changes: 2 additions & 1 deletion components/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def initialize_profile_state():
"name": "",
"profile_picture": None,
"join_date": datetime.now().strftime("%B %Y"),
"font_size": "Medium"
"font_size": "Medium",
"ai_tone": "Empathetic"
}


Expand Down
6 changes: 5 additions & 1 deletion components/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,11 @@ def render_sidebar():
if st.button("πŸ“Œ View Pinned Messages", use_container_width=True):
st.session_state.active_page = "PinnedMessages"
st.rerun()


# Peer Groups navigation
if st.button("πŸ‘₯ Find Peer Groups", use_container_width=True):
st.switch_page("pages/PeerGroups.py")


with st.sidebar:
# Theme Settings Section
Expand Down
Loading