Skip to content

Identity & Access Flows

This document visualizes the complete authentication and identity verification logic for the Singular Dream platform.

Mermaid Diagram

graph TD
    %% Nodes
    User([User])
    Landing[Landing Page / App]

    subgraph LoginModal [Login Modal]
        direction TB
        TabEmail{Tab: Member}
        TabPhone{Tab: Vendor}
        LinkForgot[Forgot Password?]
        LinkRequest[Request Access]
    end

    subgraph AuthProviders [Authentication Providers]
        Firebase[Firebase Auth]
        Twilio[Twilio SMS]
        ServerActions[Server Actions]
    end

    subgraph Wizard [Access Request Wizard]
        step1[Step 1: Auth Method]
        step2[Step 2: Category]
        step3[Step 3: Role & Unit]
        step4[Step 4: Evidence Upload]
        stepSubmit[Submit Request]
    end

    subgraph Backend [System Backend]
        Firestore[(Firestore DB)]
        Admin[Admin Dashboard]
    end

    %% Flows
    User --> Landing
    Landing -- "Start Session" --> LoginModal

    %% Member Flow
    LoginModal --> TabEmail
    TabEmail -- "Email/Pass" --> Firebase
    TabEmail -- "Google Sign-In" --> Firebase
    TabEmail -- "Reset" --> LinkForgot --> Firebase

    %% Vendor Flow
    LoginModal --> TabPhone
    TabPhone -- "Input Phone" --> ServerActions
    ServerActions -- "sendOtp" --> Twilio
    Twilio -- "SMS Code" --> User
    User -- "Input Code" --> ServerActions
    ServerActions -- "verifyOtp" --> Firebase
    Firebase -- "Custom Token" --> Landing

    %% Access Request Flow
    LoginModal -- "New Member?" --> LinkRequest
    LinkRequest --> |Redirect| Wizard

    Wizard --> step1
    step1 -- "Google/Email Link" --> Firebase
    step1 --> step2 --> step3 --> step4 --> stepSubmit

    stepSubmit -- "Create Doc" --> Firestore
    Firestore -- "Pending Request" --> Admin

    %% Success State
    Firebase -- "Token" --> Landing
    Landing -- "Authenticated" --> Dashboard[User Dashboard]

    %% Styling
    classDef yellow fill:#FFC107,stroke:#333,stroke-width:2px,color:black;
    classDef dark fill:#1a1a1a,stroke:#FFC107,stroke-width:1px,color:white;

    class TabEmail,TabPhone,LinkForgot,LinkRequest dark;
    class Firebase,Twilio yellow;

Version History

Version Date Author Change
0.1.0 2026-01-29 Antigravity Initial Audit & Metadata Injection