# User Journey Flows - Detailed Process Diagrams ## 1. Youth Registration Flow - Detailed ### High-Level Process ```mermaid flowchart TD Start["🔗 User Visits Platform"] -->|HTTP Request| A["Streamlit App
Port 8501"] A -->|Load| B["Check Session"] B -->|No Session| C["Show Login Page"] B -->|Has Session| D["Redirect to Dashboard"] C -->|Click 'Register'| E["Show Registration Form"] E -->|Fill Form| F{Validate Input} F -->|Invalid| G["Show Error
- Invalid Email
- Weak Password
- Email Exists"] G -->|Retry| E F -->|Valid| H["Hash Password"] H -->|Create| I["Insert into mb_users
- user_id (auto)
- email
- password_hash
- role = 'student'
- created_at"] I -->|Success| J["Create Session
st.session_state"] I -->|Failure| K["Show DB Error"] J -->|Redirect| L["Youth Dashboard"] K -->|Retry| E L -->|Load| M["Display Profile
- Student ID
- Email
- Institution"] M -->|End| N["✅ Registration Complete"] ``` ### Detailed Sequence Diagram ```mermaid sequenceDiagram actor User as Youth User
Browser participant UI as Streamlit UI
0_login.py participant Auth as Auth Module
Authentication participant Hash as Password
Hashing participant DB as SQLite DB
mb_compass.db participant Session as Session Manager
st.session_state User->>UI: Click "Register" Button UI->>UI: Display Registration Form Note over UI: Form Fields:
- Email
- Password (confirm)
- Full Name
- Institution
- Education Level User->>UI: Fill & Submit Form UI->>Auth: validate_input(form_data) Auth->>Auth: Check Email Format Auth->>Auth: Check Password Strength Auth->>DB: SELECT * FROM mb_users WHERE email=? alt Email Already Exists DB-->>Auth: User Record Found Auth-->>UI: Error: "Email Already Registered" UI-->>User: Show Error Message User->>UI: Correct Email & Retry else Email is Unique DB-->>Auth: No Records Found Auth->>Hash: hash_password(password) Hash-->>Auth: password_hash Auth->>DB: INSERT INTO mb_users Note over DB: INSERT VALUES
- null (auto id)
- email
- password_hash
- 'student' (role)
- full_name
- institution
- education_level
- NULL (phone)
- NULL (dob)
- NULL (skills)
- NOW() (created_at) DB-->>Auth: Success (user_id=X) Auth->>Session: Create Session Note over Session: st.session_state updates:
- logged_in = True
- user_id = X
- email = user@email.com
- role = 'student'
- full_name = name Session-->>Auth: Session Created Auth-->>UI: Success UI->>UI: Clear Form UI->>UI: Redirect Page UI-->>User: "Welcome! → Youth Dashboard" end ``` ### Error Handling Flow ```mermaid flowchart TD Input["User Registration
Input"] -->|Validate| A{Email Valid?} A -->|No| E1["❌ Show Error
Invalid Email Format"] E1 -->|User Retry| Input A -->|Yes| B{Password
Strong?} B -->|No| E2["❌ Show Error
Password < 8 chars"] E2 -->|User Retry| Input B -->|Yes| C{Email Unique
in DB?} C -->|No| E3["❌ Show Error
Email Already Registered"] E3 -->|User Retry| Input C -->|Yes| D["✅ Create User
in Database"] D -->|Insert Success| Success["✅ Registration
Complete"] D -->|DB Error| E4["❌ Show Error
Database Error"] E4 -->|Retry| D ``` --- ## 2. Youth Dashboard Flow - Complete User Journey ### Youth Dashboard Process ```mermaid flowchart TD A["Youth Logs In"] -->|Authenticated| B["Load Youth Dashboard
2_youth_dashboard.py"] B -->|Query| C["Get User Profile
FROM mb_users"] B -->|Query| D["Get Learning Modules
FROM learning_modules"] B -->|Query| E["Get Progress
FROM student_daily_features"] B -->|Query| F["Get Feedback Status
FROM survey_distribution_logs"] C -->|Display| G["Profile Section
- Student ID
- Email
- Full Name
- Institution
- Education Level"] D -->|Display| H["Modules Section
- List of Assigned Modules
- Module Title
- Description
- Status"] E -->|Display| I["Progress Section
- Modules Assigned
- Modules Completed
- Completion %
- Days Since Registration"] F -->|Display| J["Feedback Section
- Survey Forms
- Response Status
- Submit Button"] H -->|Click Module| K["View Module Details
- Full Description
- Duration
- Skills Covered
- Current Progress"] J -->|Click Feedback| L["Open Survey Form
1. Role Match
2. Satisfaction
3. Growth Opportunity
4. Compensation
5. Comments"] L -->|Submit| M["Validate Survey
- Required Fields
- Rating Ranges
- Comment Length"] M -->|Valid| N["Store Survey
INSERT INTO
youth_feedback_surveys"] M -->|Invalid| O["Show Validation
Errors"] O -->|Correct| L N -->|Success| P["Show Confirmation
✅ Feedback Saved"] P -->|Continue| J ``` ### Detailed Sequence Diagram - Profile & Progress ```mermaid sequenceDiagram participant Youth as Youth User participant Dashboard as Youth Dashboard
Page participant YouthService as Youth Service
Data Layer participant DB as SQLite Database participant Cache as Session Cache Youth->>Dashboard: Load Page Dashboard->>Cache: Check Cached Profile alt Cache Hit Cache-->>Dashboard: Profile Data (TTL Valid) else Cache Miss Dashboard->>YouthService: get_user_profile(user_id) YouthService->>DB: SELECT * FROM mb_users
WHERE user_id = ? DB-->>YouthService: User Record YouthService->>DB: SELECT * FROM learning_modules
WHERE user_id = ? DB-->>YouthService: Module List (2 records) YouthService->>DB: SELECT * FROM student_daily_features
WHERE user_id = ? DB-->>YouthService: Feature Record YouthService->>Cache: Store Profile YouthService-->>Dashboard: Profile Object Cache-->>Dashboard: Cached Copy end Dashboard->>Dashboard: Render Profile Section Note over Dashboard: Display:
- Student ID: MB-APAC-2026-ABC
- Email: youth@magicbus.local
- Name: Student Name
- Institution: School Name Dashboard->>Dashboard: Render Modules Section Note over Dashboard: Module 1: Python Basics
Status: In Progress (60%)
Module 2: Communication
Status: Completed Dashboard->>Dashboard: Render Progress Card Note over Dashboard: Assigned: 2
Completed: 1
Completion: 50%
Days: 15 days Dashboard-->>Youth: Display Dashboard ``` ### Feedback Survey Submission Flow ```mermaid sequenceDiagram participant Youth as Youth User participant SurveyUI as Feedback Form
Streamlit UI participant Validator as Form Validator participant DB as SQLite DB Youth->>SurveyUI: Click "Submit Feedback" SurveyUI->>Youth: Show Survey Questions Note over SurveyUI: Survey Questions:
1. Role Match (1-5)
2. Environment (1-5)
3. Growth (1-5)
4. Compensation (1-5)
5. Comments (text) Youth->>SurveyUI: Fill All Answers Youth->>SurveyUI: Click "Submit" SurveyUI->>Validator: validate_survey(form_data) Validator->>Validator: Check All Fields Filled Validator->>Validator: Check Ratings in Range Validator->>Validator: Check Comments < 500 chars alt Validation Fails Validator-->>SurveyUI: Error Messages SurveyUI-->>Youth: Show Errors & Highlights Youth->>SurveyUI: Correct Errors SurveyUI->>Validator: validate_survey(form_data) else Validation Passes Validator-->>SurveyUI: OK SurveyUI->>DB: INSERT INTO youth_feedback_surveys Note over DB: INSERT VALUES
- survey_id (auto)
- user_id
- email
- placement_company
- job_title
- rating_1, rating_2, ...
- comments
- NOW() (created_at) DB-->>SurveyUI: Inserted (survey_id=X) SurveyUI->>SurveyUI: Refresh Page SurveyUI-->>Youth: "✅ Feedback Saved Successfully" end ``` --- ## 3. Admin Control Flow - Complete ### Admin Dashboard Process ```mermaid flowchart TD A["Admin Logs In"] -->|Role Check| B{Is Admin?} B -->|No| C["❌ Access Denied"] B -->|Yes| D["Load Admin Portal
3_magicbus_admin.py"] D -->|Query| E["Load Dashboard Data
- Total Users
- Module Count
- Survey Status"] D -->|Display| F["Admin Menu"] F -->|Option 1| G["👥 User Management"] F -->|Option 2| H["📚 Module Management"] F -->|Option 3| I["📋 Survey Distribution"] F -->|Option 4| J["📊 System Reports"] G -->|Action| G1["List All Users
- User ID
- Email
- Role
- Created Date"] G1 -->|Search| G2["Filter Users
- By Email
- By Role
- By Date"] H -->|Action| H1["View Modules
- Module List
- Completion Stats
- Learner Count"] H1 -->|Edit| H2["Create/Edit Module
- Title
- Description
- Duration
- Skills"] H2 -->|Save| H3["Store in DB
INSERT/UPDATE
learning_modules"] I -->|Action| I1["Create Survey
- Select Template
- Choose Recipients
- Set Deadline"] I1 -->|Send| I2["Distribute Survey
- Send Emails
- Create Log Records
- Track Opens"] I2 -->|Store| I3["Log Distribution
INSERT
survey_distribution_logs"] J -->|Action| J1["View Reports
- Completion Rate
- Dropout Risk
- Engagement Stats"] ``` ### Admin Workflow - Detailed Sequence ```mermaid sequenceDiagram participant Admin as Admin User participant Portal as Admin Portal
3_magicbus_admin.py participant AdminSvc as Admin Service participant DB as SQLite DB participant Email as Email Service
Background Job Admin->>Portal: Navigate to Admin Portal Portal->>AdminSvc: load_dashboard() AdminSvc->>DB: SELECT COUNT(*) FROM mb_users DB-->>AdminSvc: 50 AdminSvc->>DB: SELECT COUNT(*) FROM learning_modules DB-->>AdminSvc: 16 AdminSvc-->>Portal: Dashboard Data Portal-->>Admin: Show Admin Dashboard Note over Portal: Admin Options:
- User Management
- Module Management
- Survey Distribution
- System Health Admin->>Portal: Click "Create New Module" Portal-->>Admin: Show Module Form Admin->>Portal: Fill Module Details Note over Admin: - Title: "Leadership Skills"
- Duration: 4 weeks
- Skills: Leadership, Communication
- Description: Learn to lead Admin->>Portal: Submit Form Portal->>AdminSvc: create_module(module_data) AdminSvc->>AdminSvc: Validate Module AdminSvc->>DB: INSERT INTO learning_modules Note over DB: INSERT VALUES
- module_id (auto)
- title
- description
- duration
- skills
- status = 'active' DB-->>AdminSvc: Inserted (module_id=17) AdminSvc-->>Portal: Success Portal-->>Admin: "✅ Module Created" Admin->>Portal: Click "Send Survey" Portal-->>Admin: Show Survey Distribution Form Admin->>Portal: Select Recipients & Template Admin->>Portal: Submit Portal->>AdminSvc: send_survey(recipients, template) AdminSvc->>DB: SELECT * FROM mb_users WHERE role='student' DB-->>AdminSvc: 50 Users AdminSvc->>Email: Send Emails (async) AdminSvc->>DB: INSERT INTO survey_distribution_logs (x50 records) Note over DB: Log each send:
- recipient_email
- survey_type
- sent_date
- opened = False DB-->>AdminSvc: Inserted AdminSvc-->>Portal: Success Portal-->>Admin: "✅ Surveys Sent to 50 Recipients" Email->>Email: Send 50 Emails ``` ### Module Creation & Management ```mermaid flowchart TD A["Admin: Create Module"] -->|Form| B["Enter Module Details
- Title
- Description
- Duration
- Skills
- Prerequisites
- Difficulty"] B -->|Validate| C{Valid Input?} C -->|No| D["Show Validation
Errors"] D -->|Correct| B C -->|Yes| E["Store in DB"] E -->|Query| F["INSERT INTO
learning_modules"] F -->|Success| G["✅ Module Created
module_id=X"] F -->|Failure| H["❌ Database Error"] G -->|Next| I["Assign to Youth
- Select Module
- Select Students"] I -->|Assign| J["UPDATE learning_modules
SET user_id = Y"] J -->|Success| K["✅ Assigned to
N Students"] K -->|Track| L["View Completion
- Modules Assigned
- Modules Completed
- Completion %"] L -->|Report| M["Generate Report
- Per Module Stats
- Overall Stats
- Effectiveness"] ``` --- ## 4. Decision Intelligence Flow - Complete ### Decision Intelligence Dashboard Process ```mermaid flowchart TD A["Admin: Access DI
Decision Intelligence
4_decision_intelligence_azure.py"] -->|Load| B["Initialize Components"] B -->|Create| B1["AzureBlobConnector"] B -->|Create| B2["AzureFeatureEngineer"] B -->|Create| B3["AzureDecisionDashboard"] C["Sidebar: Refresh Features
Click 🔄 Button"] -->|Trigger| D["Feature Engineering
Pipeline"] D -->|Load| D1["Load Raw Data
- From SQLite
- From Azure Blob"] D1 -->|Query| E["mb_users (50)"] D1 -->|Query| F["learning_modules (16)"] D1 -->|Query| G["student_daily_features"] D -->|Compute| H["Compute 6 Features"] H -->|Feature 1| H1["student_daily_features
- modules_assigned
- modules_completed
- avg_completion_pct"] H -->|Feature 2| H2["dropout_risk
- risk_level: HIGH/MED/LOW
- risk_score: 1-9
- risk_reason"] H -->|Feature 3| H3["sector_fit
- sector: Design, Programming...
- sector_fit_score: 0-100
- readiness_status: Green/Amber/Red"] H -->|Feature 4| H4["module_effectiveness
- completion_rate
- effectiveness_level"] H -->|Feature 5| H5["gamification_impact
- Badge earners vs non-earners
- Engagement comparison"] H -->|Feature 6| H6["mobilisation_funnel
- 4 stages
- Progression %"] D -->|Store| I["Cache Features
In Memory
TTL: 1 hour"] I -->|Return| J["Feature Data Ready
✅ All 6 Computed"] J -->|Display| TAB1["Tab 1: Executive Overview
- KPIs: 50 enrolled
- 70.9% completion
- 40% dropout"] J -->|Display| TAB2["Tab 2: Mobilisation Funnel
- Funnel Chart
- Progression Stats"] J -->|Display| TAB3["Tab 3: Sector Heatmap
- Sector vs Readiness
- Interactive Heatmap"] J -->|Display| TAB4["Tab 4: At-Risk Youth
- Student List
- Risk Scores
- Interventions"] J -->|Display| TAB5["Tab 5: Module Effectiveness
- Module Rankings
- Completion Rates"] J -->|Display| TAB6["Tab 6: Gamification
- Comparison Metrics
- Impact Analysis"] J -->|Display| TAB7["Tab 7: Proposals
- AI-Generated
- Download PDF"] ``` ### Detailed Feature Computation Flow ```mermaid sequenceDiagram participant Admin as Admin/Stakeholder participant UI as DI Dashboard UI participant Engineer as Feature Engineer participant Connector as Azure Connector participant DB as SQLite DB participant Azure as Azure Blob participant Cache as Feature Cache Admin->>UI: Click "Compute Features" Button UI->>Engineer: compute_all_features() Note over Engineer: Load Feature 1
student_daily_features Engineer->>Connector: load_dataset("student_daily_features") Connector->>Cache: Check Cache alt Cache Hit Cache-->>Connector: Return Cached else Cache Miss Connector->>DB: SELECT from student_daily_features DB-->>Connector: 50 Records Connector->>Cache: Store in Cache end Connector-->>Engineer: DataFrame (50 rows) Note over Engineer: Load Feature 2
dropout_risk Engineer->>Connector: load_dataset("student_dropout_risk") Connector->>DB: SELECT from student_dropout_risk DB-->>Connector: 50 Records Connector-->>Engineer: DataFrame Note over Engineer: Load Feature 3-6...
Similar pattern Engineer->>Engineer: Aggregate Metrics Note over Engineer: For Executive Overview:
- total_enrolled: COUNT(*) = 50
- completion_rate: AVG(completion%) = 70.9%
- dropout_risk_pct: COUNT(HIGH) / 50 = 40%
- engagement_score: (active/50)*100 = 57% Engineer->>Engineer: Build Sector Heatmap Note over Engineer: Cross-tab:
Sector x Readiness
6 sectors × 3 statuses
= 18 data points Engineer->>Engineer: Extract At-Risk Youth Note over Engineer: WHERE dropout_risk = 'HIGH'
ORDER BY risk_score DESC
LIMIT 10 Engineer-->>UI: All Features Ready UI->>UI: Render 7 Tabs UI->>UI: Tab 1: Display KPIs Note over UI: Show Cards:
- 👥 50 Enrolled
- 📚 70.9% Completion
- ⚠️ 40% Dropout UI->>UI: Tab 3: Render Heatmap Note over UI: Plotly Heatmap
X: Sector
Y: Readiness
Z: Count UI->>UI: Tab 4: Display Youth Table Note over UI: Top 10 At-Risk
- Student Name
- Risk Score
- Risk Level UI-->>Admin: Display Complete Dashboard ``` ### Proposal Generation Flow ```mermaid flowchart TD A["Admin: Proposal Tab"] -->|Form| B["Enter Proposal Params
- Region: APAC
- Sector: Design
- Grade Level: High School"] B -->|Submit| C["Generate Insights
generate_proposal_insights()"] C -->|Query| C1["Get Sector Data
- Youth in sector
- Completion rate
- Readiness status"] C -->|Query| C2["Get Effectiveness
- Module performance
- Skills coverage
- Time investment"] C -->|Analyze| C3["Calculate Metrics
- ROI potential
- Funding needs
- Timeline"] C -->|Generate| C4["Create Proposal Text
- Executive Summary
- Youth Profile
- Sector Analysis
- Resource Needs
- Expected Outcomes"] C4 -->|Format| C5["Build Proposal
- Header
- Sections
- Metrics
- Recommendations"] C5 -->|Display| D["Show Proposal
in Streamlit"] D -->|User Action| E{User Action} E -->|Download| F["Generate PDF
Proposal Document"] E -->|Copy| G["Copy to Clipboard"] E -->|Share| H["Send via Email"] F -->|Download| I["Download:
proposal_
YYYY_MM_DD.pdf"] ``` --- ## Data State Transitions ### User State Machine ```mermaid stateDiagram-v2 [*] --> NotRegistered NotRegistered -->|Register| Registered Registered -->|Submit Profile| ProfileComplete ProfileComplete -->|Start Learning| Learning Learning -->|Complete Module| ModuleComplete Learning -->|Submit Feedback| FeedbackSubmitted FeedbackSubmitted -->|[Optional] Continue| Learning ModuleComplete -->|All Done| Graduated note right of NotRegistered - New visitor - No account end note note right of Registered - Account created - Initial profile end note note right of ProfileComplete - Full details entered - Ready to learn end note note right of Learning - Active participation - Module assignments end note note right of ModuleComplete - Finished module - Progress updated end note note right of FeedbackSubmitted - Feedback recorded - Data analyzed end note ``` --- **Last Updated**: January 29, 2026