```python # ======================================================================== # PROJECT: User Onboarding Flow # VERSION: 1.0.0 # DESCRIPTION: Handles user registration, account creation, # parallel profile setup, and dashboard entry. # ======================================================================== # --- GLOBAL STATE DEFINITIONS --- $user_id = null $onboarding_status = "not_started" $account_created = false # --- MODULE: PROFILE SETUP (The Parallel Block) --- # This module handles three tasks that can happen in any order. Module ProfileSetup { docs: "docs/profile_setup.md", # Start by splitting the flow into three parallel paths Profile.Start F-> [Profile.Username, Profile.Photo, Profile.Interests] # Individual Node Logic Profile.Username /input /save {name} -> Profile.Join Profile.Photo /upload /save {img} -> Profile.Join Profile.Interests /select /save {tags} -> Profile.Join # Synchronize: Wait for ALL three to finish before completing the module [Profile.Username, Profile.Photo, Profile.Interests] J-> Profile.Complete return {profile_complete: true} } # --- MAIN APPLICATION FLOW --- # 1. Welcome & Email Entry Welcome.Screen /start /show [doc: "docs/welcome.md"] {email} -> Auth.ValidateEmail # 2. Email Validation (Branching Logic) Auth.ValidateEmail /check /verify {email} ? [ exists -> Welcome.Error {msg: "Email already taken"} -> Welcome.Screen, available -> Auth.CreateAccount ] # 3. Account Creation (External API & Async Wait) Auth.CreateAccount /execute /call [doc: "docs/account_creation.md"] EXT:AuthService.CreateAccount /post /register {$api_key} {email} -> WAIT (Account_Created) T [5m] -> Auth.Timeout_Handler # If API takes > 5 mins, fail -> $user_id = {uid} -> $account_created = true -> Call ProfileSetup # 4. Transition to Dashboard ProfileSetup.Complete -> Dashboard.Welcome /render /show {$user_id} -> $onboarding_status = "completed" -> Dashboard.Home # 5. Error Handling (The Dead Letter / Recovery) Auth.Timeout { # If the user abandons the process # Redirect to a "Resume Account" page Page.Recovery /redirect } # --- END OF GRAPH --- ```