Architecture Diagrams¶
This document provides three complementary Mermaid diagrams that illustrate the GraphRAG system from different perspectives:
- User Journey Diagram - Shows the user experience flow and interactions
- Cloud Infrastructure Diagram - Shows deployment architecture and service relationships
- AI Implementation Diagram - Shows the AI/LLM processing pipeline and decision flows
1. User Journey Diagram¶
This diagram illustrates the user's perspective: how they interact with the system, what they see, and the flow of their experience.
flowchart TD
Start([User Opens Application]) --> Login[Login/Select Username]
Login --> Dashboard[Main Dashboard]
Dashboard --> AskQuestion[Ask Natural Language Question]
Dashboard --> ViewKB[Browse Knowledge Base]
Dashboard --> ViewFavorites[View Favorites]
Dashboard --> ViewHistory[View Chat History]
AskQuestion --> Processing[System Processing]
Processing --> RouteDecision{Route Decision}
RouteDecision -->|Analytics Question| AnalyticsRoute[Analytics Agent]
RouteDecision -->|Standard Query| CypherRoute[Text-to-Cypher]
AnalyticsRoute --> AnalyticsResult[Graph Algorithm Results]
CypherRoute --> CypherGen[Generate Cypher Query]
CypherGen --> ExecuteQuery[Execute on Neo4j]
ExecuteQuery --> QueryResults[Raw Query Results]
AnalyticsResult --> Summarize[Generate Summary]
QueryResults --> Summarize
Summarize --> DisplayResults[Display Results]
DisplayResults --> ShowCypher[Show Generated Cypher]
DisplayResults --> ShowTable[Show Results Table]
DisplayResults --> ShowSummary[Show Natural Language Summary]
DisplayResults --> ShowRoute[Show Route Type Badge]
ShowCypher --> UserActions{User Actions}
ShowTable --> UserActions
ShowSummary --> UserActions
ShowRoute --> UserActions
UserActions -->|Save| SaveFavorite[Save to Favorites]
UserActions -->|Ask Follow-up| AskQuestion
UserActions -->|Browse KB| ViewKB
UserActions -->|Delete| DeleteMessage[Delete Message]
SaveFavorite --> Dashboard
DeleteMessage --> Dashboard
ViewKB --> KBDetail[View Category Details]
KBDetail --> Dashboard
ViewFavorites --> Dashboard
ViewHistory --> Dashboard
style Start fill:#e4a001,stroke:#e4a001,color:#1c1d1f
style Dashboard fill:#1159af,stroke:#1159af,color:#ffffff
style Processing fill:#f7630c,stroke:#f7630c,color:#1c1d1f
style RouteDecision fill:#383e49,stroke:#e4a001,color:#e9e7e7
style DisplayResults fill:#505762,stroke:#ffd95e,color:#ffffff
2. Cloud Infrastructure Diagram¶
This diagram shows the deployment architecture, cloud services, and how components communicate in a production environment.
graph TB
subgraph "User Layer"
Browser[Web Browser]
Mobile[Mobile App]
end
subgraph "Azure Static Web Apps / CDN"
Frontend[Next.js Frontend
Port 3003]
end
subgraph "Azure Container Apps"
Backend[FastAPI Backend
Port 8001]
end
subgraph "Managed Services"
Neo4j[(Neo4j Aura
Graph Database)]
MongoDB[(MongoDB Atlas
Knowledge Base)]
end
subgraph "AI Services"
OpenAI[OpenAI API
GPT-4o]
end
subgraph "Observability Stack"
Langfuse[Langfuse UI
Port 3001]
Postgres[(PostgreSQL
Port 5433)]
ClickHouse[(ClickHouse
Port 8123)]
end
subgraph "Optional Services"
GDSAgent[Neo4j GDS Agent
via MCP stdio]
end
Browser -->|HTTPS| Frontend
Mobile -->|HTTPS| Frontend
Frontend -->|REST API
WebSocket| Backend
Backend -->|Cypher Queries
Bolt Protocol| Neo4j
Backend -->|MongoDB Driver| MongoDB
Backend -->|Langfuse SDK| Langfuse
Backend -->|OpenAI SDK| OpenAI
Backend -->|MCP stdio
JSON-RPC| GDSAgent
Langfuse --> Postgres
Langfuse --> ClickHouse
GDSAgent -.->|Queries| Neo4j
Backend -.->|Traces| Langfuse
style Browser fill:#e4a001,stroke:#e4a001,color:#1c1d1f
style Frontend fill:#1159af,stroke:#1159af,color:#ffffff
style Backend fill:#f7630c,stroke:#f7630c,color:#1c1d1f
style Neo4j fill:#13612e,stroke:#13612e,color:#ffffff
style MongoDB fill:#13612e,stroke:#13612e,color:#ffffff
style OpenAI fill:#383e49,stroke:#ffd95e,color:#e9e7e7
style Langfuse fill:#505762,stroke:#f7630c,color:#ffffff
style GDSAgent fill:#1159af,stroke:#1159af,color:#ffffff,stroke-dasharray: 5 5
3. AI Implementation Diagram¶
This diagram details the AI processing pipeline, showing how natural language questions are transformed into Cypher queries or routed to analytics tools, including all the AI components and decision points.
flowchart TD
Start([User Question]) --> LoadContext[Load Context]
LoadContext --> LoadSchema[Load Neo4j Schema
ai/schema/]
LoadContext --> LoadTerminology[Load Terminology
ai/terminology/]
LoadContext --> LoadPrompt[Load Prompt Template
ai/prompts/]
LoadSchema --> CheckAnalytics{Analytics
Enabled?}
LoadTerminology --> CheckAnalytics
LoadPrompt --> CheckAnalytics
CheckAnalytics -->|Yes| TryAnalytics[Analytics Agent Route]
CheckAnalytics -->|No| TextToCypher[Text-to-Cypher Route]
subgraph "Analytics Agent Path"
TryAnalytics --> LLMSelect[LLM Tool Selector
GraphAnalyticsAgent]
LLMSelect --> ToolDecision{Tool
Appropriate?}
ToolDecision -->|Yes| CallMCP[Call MCP Tool
leiden/article_rank/bridges]
ToolDecision -->|No| FallbackCypher[Fallback to Cypher]
CallMCP --> MCPResult[MCP Tool Result]
MCPResult --> AnalyticsSummary[Generate Summary
LLM]
AnalyticsSummary --> AnalyticsOutput[Return Analytics Result]
end
subgraph "Text-to-Cypher Path"
TextToCypher --> VectorSearch{Vector Search
Enabled?}
FallbackCypher --> VectorSearch
VectorSearch -->|Yes| SearchExamples[Search Similar Examples
ai/fewshots/vector_store]
VectorSearch -->|No| LoadStatic[Load Static Examples
ai/fewshots/loader]
SearchExamples --> RenderPrompt[Render Prompt Template]
LoadStatic --> RenderPrompt
RenderPrompt --> InjectSchema[Inject Schema Context]
RenderPrompt --> InjectTerminology[Inject Terminology]
RenderPrompt --> InjectExamples[Inject Few-Shot Examples]
RenderPrompt --> InjectQuestion[Inject User Question]
InjectSchema --> CompilePrompt[Compile Full Prompt]
InjectTerminology --> CompilePrompt
InjectExamples --> CompilePrompt
InjectQuestion --> CompilePrompt
CompilePrompt --> CallLLM[Call OpenAI LLM
GPT-4o]
CallLLM --> TraceLangfuse[Trace to Langfuse]
TraceLangfuse --> ExtractCypher[Extract Cypher Query]
ExtractCypher --> ValidateCypher{Valid
Cypher?}
ValidateCypher -->|No| Error[Return Error]
ValidateCypher -->|Yes| ExecuteCypher[Execute on Neo4j]
ExecuteCypher --> QueryResults[Raw Query Results]
QueryResults --> LoadSummaryPrompt[Load Summary Prompt
graph-result-summarizer]
LoadSummaryPrompt --> RenderSummary[Render Summary Prompt]
RenderSummary --> CallSummaryLLM[Call OpenAI LLM
for Summary]
CallSummaryLLM --> TraceSummary[Trace Summary to Langfuse]
TraceSummary --> CypherOutput[Return Cypher Result]
end
AnalyticsOutput --> End([Return to User])
CypherOutput --> End
Error --> End
style Start fill:#e4a001,stroke:#e4a001,color:#1c1d1f
style CheckAnalytics fill:#1159af,stroke:#1159af,color:#ffffff
style TryAnalytics fill:#f7630c,stroke:#f7630c,color:#1c1d1f
style TextToCypher fill:#f7630c,stroke:#f7630c,color:#1c1d1f
style CallLLM fill:#383e49,stroke:#ffd95e,color:#e9e7e7
style CallSummaryLLM fill:#383e49,stroke:#ffd95e,color:#e9e7e7
style LLMSelect fill:#383e49,stroke:#ffd95e,color:#e9e7e7
style End fill:#13612e,stroke:#13612e,color:#ffffff
Diagram Usage Recommendations¶
When to Use Each Diagram¶
- User Journey Diagram:
- Best for onboarding new users
- Demonstrating the user experience to stakeholders
- UX/UI design discussions
-
User documentation
-
Cloud Infrastructure Diagram:
- DevOps and deployment planning
- Infrastructure reviews
- Cost estimation discussions
- Security and compliance audits
-
System architecture documentation
-
AI Implementation Diagram:
- Developer onboarding
- AI/ML team discussions
- Debugging AI pipeline issues
- Prompt engineering sessions
- Performance optimization
Integration with Documentation¶
These diagrams complement the existing architecture documentation:
- User Journey → See
frontend.mdfor component details - Cloud Infrastructure → See
azure-deployment.mdfor deployment specifics - AI Implementation → See
ai-stack.mdandmcp.mdfor technical details
Maintenance¶
- Update diagrams when adding new user features (User Journey)
- Update diagrams when changing deployment architecture (Cloud Infrastructure)
- Update diagrams when modifying AI pipeline or adding new LLM routes (AI Implementation)
Exporting Diagrams¶
To export these diagrams as images:
- Use Mermaid Live Editor: https://mermaid.live/
- Copy each diagram code block
- Export as PNG/SVG
- Add to documentation or presentations
Alternatively, if using MkDocs with mermaid plugin, these will render automatically in the documentation site.