graph TD
%% Phase 1: Planning - Top Left
subgraph P1["Phase 1: Research Planning"]
A[User Input: Enter Topic] --> B{Select Planning Engine}
B --> C[Generate Research Plan]
C --> D[API: generate-plan]
D --> E[LLM Creates Structured Plan]
E --> F[Display Plan in UI]
F --> G[User Review & Edit]
end
%% Phase 2: Research Execution - Top Right
subgraph P2["Phase 2: Research Execution"]
H[User: Configure Research] --> I[API: start-research]
I --> J[Parse Research Plan]
J --> K{Research Loop}
subgraph ResearchLoop["Research Cycle"]
L[Research Subtopic]
M[Gather Findings]
end
K -->|Next| L
L --> M
M --> K
K -->|Complete| N[Compile All Research]
N --> O[Synthesize Report]
O --> P[Process Citations]
end
%% Phase 3: Refinement - Bottom Center (Reorganized)
subgraph P3["Phase 3: Analysis & Refinement"]
Q[Research Report Display]
subgraph P3Left["Improvement Path"]
R1{User Decision} -->|Re-synthesize| S[Improve Report]
S --> O
end
subgraph P3Center["Comparison Path"]
R2{User Decision} -->|Compare & Judge| T[Select Reports + Judge Engine]
T --> U[API: judge-syntheses]
U --> V[Judge LLM Evaluation]
subgraph Scoring["Scoring Process"]
V --> W[Generate Score Cards]
W --> X[Display Modal: 5 Criteria Scores + Reasoning]
end
V --> Y[Generate Final Judged Report]
end
subgraph P3Right["New Topic Path"]
R3{User Decision} -->|New Topic| Z[Start Over]
end
Q --> R1
Q --> R2
Q --> R3
Y --> Q
Z --> A
end
%% Phase Connections
G --> H
P --> Q
%% Styling for clarity
style P1 fill:#f0f9ff,stroke:#0369a1,stroke-width:2px
style P2 fill:#f0fdf4,stroke:#166534,stroke-width:2px
style P3 fill:#fef7ff,stroke:#7e22ce,stroke-width:2px
style ResearchLoop fill:#fffbeb,stroke:#f59e0b,stroke-width:1px
style P3Left fill:#fef7ff,stroke:#7e22ce,stroke-width:1px
style P3Center fill:#fef7ff,stroke:#7e22ce,stroke-width:1px
style P3Right fill:#fef7ff,stroke:#7e22ce,stroke-width:1px
style Scoring fill:#f0f9ff,stroke:#0369a1,stroke-width:1px
style A fill:#e0f2fe,stroke:#0284c7,stroke-width:2px
style Y fill:#e0e7ff,stroke:#4f46e5,stroke-width:2px
style P fill:#fef9c3,stroke:#ca8a04,stroke-width:2px
style K fill:#fef3c7,stroke:#d97706,stroke-width:2px
style X fill:#dcfce7,stroke:#16a34a,stroke-width:2px
style W fill:#dcfce7,stroke:#16a34a,stroke-width:2px