## AI Features, Knowledge Graph and UX Integration
This short document maps how KnowledgeService produces KnowledgePacket/GroundedResponseDto, how semantic search and grounding feed UI components (Assistant bubble, Intelligence panels), and where prompts live.

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    flow_file_nexusreader_infrastructure_helpers_contenthasher_cs_file_1["ContentHasher"]
    flow_file_nexusreader_infrastructure_services_knowledgeservice_cs_file_1["KnowledgeService"]
    flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1["GroundedResponseDto.cs"]
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1["KnowledgePacket"]
    flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1["RelevantContext"]
    flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1["SemanticSearchResultDto"]
    flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1["GetKnowledgeGraphQuery"]
    flow_file_nexusreader_application_queries_graph_getknowledgegraphqueryhandler_cs_file_1["GetKnowledgeGraphQueryHandler"]
    flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1["GraphViewModels.cs"]
    flow_file_nexusreader_infrastructure_helpers_jsonrepairhelper_cs_file_1["JsonRepairHelper"]
    flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11[/"CitationDto"/]
    flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5[/"GroundedResponseDto"/]
    flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5[/"KeyConcept"/]
    flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17[/"KnowledgeLinkDto"/]
    flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19[/"KnowledgePacket"/]
    flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16[/"KnowledgeUnitDto"/]
    flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_quizquestion_10[/"QuizQuestion"/]
    flow_type_nexusreader_application_dtos_ai_relevantcontext_cs_relevantcontext_3[/"RelevantContext"/]
    flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3[/"SemanticSearchResultDto"/]
    flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8[/"GetKnowledgeGraphQuery"/]
    flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 -->|dto CitationDto| flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11
    flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 -->|dto GroundedResponseDto| flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KeyConcept| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KnowledgeLinkDto| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KnowledgePacket| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KnowledgeUnitDto| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto QuizQuestion| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_quizquestion_10
    flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1 -->|dto RelevantContext| flow_type_nexusreader_application_dtos_ai_relevantcontext_cs_relevantcontext_3
    flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1 -->|dto SemanticSearchResultDto| flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3
    flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1 -->|query GetKnowledgeGraphQuery| flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8
    click flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:5:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:11:1" "Open source"
    click flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/SemanticSearchResultDto.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3 href "vscode://file/NexusReader.Application/DTOs/AI/SemanticSearchResultDto.cs:3:1" "Open source"
    click flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1 href "vscode://file/NexusReader.Application/Queries/Graph/GetKnowledgeGraphQuery.cs:1:1" "Open source"
    click flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8 href "vscode://file/NexusReader.Application/Queries/Graph/GetKnowledgeGraphQuery.cs:8:1" "Open source"
    click flow_file_nexusreader_application_queries_graph_getknowledgegraphqueryhandler_cs_file_1 href "vscode://file/NexusReader.Application/Queries/Graph/GetKnowledgeGraphQueryHandler.cs:1:1" "Open source"
    click flow_file_nexusreader_infrastructure_services_knowledgeservice_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:1:1" "Open source"
    click flow_file_nexusreader_infrastructure_helpers_contenthasher_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Helpers/ContentHasher.cs:1:1" "Open source"
    click flow_file_nexusreader_infrastructure_helpers_jsonrepairhelper_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Helpers/JsonRepairHelper.cs:1:1" "Open source"
    click flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:5:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_quizquestion_10 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:10:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:16:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:17:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:19:1" "Open source"
    click flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/RelevantContext.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_relevantcontext_cs_relevantcontext_3 href "vscode://file/NexusReader.Application/DTOs/AI/RelevantContext.cs:3:1" "Open source"
    click flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1 href "vscode://file/NexusReader.Application/Queries/Graph/GraphViewModels.cs:1:1" "Open source"
```

This dependency map shows DTOs (KnowledgePacket, GroundedResponseDto, SemanticSearchResultDto), helpers, the KnowledgeService and the GetKnowledgeGraph query artifacts. It documents file-level links and where types are defined for UI and application use.

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    subgraph flow_0_nexusreader_application_queries_graph_getknowledgegraphquery_cs["GetKnowledgeGraphQuery"]
    end
    subgraph flow_1_nexusreader_application_dtos_ai_semanticsearchresultdto_cs["SemanticSearchResultDto"]
    end
    subgraph flow_2_nexusreader_application_dtos_ai_groundedresponsedto_cs["GroundedResponseDto.cs"]
    end
    subgraph Node_xref_ai_and_knowledge_ux_md_knowledge_graph_extraction_flow["Knowledge / Graph Extraction Flow"]
    end
    subgraph Node_xref_ai_and_knowledge_ux_md_semantic_search_global_intelligence_flow["Semantic Search / Global Intelligence Flow"]
    end
    subgraph Node_xref_ai_and_knowledge_ux_md_grounded_answer_ai_q_a_flow["Grounded Answer (AI Q&A) Flow"]
    end
    flow_method_nexusreader_ui_shared_components_atoms_nexusbutton_razor_render_component_markup_1["Render (component markup)"]
    flow_method_nexusreader_ui_shared_components_atoms_nexusicon_razor_render_razor_template_component_render_1["Render (Razor template / component render)"]
    flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1["GroundedResponseDto.cs"]
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1["KnowledgePacket"]
    flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1["RelevantContext"]
    flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1["SemanticSearchResultDto"]
    flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1["GetKnowledgeGraphQuery"]
    flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1["GraphViewModels.cs"]
    flow_file_nexusreader_ui_shared_components_atoms_nexusbutton_razor_file_1["NexusButton.razor"]
    flow_file_nexusreader_ui_shared_components_atoms_nexusicon_razor_file_1["NexusIcon"]
    flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11[/"CitationDto"/]
    flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5[/"GroundedResponseDto"/]
    flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5[/"KeyConcept"/]
    flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17[/"KnowledgeLinkDto"/]
    flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19[/"KnowledgePacket"/]
    flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16[/"KnowledgeUnitDto"/]
    flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_quizquestion_10[/"QuizQuestion"/]
    flow_type_nexusreader_application_dtos_ai_relevantcontext_cs_relevantcontext_3[/"RelevantContext"/]
    flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3[/"SemanticSearchResultDto"/]
    flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8[/"GetKnowledgeGraphQuery"/]
    flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphdatadto_5[/"GraphDataDto"/]
    flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphlinkdto_4[/"GraphLinkDto"/]
    flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphnodedto_3[/"GraphNodeDto"/]
    flow_type_nexusreader_ui_shared_components_atoms_nexusbutton_razor_nexusbutton_parameters_component_props_5[/"NexusButton parameters (component props)"/]
    flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 -->|dto CitationDto| flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11
    flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 -->|dto GroundedResponseDto| flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KeyConcept| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KnowledgeLinkDto| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KnowledgePacket| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KnowledgeUnitDto| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto QuizQuestion| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_quizquestion_10
    flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1 -->|dto RelevantContext| flow_type_nexusreader_application_dtos_ai_relevantcontext_cs_relevantcontext_3
    flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1 -->|dto SemanticSearchResultDto| flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3
    flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1 -->|query GetKnowledgeGraphQuery| flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8
    flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1 -->|dto GraphDataDto| flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphdatadto_5
    flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1 -->|dto GraphLinkDto| flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphlinkdto_4
    flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1 -->|dto GraphNodeDto| flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphnodedto_3
    flow_file_nexusreader_ui_shared_components_atoms_nexusbutton_razor_file_1 -->|Render component markup| flow_method_nexusreader_ui_shared_components_atoms_nexusbutton_razor_render_component_markup_1
    flow_file_nexusreader_ui_shared_components_atoms_nexusbutton_razor_file_1 -->|view-model NexusButton parameters component props| flow_type_nexusreader_ui_shared_components_atoms_nexusbutton_razor_nexusbutton_parameters_component_props_5
    flow_file_nexusreader_ui_shared_components_atoms_nexusicon_razor_file_1 -->|Render Razor template / component render| flow_method_nexusreader_ui_shared_components_atoms_nexusicon_razor_render_razor_template_component_render_1
    click flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:5:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:11:1" "Open source"
    click flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/SemanticSearchResultDto.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3 href "vscode://file/NexusReader.Application/DTOs/AI/SemanticSearchResultDto.cs:3:1" "Open source"
    click flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1 href "vscode://file/NexusReader.Application/Queries/Graph/GetKnowledgeGraphQuery.cs:1:1" "Open source"
    click flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8 href "vscode://file/NexusReader.Application/Queries/Graph/GetKnowledgeGraphQuery.cs:8:1" "Open source"
    click flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:5:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_quizquestion_10 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:10:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:16:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:17:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:19:1" "Open source"
    click flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/RelevantContext.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_relevantcontext_cs_relevantcontext_3 href "vscode://file/NexusReader.Application/DTOs/AI/RelevantContext.cs:3:1" "Open source"
    click flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1 href "vscode://file/NexusReader.Application/Queries/Graph/GraphViewModels.cs:1:1" "Open source"
```

This flow highlights how GetKnowledgeGraphQuery ties semantic search results and grounded responses to UI rendering components (Assistant/Intelligence panels). It shows which DTOs flow into UI components and the renderer points for shared atoms like NexusButton/NexusIcon.

```mermaid
classDiagram
    class flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1["GroundedResponseDto.cs"]
    class flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1["KnowledgePacket"]
    class flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1["RelevantContext"]
    class flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1["SemanticSearchResultDto"]
    class flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1["GetKnowledgeGraphQuery"]
    class flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1["GraphViewModels.cs"]
    class flow_file_nexusreader_ui_shared_components_atoms_nexusbutton_razor_file_1["NexusButton.razor"]
    class flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11["CitationDto"]
    class flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5["GroundedResponseDto"]
    class flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5["KeyConcept"]
    class flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17["KnowledgeLinkDto"]
    class flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19["KnowledgePacket"]
    class flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16["KnowledgeUnitDto"]
    class flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_quizquestion_10["QuizQuestion"]
    class flow_type_nexusreader_application_dtos_ai_relevantcontext_cs_relevantcontext_3["RelevantContext"]
    class flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3["SemanticSearchResultDto"]
    class flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8["GetKnowledgeGraphQuery"]
    class flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphdatadto_5["GraphDataDto"]
    class flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphlinkdto_4["GraphLinkDto"]
    class flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphnodedto_3["GraphNodeDto"]
    flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 --> flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11 : dto CitationDto
    flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 --> flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5 : dto GroundedResponseDto
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 --> flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5 : dto KeyConcept
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 --> flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17 : dto KnowledgeLinkDto
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 --> flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19 : dto KnowledgePacket
    flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 --> flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16 : dto KnowledgeUnitDto
    flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1 --> flow_type_nexusreader_application_dtos_ai_relevantcontext_cs_relevantcontext_3 : dto RelevantContext
    flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1 --> flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3 : dto SemanticSearchResultDto
    flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1 --> flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8 : query GetKnowledgeGraphQuery
    flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1 --> flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphdatadto_5 : dto GraphDataDto
    flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1 --> flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphlinkdto_4 : dto GraphLinkDto
    flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1 --> flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphnodedto_3 : dto GraphNodeDto
    click flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:5:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:11:1" "Open source"
    click flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/SemanticSearchResultDto.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3 href "vscode://file/NexusReader.Application/DTOs/AI/SemanticSearchResultDto.cs:3:1" "Open source"
    click flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1 href "vscode://file/NexusReader.Application/Queries/Graph/GetKnowledgeGraphQuery.cs:1:1" "Open source"
```

The class diagram clarifies the shapes: GroundedResponseDto (with CitationDto), KnowledgePacket (KeyConcept, KnowledgeUnitDto, QuizQuestion) and SemanticSearchResultDto. These are the payloads the UI consumes for grounded answers, graph rendering and search snippets.

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart LR
    subgraph layer_application["application"]
        flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1["GroundedResponseDto.cs"]
        flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1["KnowledgePacket"]
        flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1["RelevantContext"]
        flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1["SemanticSearchResultDto"]
        flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1["GetKnowledgeGraphQuery"]
        flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1["GraphViewModels.cs"]
        flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11[/"CitationDto"/]
        flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5[/"GroundedResponseDto"/]
        flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5[/"KeyConcept"/]
        flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17[/"KnowledgeLinkDto"/]
        flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19[/"KnowledgePacket"/]
        flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16[/"KnowledgeUnitDto"/]
        flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_quizquestion_10[/"QuizQuestion"/]
        flow_type_nexusreader_application_dtos_ai_relevantcontext_cs_relevantcontext_3[/"RelevantContext"/]
        flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3[/"SemanticSearchResultDto"/]
        flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8[/"GetKnowledgeGraphQuery"/]
        flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphlinkdto_4[/"GraphLinkDto"/]
        flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphnodedto_3[/"GraphNodeDto"/]
        flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 -->|dto CitationDto| flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11
        flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 -->|dto GroundedResponseDto| flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5
        flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KeyConcept| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5
        flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KnowledgeLinkDto| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17
        flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KnowledgePacket| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19
        flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto KnowledgeUnitDto| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16
        flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 -->|dto QuizQuestion| flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_quizquestion_10
        flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1 -->|dto RelevantContext| flow_type_nexusreader_application_dtos_ai_relevantcontext_cs_relevantcontext_3
        flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1 -->|dto SemanticSearchResultDto| flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3
        flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1 -->|query GetKnowledgeGraphQuery| flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8
        flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1 -->|dto GraphLinkDto| flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphlinkdto_4
        flow_file_nexusreader_application_queries_graph_graphviewmodels_cs_file_1 -->|dto GraphNodeDto| flow_type_nexusreader_application_queries_graph_graphviewmodels_cs_graphnodedto_3
    end
    subgraph layer_frontend["frontend"]
    end
    click flow_file_nexusreader_application_dtos_ai_groundedresponsedto_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_groundedresponsedto_5 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:5:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_groundedresponsedto_cs_citationdto_11 href "vscode://file/NexusReader.Application/DTOs/AI/GroundedResponseDto.cs:11:1" "Open source"
    click flow_file_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/SemanticSearchResultDto.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_semanticsearchresultdto_cs_semanticsearchresultdto_3 href "vscode://file/NexusReader.Application/DTOs/AI/SemanticSearchResultDto.cs:3:1" "Open source"
    click flow_file_nexusreader_application_queries_graph_getknowledgegraphquery_cs_file_1 href "vscode://file/NexusReader.Application/Queries/Graph/GetKnowledgeGraphQuery.cs:1:1" "Open source"
    click flow_type_nexusreader_application_queries_graph_getknowledgegraphquery_cs_getknowledgegraphquery_8 href "vscode://file/NexusReader.Application/Queries/Graph/GetKnowledgeGraphQuery.cs:8:1" "Open source"
    click flow_file_nexusreader_application_dtos_ai_knowledgepacket_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:1:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_keyconcept_5 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:5:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_quizquestion_10 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:10:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgeunitdto_16 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:16:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgelinkdto_17 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:17:1" "Open source"
    click flow_type_nexusreader_application_dtos_ai_knowledgepacket_cs_knowledgepacket_19 href "vscode://file/NexusReader.Application/DTOs/AI/KnowledgePacket.cs:19:1" "Open source"
    click flow_file_nexusreader_application_dtos_ai_relevantcontext_cs_file_1 href "vscode://file/NexusReader.Application/DTOs/AI/RelevantContext.cs:1:1" "Open source"
```

This layer map separates application DTO/query surfaces (what the frontend calls) from frontend components. It confirms GetKnowledgeGraphQuery is the main query returning graph and search DTOs to the UI.

```mermaid
flowchart TD
    subgraph NexusReader_Infrastructure_Services_KnowledgeService["KnowledgeService"]
    end
    subgraph NexusReader_Infrastructure_Helpers_ContentHasher["ContentHasher"]
    end
    subgraph NexusReader_UI_Shared_Services_KnowledgeCoordinator["KnowledgeCoordinator"]
    end
    flow_file_nexusreader_infrastructure_helpers_contenthasher_cs_file_1["ContentHasher"]
    flow_file_nexusreader_infrastructure_services_knowledgeservice_cs_file_1["KnowledgeService"]
    flow_file_nexusreader_ui_shared_services_knowledgecoordinator_cs_file_1["KnowledgeCoordinator"]
    flow_method_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_9["ComputeHash"]
    flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getgraphdataasync_66["GetGraphDataAsync"]
    flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeasync_61["GetKnowledgeAsync"]
    flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_81["GetKnowledgeInternalAsync"]
    flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgemapasync_76["GetKnowledgeMapAsync"]
    flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112["RequestSummaryAndQuizAsync"]
    flow_action_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_branch_11_11{"Evaluates branch condition"}
    flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_await_85_85["Waits for async work"]
    flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_guard_clause_83_83{"Guards early exit or rejection path"}
    flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_generatefullquiz_await_91_91["Waits for async work"]
    flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_requestsummary_await_83_83["Waits for async work"]
    flow_action_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_await_114_114["Waits for async work"]
    flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getgraphdataasync_return_68_68(["Returns result"])
    flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeasync_return_63_63(["Returns result"])
    flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgemapasync_return_78_78(["Returns result"])
    flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_await_85_85 -->|ContentHasher.ComputeHash| flow_method_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_9
    flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_guard_clause_83_83 -->|Waits for async work| flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_await_85_85
    flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_generatefullquiz_await_91_91 -->|RequestSummaryAndQuizAsync| flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112
    flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_requestsummary_await_83_83 -->|RequestSummaryAndQuizAsync| flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112
    flow_file_nexusreader_infrastructure_helpers_contenthasher_cs_file_1 -->|ComputeHash| flow_method_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_9
    flow_file_nexusreader_infrastructure_services_knowledgeservice_cs_file_1 -->|GetGraphDataAsync| flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getgraphdataasync_66
    flow_file_nexusreader_infrastructure_services_knowledgeservice_cs_file_1 -->|GetKnowledgeAsync| flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeasync_61
    flow_file_nexusreader_infrastructure_services_knowledgeservice_cs_file_1 -->|GetKnowledgeInternalAsync| flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_81
    flow_file_nexusreader_infrastructure_services_knowledgeservice_cs_file_1 -->|GetKnowledgeMapAsync| flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgemapasync_76
    flow_file_nexusreader_ui_shared_services_knowledgecoordinator_cs_file_1 -->|RequestSummaryAndQuizAsync| flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112
    flow_method_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_9 -->|true / false| flow_action_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_branch_11_11
    flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getgraphdataasync_66 -->|Returns result| flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getgraphdataasync_return_68_68
    flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeasync_61 -->|Returns result| flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeasync_return_63_63
    flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgemapasync_76 -->|Returns result| flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgemapasync_return_78_78
    flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112 -->|Waits for async work| flow_action_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_await_114_114
    click flow_file_nexusreader_infrastructure_services_knowledgeservice_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:1:1" "Open source"
    click flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeasync_61 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:61:1" "Open source"
    click flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeasync_return_63_63 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:63:1" "Open source"
    click flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getgraphdataasync_66 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:66:1" "Open source"
    click flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getgraphdataasync_return_68_68 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:68:1" "Open source"
    click flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgemapasync_76 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:76:1" "Open source"
    click flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgemapasync_return_78_78 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:78:1" "Open source"
    click flow_method_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_81 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:81:1" "Open source"
    click flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_guard_clause_83_83 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:83:1" "Open source"
    click flow_action_nexusreader_infrastructure_services_knowledgeservice_cs_getknowledgeinternalasync_await_85_85 href "vscode://file/NexusReader.Infrastructure/Services/KnowledgeService.cs:85:1" "Open source"
    click flow_file_nexusreader_infrastructure_helpers_contenthasher_cs_file_1 href "vscode://file/NexusReader.Infrastructure/Helpers/ContentHasher.cs:1:1" "Open source"
    click flow_method_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_9 href "vscode://file/NexusReader.Infrastructure/Helpers/ContentHasher.cs:9:1" "Open source"
    click flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_requestsummary_await_83_83 href "vscode://file/NexusReader.UI.Shared/Components/Molecules/SelectionAiPanel.razor:83:1" "Open source"
    click flow_file_nexusreader_ui_shared_services_knowledgecoordinator_cs_file_1 href "vscode://file/NexusReader.UI.Shared/Services/KnowledgeCoordinator.cs:1:1" "Open source"
    click flow_method_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_112 href "vscode://file/NexusReader.UI.Shared/Services/KnowledgeCoordinator.cs:112:1" "Open source"
    click flow_action_nexusreader_ui_shared_components_molecules_selectionaipanel_razor_generatefullquiz_await_91_91 href "vscode://file/NexusReader.UI.Shared/Components/Molecules/SelectionAiPanel.razor:91:1" "Open source"
    click flow_action_nexusreader_infrastructure_helpers_contenthasher_cs_computehash_branch_11_11 href "vscode://file/NexusReader.Infrastructure/Helpers/ContentHasher.cs:11:1" "Open source"
    click flow_action_nexusreader_ui_shared_services_knowledgecoordinator_cs_requestsummaryandquizasync_await_114_114 href "vscode://file/NexusReader.UI.Shared/Services/KnowledgeCoordinator.cs:114:1" "Open source"
```

The method flow details the runtime orchestration: KnowledgeService entry points (GetKnowledgeAsync/GetGraphDataAsync), internal hashing for dedupe, and UI-side KnowledgeCoordinator calls for summaries/quizzes. It shows where async waits, guard clauses and result returns occur.

### Key Files
- NexusReader.Infrastructure/Services/KnowledgeService.cs
- NexusReader.Infrastructure/Services/PromptRegistry.cs
- NexusReader.Application/DTOs/AI/KnowledgePacket.cs
- NexusReader.Application/DTOs/AI/GroundedResponseDto.cs
- NexusReader.Application/DTOs/AI/SemanticSearchResultDto.cs
- NexusReader.Application/Queries/Graph/GetKnowledgeGraphQuery.cs
- NexusReader.Application/Queries/Graph/GetKnowledgeGraphQueryHandler.cs
- NexusReader.Application/Queries/Graph/GraphViewModels.cs
- NexusReader.UI.Shared/Services/KnowledgeCoordinator.cs
- NexusReader.UI.Shared/Components/Molecules/AiAssistantBubble.razor

---

## See Also

- [Project Overview and High-level Architecture](../collections/overview.md)
- [Infrastructure Services (AI, Epub, Storage, Billing)](../infrastructure/infrastructure-services.md)
- [Application Layer: Commands, Queries, DTOs and Handlers](../domains/application-cqs-and-handlers.md)
- [Web Client (WASM) and Shared UI Components](../domains/web-client-and-shared-ui.md)
- [Mobile (MAUI) Application Integration](../runtime/mobile-maui.md)
- [Business Overview](../business/business-overview.md)
- [Top Business Flows](../business/top-business-flows.md)
