# Paddock Setup Flow — Proposed

## Full Flow

```mermaid
flowchart TD
    START([Student drops syllabus]) --> EXTRACT[Text extraction]
    EXTRACT --> DETECT{Auto-detect format}
    
    DETECT -->|"high confidence"| PARSE_OK[LLM parse with detected format]
    DETECT -->|"low confidence / ambiguous"| PARSE_GUESS[LLM parse with best guess]
    
    PARSE_OK --> STREAM[Stream modules to client]
    PARSE_GUESS --> STREAM
    
    STREAM --> EVAL{Evaluate parse quality}
    
    %% ═══════════════════════════════════════════
    %% BRANCH A: Dated syllabus (best case)
    %% ═══════════════════════════════════════════
    EVAL -->|"Dated: real dates found,\n≥6 milestones,\nmeeting days derivable"| DATED_CONFIRM
    
    DATED_CONFIRM["Show modules with weeks\n─────────────────\nMeeting days: pre-filled ✓\nTitle: shown in header\n─────────────────\n[Looks right]"]
    
    DATED_CONFIRM --> CREATE_WS

    %% ═══════════════════════════════════════════
    %% BRANCH B: Numbered syllabus
    %% ═══════════════════════════════════════════
    EVAL -->|"Numbered: week labels found,\n≥6 milestones,\nmeeting days maybe detected"| NUMBERED_CONFIRM
    
    NUMBERED_CONFIRM["Show modules with week numbers\n─────────────────\nMeeting days: pre-filled or ASK\nTitle: shown in header\n─────────────────\n[Looks right]"]
    
    NUMBERED_CONFIRM --> CREATE_WS

    %% ═══════════════════════════════════════════
    %% BRANCH C: Topic-based syllabus (hard case)
    %% ═══════════════════════════════════════════
    EVAL -->|"Topic-based: topics only,\nno temporal structure"| TOPIC_ASK
    
    TOPIC_ASK["Show discovered topics (no weeks)\n─────────────────\nWe found N topics in your syllabus.\nTo build your weekly plan, we need:\n─────────────────\nMeeting days: REQUIRED\nSemester weeks: REQUIRED\n(or derive from term dates)\n─────────────────\n[Build my plan]"]
    
    TOPIC_ASK --> SYNTHESIZE["Synthesize week plan:\n- Distribute N topics across W weeks\n- Account for meeting frequency\n- Group related topics\n- Insert reading weeks if needed"]
    
    SYNTHESIZE --> TOPIC_VALIDATE["Show synthesized week plan\n─────────────────\nWeek 1 (Mon 1/13): Negligence\nWeek 2 (Mon 1/20): Strict Liability\nWeek 3 (Mon 1/27): Products Liability\n...\n─────────────────\n[Looks right] [Adjust plan]"]
    
    TOPIC_VALIDATE -->|"Looks right"| CREATE_WS
    TOPIC_VALIDATE -->|"Adjust plan"| TOPIC_EDIT["Manual week editor\n(drag topics, split/merge weeks)"]
    TOPIC_EDIT --> CREATE_WS

    %% ═══════════════════════════════════════════
    %% BRANCH D: Parse failure / bad result
    %% ═══════════════════════════════════════════
    EVAL -->|"<4 milestones or\ngarbled results"| BAD_PARSE
    
    BAD_PARSE["Hmm, we had trouble reading this.\n─────────────────\nIs your syllabus a:\n○ Dated schedule (Jan 15: Topic)\n○ Week-by-week list (Week 1: Topic)\n○ Topic outline (just topics)\n─────────────────\n[Try again with this hint]  [Upload different file]"]
    
    BAD_PARSE -->|"Try again"| REPARSE[Re-parse with explicit format hint]
    REPARSE --> STREAM
    BAD_PARSE -->|"Upload different file"| START

    %% ═══════════════════════════════════════════
    %% COMMON: Workspace creation + enrichment
    %% ═══════════════════════════════════════════
    CREATE_WS[["Create workspace\n+ start enrichment"]] --> REDIRECT

    REDIRECT{Where to send student?}
    REDIRECT -->|"Option A"| COURSE_PAGE["→ /paddock/courseId\nCourse workspace with\nweek plan visible,\nscenarios filling in"]
    REDIRECT -->|"Option B"| FORMING_DESK["→ /dashboard\nCourseFormingDesk with\npulsing stage indicators"]


    %% Styling
    classDef ask fill:#fef3c7,stroke:#f59e0b,color:#78350f
    classDef good fill:#d1fae5,stroke:#10b981,color:#064e3b
    classDef bad fill:#fee2e2,stroke:#ef4444,color:#7f1d1d
    classDef action fill:#dbeafe,stroke:#3b82f6,color:#1e3a5a
    classDef synthesize fill:#ede9fe,stroke:#8b5cf6,color:#3b0764
    
    class DATED_CONFIRM,NUMBERED_CONFIRM,TOPIC_ASK,TOPIC_VALIDATE ask
    class CREATE_WS,COURSE_PAGE good
    class BAD_PARSE bad
    class REPARSE,SYNTHESIZE,TOPIC_EDIT action
```

## The Topic-Based Problem (zoomed in)

```mermaid
flowchart LR
    subgraph "What the syllabus gives us"
        T1[Negligence]
        T2[Strict Liability]  
        T3[Products Liability]
        T4[Vicarious Liability]
        T5[Damages]
        T6[Defenses]
        T7[Causation]
        T8[Duty]
        T9[Emotional Distress]
        T10[Economic Torts]
        T11[Review]
    end
    
    subgraph "What we need to build"
        W1["Week 1 (Mon 1/13):<br/>Negligence"]
        W2["Week 2 (Mon 1/20):<br/>Strict Liability"]
        W3["Week 3 (Mon 1/27):<br/>Products Liability +<br/>Vicarious Liability"]
        W4["Week 4 (Mon 2/3):<br/>Damages"]
        Wdots["..."]
        W14["Week 14 (Mon 4/14):<br/>Review"]
    end
    
    T1 --> W1
    T2 --> W2
    T3 --> W3
    T4 --> W3
    T5 --> W4
    T11 --> W14
```

## Missing inputs for topic-based syllabi

| Input | Source | Confidence | Required for |
|-------|--------|-----------|-------------|
| **Topics list** | Parsed from syllabus | High | Module titles |
| **Topic count** | Parsed | High | Week distribution |
| **Meeting days** | NOT in syllabus | None — must ask | Calendar mapping, meetings/week |
| **Semester length** | Maybe from term label | Medium | Total weeks to fill |
| **Semester start** | Maybe from term label | Low | Calendar date mapping |
| **Topics per week** | NOT in syllabus | None — must infer | Distribution algorithm |
| **Topic grouping** | NOT in syllabus | None — LLM can infer | Combining related topics |
| **Reading/exam weeks** | Sometimes in syllabus | Low | Gaps in schedule |

## Key questions for the topic-based flow

1. **When to ask meeting days?** 
   - Current: on confirm form (too late, already parsed)
   - Proposed: immediately after streaming, before plan synthesis
   - Alternative: before parse begins (student knows the answer, parse could use it)

2. **How to determine semester length?**
   - From term label ("Fall 2026" → ~15 weeks Aug-Dec)
   - From institution defaults (most law schools: 14-15 weeks)
   - Ask the student: "How many weeks is your semester?"
   - Infer from topic count + meeting frequency

3. **How to distribute topics across weeks?**
   - Equal distribution (11 topics / 14 weeks → some weeks have 1, some 0)
   - LLM grouping (ask LLM to cluster related topics into week-sized units)
   - Let student drag/arrange after initial proposal

4. **What's the validation step?**
   - Must show the synthesized plan before committing
   - Student needs to see "Week 3: Products Liability + Vicarious Liability"
   - Need an adjustment mechanism (not just "looks right / doesn't")

5. **What if the syllabus is PARTIALLY temporal?**
   - "Weeks 1-3: Torts fundamentals; Topics after midterm: TBD"
   - Hybrid: some weeks mapped, some topics floating
   - This is probably the most common "messy" case
