Skip to main content

Sanctiv App - Navigation Flow Map

Generated: 2025-11-20
Status: Current as of Flow Engine v1.0

Table of Contents


Authentication Flows

Unauthenticated Users

┌─────────────┐
│  App Start  │
└──────┬──────┘

       ├─ isAuthenticated = false


┌─────────────┐
│ Login Screen│ ◄──┐
└──────┬──────┘    │
       │           │
       ├─ "Sign Up"│
       │           │
       ▼           │
┌─────────────┐   │
│SignUp Screen├───┘
└──────┬──────┘

       ├─ Success


   [Main App]

First-Time Users (Authenticated)

┌─────────────────┐
│ Login Success   │
└────────┬────────┘

         ├─ hasJournalEntries = false


┌─────────────────┐
│ Welcome Screen  │ (3 seconds, auto-navigate)
│  "Preparing..."  │
└────────┬────────┘


┌─────────────────┐
│   Main Tabs     │
└─────────────────┘

Returning Users

┌─────────────────┐
│ Login Success   │
└────────┬────────┘

         ├─ hasJournalEntries = true


┌─────────────────┐
│   Main Tabs     │ (Skip Welcome)
└─────────────────┘

Main App Structure

Bottom Tab Navigation (4 Tabs)

┌────────────────────────────────────────┐
│            Main Tabs                   │
├──────────┬──────────┬────────┬─────────┤
│ Journal  │Companions│ Goals  │ Progress│
│  (book)  │ (people) │ (flag) │ (chart) │
└──────────┴──────────┴────────┴─────────┘
Each tab contains its own Stack Navigator.

Journal Flow

Journal Stack Structure

JournalStack

├─ JournalHome (Main Screen)
│  └─ Header: "Journal" + UserProfileHeader

├─ WriteJournal (fullScreenModal)
│  └─ Blank page journal entry

└─ EntryDetail
   └─ View past journal entry

User Journey: Creating a Journal Entry

┌────────────────┐
│  JournalHome   │
└───────┬────────┘

        ├─ Empty State: Shows "Begin Your Journey"
        │  └─ Button: "Start Writing"

        ├─ With Entries: Shows list of entries
        │  └─ Button: + (floating action button)


┌────────────────┐
│  GuidedJournal │ (New as of v1.0)
│  Intro Screen  │
└───────┬────────┘

        ├─ Back Arrow (←) → Returns to JournalHome

        ├─ Option 1: "Start Guided Session →"
        │   └─ Goes to 13-step flow (see Flow Engine section)

        └─ Option 2: "Start with Blank Page"
            └─ Goes to WriteJournal screen

WriteJournal Screen (Blank Page)

┌────────────────────┐
│  WriteJournal      │
│  (Modal)           │
├────────────────────┤
│ • Mood picker      │
│ • Text input       │
│ • Voice input      │
│ • Cancel/Save btns │
└─────────┬──────────┘

          ├─ Save → Saves to Supabase
          │         (with orgId)

          └─ Cancel → Back to JournalHome

Guided Journal Flow Engine

Flow Container Architecture

┌──────────────────────────────────────┐
│     FlowContainer                    │
│     (Conductor/Orchestrator)         │
├──────────────────────────────────────┤
│                                      │
│  ┌────────────────────────────────┐ │
│  │   FlowContext (State)          │ │
│  │  • Current step                │ │
│  │  • Session data                │ │
│  │  • Progress tracking           │ │
│  └────────────────────────────────┘ │
│                                      │
│  ┌────────────────────────────────┐ │
│  │   StepRenderer                 │ │
│  │  • Dynamically renders         │ │
│  │    content type components     │ │
│  └────────────────────────────────┘ │
│                                      │
│  ┌────────────────────────────────┐ │
│  │   Content Types                │ │
│  │  • PickerType                  │ │
│  │  • TextPromptType              │ │
│  │  • BreathingType               │ │
│  │  │  • ScriptureType              │ │
│  │  • MessageType                 │ │
│  │  • SummaryType                 │ │
│  └────────────────────────────────┘ │
│                                      │
│  ┌────────────────────────────────┐ │
│  │   Components                   │ │
│  │  • ProgressBar                 │ │
│  │  • NavigationControls          │ │
│  │  • BreathingCircle             │ │
│  │  • IntensitySlider             │ │
│  │  • PickerGrid                  │ │
│  └────────────────────────────────┘ │
└──────────────────────────────────────┘

Guided Session Flow (13 Steps)

Intro Screen

─────────────────────────────────────
PHASE 1: OPENING (4 steps)
─────────────────────────────────────
1. Mood Check        (picker)
2. What's Happening  (text-prompt)
3. Intensity         (picker)
4. What Matters      (text-prompt)

─────────────────────────────────────
PHASE 2: PROCESS (3 steps)
─────────────────────────────────────
5. Emotions          (picker)
6. Body Sensations   (picker)
7. Thoughts          (text-prompt)

─────────────────────────────────────
PHASE 3: ANCHOR (3 steps)
─────────────────────────────────────
8. Breathing         (breathing-exercise)
9. Scripture         (scripture-selection) *
10. Paraphrase       (text-prompt)

─────────────────────────────────────
PHASE 4: RESPOND (2 steps)
─────────────────────────────────────
11. Prayer           (text-prompt) **
12. Action Step      (text-prompt)

─────────────────────────────────────
PHASE 5: CLOSE (1 step)
─────────────────────────────────────
13. Summary          (summary) ***

Complete → Saves to Supabase
          Returns to JournalHome

* AI Scripture suggestions (Phase 4 - deferred)
** AI Prayer generation (Phase 4 - deferred)
*** AI Summary (Phase 4 - deferred)

Session Persistence

Flow Engine → TemplateManager

         ┌──────────┴──────────┐
         │                     │
         ▼                     ▼
   AsyncStorage         Supabase
   (Auto-save)     (On Complete)
   
   • Draft saved every step
   • Final save includes:
     - userId
     - orgId (RLS)
     - All responses
     - Timestamps

Flow Engine Templates

Available Templates

Template IDNameStepsDurationCategory
sanctiv-journal-v1Sanctiv Journal13~12 minSpiritual Growth
quick-gratitude-v1Quick Gratitude3~2 minGratitude
prayer-focus-v1Prayer Focus3~5 minPrayer
win-tracker-v1Win Tracker4~3 minCoaching

Template Structure

JournalTemplate
├─ id: string
├─ name: string
├─ description: string
├─ category: string
├─ estimatedMinutes: number
└─ phases: Phase[]
    └─ Phase
        ├─ id: string
        ├─ title: string
        └─ steps: TemplateStep[]
            └─ TemplateStep
                ├─ id: string
                ├─ type: ContentType
                ├─ title: string
                ├─ prompt: string
                └─ config: StepConfig

Companions Flow

Companions Stack Structure

CompanionsStack

├─ CompanionsHome (Main Screen)
│  └─ Header: "Companions" + UserProfileHeader

├─ AddCompanion (modal)
│  └─ Create new companion

├─ CompanionProfile (modal)
│  └─ View/edit companion details

└─ Chat (fullScreen)
   └─ 1:1 conversation with companion

User Journey: Companion Interaction

┌────────────────┐
│ CompanionsHome │
└───────┬────────┘

        ├─ "Add Companion" button
        │  └─→ AddCompanion (modal)

        ├─ Tap companion card
        │  └─→ CompanionProfile (modal)
        │        │
        │        ├─ "Start Conversation"
        │        │  └─→ Chat screen
        │        │
        │        └─ View stats, insights, settings

        └─ Tap "Message" on card
           └─→ Chat screen directly

Goals & Progress

Simple Stack Structures

Goals Stack

GoalsStack

└─ GoalsHome
   └─ Header: "Goals" + UserProfileHeader

Progress Stack

ProgressStack

└─ ProgressHome
   └─ Header: "Progress" + UserProfileHeader
Note: These are placeholder screens for future implementation

Settings & Profile

Global Modals (Available from any tab)

Any Screen (via UserProfileHeader)

      ├─ Tap profile avatar
      │  └─→ Profile (modal)

      └─ Tap settings icon
         └─→ Settings (modal)

              ├─ Account settings
              ├─ Notifications
              ├─ Privacy
              └─ Sign Out
                 └─→ Login screen

Complete User Journey Map

New User (Full Journey)

1. App Launch
   └─→ Login

2. First Login
   └─→ Welcome Screen (3s)
       └─→ Main Tabs (Journal tab)

3. Empty State
   └─→ "Begin Your Journey"
       └─→ "Start Writing" button
           └─→ GuidedJournal Intro

4. Choose Path
   ├─→ "Start Guided Session" (13 steps)
   │   └─→ Complete → Saves to DB
   │       └─→ Back to JournalHome (now with entries)

   └─→ "Start with Blank Page"
       └─→ WriteJournal
           └─→ Save → Back to JournalHome

Returning User (Typical Session)

1. App Launch
   └─→ Login
       └─→ Main Tabs (Journal tab)

2. JournalHome (with entries)
   └─→ Tap + button
       └─→ GuidedJournal Intro
           ├─→ Choose Guided (13 steps)
           └─→ Choose Blank Page

3. Browse past entries
   └─→ Tap entry card
       └─→ EntryDetail
           └─→ View content, AI insights

Maximum Depth by Tab

TabMax DepthExample Path
Journal3 levelsJournal → Guided Intro → Step 1-13 → Complete
Journal (Alt)2 levelsJournal → WriteJournal → Save
Companions3 levelsCompanions → CompanionProfile → Chat
Goals1 levelGoals (single screen)
Progress1 levelProgress (single screen)

Global Modals (Overlay)

  • Settings (any tab)
  • Profile (any tab)

Deep Linking (Future)

Structure ready for deep links:
sanctiv://journal/entry/:entryId
sanctiv://companions/chat/:companionId
sanctiv://guided-session/:templateId

Technical Details

  • expo-router - File-based routing (built on React Navigation)
  • Hooks: useRouter, useLocalSearchParams, useFocusEffect, usePathname

Presentation Modes

ScreenModeBehavior
guided-journalfullScreenModalFull screen, slide up
companions/addmodalCard modal (iOS)
companions/[id]modalCard modal (iOS)
profilemodalCard modal (iOS)

State Management

  • Auth State: Zustand (authStore)
  • Journal State: Zustand (journalStore)
  • Flow Engine State: React Context (FlowContext)
  • Navigation State: Expo Router built-in

Key Files

FilePurpose
src/navigation/AppNavigator.tsxMain navigation container
src/flow-engine/FlowContainer.tsxFlow engine orchestrator
src/flow-engine/FlowContext.tsxFlow session state
src/templates/index.tsTemplate registry
src/screens/GuidedJournalTestScreen.tsxEntry point for guided flow

Future Enhancements

Planned Navigation Features

  1. Deep Linking - Direct links to specific entries/sessions
  2. Tab Badge Counts - Unread companion messages
  3. Onboarding Flow - First-time setup wizard
  4. Template Selection - Choose from multiple templates
  5. History/Drafts - Resume incomplete sessions

Debugging Tips

View Navigation State

// In AppNavigator.tsx
<NavigationContainer
  onStateChange={(state) => {
    console.log('Navigation State:', state);
  }}
>

Check Current Route

import { usePathname, useSegments } from 'expo-router';

const pathname = usePathname();
const segments = useSegments();
console.log('Current Path:', pathname);
console.log('Segments:', segments);

Test Flow Engine State

// In any flow step
const { session, currentStepNumber, totalSteps } = useFlow();
console.log(`Step ${currentStepNumber}/${totalSteps}`, session);

Last Updated: November 20, 2025
Flow Engine Version: 1.0.0
Templates: 4 (1 main + 3 quick)