# ledat98/nexusrag architecture

> Architecture diagram of the GitHub repository ledat98/nexusrag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ledat98/nexusrag
- Repository: https://github.com/ledat98/nexusrag

## Overview

NexusRAG is a document knowledge-base product: users organize workspaces, upload and process documents, then search or chat over the indexed material with citations, graph context, and extracted visual content. The graph follows the documented processing and hybrid-retrieval stages and includes the web UI, API, persistence, model providers, and MCP entry point. Several frontend and API relationships are supported only by README capability descriptions or are not excerpted; those connections are omitted rather than inferred.

Main entry points: [`backend/app/services/nexus_rag_service.py`](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/nexus_rag_service.py) (RAG orchestration), [`backend/app/api/rag.py`](https://github.com/ledat98/nexusrag/blob/main/backend/app/api/rag.py) (RAG endpoints), [`backend/app/api/router.py`](https://github.com/ledat98/nexusrag/blob/main/backend/app/api/router.py) (HTTP API), [`backend/app/api/chat_agent.py`](https://github.com/ledat98/nexusrag/blob/main/backend/app/api/chat_agent.py) (Agentic chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web application"]
  node_web["Workspace UI<br/>[App.tsx]"]
  node_workspace_pages["Workspace pages<br/>[WorkspacePage.tsx]"]
  node_chat_ui["Chat and citations<br/>[ChatPanel.tsx]"]
  node_search_ui["Search results<br/>[SearchResults.tsx]"]
  node_document_viewer["Document viewer<br/>[DocumentViewer.tsx]"]
end

subgraph group_api["API and domain"]
  node_api_router["HTTP API<br/>[router.py]"]
  node_document_api["Document operations<br/>[documents.py]"]
  node_rag_api["RAG endpoints<br/>[rag.py]"]
  node_chat_agent["Agentic chat<br/>[chat_agent.py]"]
  node_prompt_builder["Chat prompting<br/>[chat_prompt.py]"]
  node_workspaces["Workspace management<br/>[workspaces.py]"]
end

subgraph group_ingest["Document ingestion"]
  node_processing["RAG orchestration"]
  node_parser["Document parsers<br/>[docling_parser.py]"]
  node_parsed_model["Parsed document model<br/>[parsed_document.py]"]
  node_chunking["Semantic chunking<br/>[chunker.py]"]
  node_legacy_rag["Basic RAG service<br/>[rag_service.py]"]
end

subgraph group_retrieval["Hybrid retrieval"]
  node_deep_retriever["Hybrid retriever<br/>[deep_retriever.py]"]
  node_embedder["Vector embeddings<br/>[embedder.py]"]
  node_vector_store[("Vector index<br/>[vector_store.py]")]
  node_knowledge_graph[("Knowledge graph")]
  node_reranker["Cross-encoder reranker<br/>[reranker.py]"]
  node_llm_factory["LLM providers<br/>[__init__.py]"]
end

subgraph group_storage["Persistence"]
  node_database[("Relational database<br/>[database.py]")]
  node_models[("Workspace and document records<br/>[document.py]")]
  node_chat_records[("Chat history records<br/>[chat_message.py]")]
end

node_user(("Knowledge worker"))
node_mcp["MCP integration<br/>[index.ts]"]

node_user -->|"uses"| node_web
node_web -->|"routes to"| node_workspace_pages
node_user -.->|"requests tools"| node_mcp
node_workspace_pages -.->|"calls API"| node_api_router
node_chat_ui -.->|"streams chat"| node_api_router
node_search_ui -.->|"requests search"| node_api_router
node_document_viewer -.->|"loads sources"| node_api_router
node_api_router -->|"routes to"| node_document_api
node_api_router -->|"routes to"| node_rag_api
node_document_api -->|"processes documents"| node_processing
node_rag_api -->|"reindexes documents"| node_processing
node_rag_api -->|"queries service"| node_legacy_rag
node_rag_api -->|"dispatches chat"| node_chat_agent
node_chat_agent -->|"builds prompts"| node_prompt_builder
node_chat_agent -->|"queries service"| node_legacy_rag
node_chat_agent -->|"uses deep RAG"| node_processing
node_processing -->|"parses documents"| node_parser
node_parser -->|"produces parsed data"| node_parsed_model
node_parser -->|"chunks content"| node_chunking
node_processing -->|"persists extracted media"| node_parsed_model
node_processing -->|"embeds chunks"| node_embedder
node_processing -->|"indexes chunks"| node_vector_store
node_processing -->|"builds graph"| node_knowledge_graph
node_legacy_rag -->|"chunks text"| node_chunking
node_legacy_rag -->|"embeds chunks"| node_embedder
node_legacy_rag -->|"indexes chunks"| node_vector_store
node_deep_retriever -->|"embeds query"| node_embedder
node_deep_retriever -->|"retrieves candidates"| node_vector_store
node_deep_retriever -->|"retrieves entities"| node_knowledge_graph
node_deep_retriever -->|"reranks candidates"| node_reranker
node_processing -->|"retrieves context"| node_deep_retriever
node_chat_agent -->|"generates responses"| node_llm_factory
node_knowledge_graph -->|"extracts graph knowledge"| node_llm_factory
node_database -->|"defines ORM base"| node_models
node_database -->|"defines ORM base"| node_chat_records
node_document_api -->|"reads and writes"| node_models
node_rag_api -->|"reads and writes"| node_models
node_rag_api -->|"loads history"| node_chat_records
node_processing -.->|"updates document state"| node_models

click node_web "https://github.com/ledat98/nexusrag/blob/main/frontend/src/App.tsx"
click node_workspace_pages "https://github.com/ledat98/nexusrag/blob/main/frontend/src/pages/WorkspacePage.tsx"
click node_chat_ui "https://github.com/ledat98/nexusrag/blob/main/frontend/src/components/rag/ChatPanel.tsx"
click node_search_ui "https://github.com/ledat98/nexusrag/blob/main/frontend/src/components/rag/SearchResults.tsx"
click node_document_viewer "https://github.com/ledat98/nexusrag/blob/main/frontend/src/components/rag/DocumentViewer.tsx"
click node_api_router "https://github.com/ledat98/nexusrag/blob/main/backend/app/api/router.py"
click node_document_api "https://github.com/ledat98/nexusrag/blob/main/backend/app/api/documents.py"
click node_rag_api "https://github.com/ledat98/nexusrag/blob/main/backend/app/api/rag.py"
click node_chat_agent "https://github.com/ledat98/nexusrag/blob/main/backend/app/api/chat_agent.py"
click node_prompt_builder "https://github.com/ledat98/nexusrag/blob/main/backend/app/api/chat_prompt.py"
click node_workspaces "https://github.com/ledat98/nexusrag/blob/main/backend/app/api/workspaces.py"
click node_processing "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/nexus_rag_service.py"
click node_parser "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/document_parser/docling_parser.py"
click node_parsed_model "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/models/parsed_document.py"
click node_chunking "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/chunker.py"
click node_legacy_rag "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/rag_service.py"
click node_deep_retriever "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/deep_retriever.py"
click node_embedder "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/embedder.py"
click node_vector_store "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/vector_store.py"
click node_knowledge_graph "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/knowledge_graph_service.py"
click node_reranker "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/reranker.py"
click node_llm_factory "https://github.com/ledat98/nexusrag/blob/main/backend/app/services/llm/__init__.py"
click node_database "https://github.com/ledat98/nexusrag/blob/main/backend/app/core/database.py"
click node_models "https://github.com/ledat98/nexusrag/blob/main/backend/app/models/document.py"
click node_chat_records "https://github.com/ledat98/nexusrag/blob/main/backend/app/models/chat_message.py"
click node_mcp "https://github.com/ledat98/nexusrag/blob/main/mcp-server/src/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_workspace_pages,node_chat_ui,node_search_ui,node_document_viewer toneBlue
class node_api_router,node_document_api,node_rag_api,node_chat_agent,node_prompt_builder,node_workspaces toneAmber
class node_processing,node_parser,node_parsed_model,node_chunking,node_legacy_rag toneMint
class node_deep_retriever,node_embedder,node_vector_store,node_knowledge_graph,node_reranker,node_llm_factory,node_user toneRose
class node_database,node_models,node_chat_records,node_mcp toneIndigo
```

## Components

### Web application

- [Workspace UI](https://github.com/ledat98/nexusrag/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Workspace pages](https://github.com/ledat98/nexusrag/blob/main/frontend/src/pages/WorkspacePage.tsx): `frontend/src/pages/WorkspacePage.tsx`
- [Chat and citations](https://github.com/ledat98/nexusrag/blob/main/frontend/src/components/rag/ChatPanel.tsx): `frontend/src/components/rag/ChatPanel.tsx`
- [Search results](https://github.com/ledat98/nexusrag/blob/main/frontend/src/components/rag/SearchResults.tsx): `frontend/src/components/rag/SearchResults.tsx`
- [Document viewer](https://github.com/ledat98/nexusrag/blob/main/frontend/src/components/rag/DocumentViewer.tsx): `frontend/src/components/rag/DocumentViewer.tsx`

### API and domain

- [HTTP API](https://github.com/ledat98/nexusrag/blob/main/backend/app/api/router.py): `backend/app/api/router.py`
- [Document operations](https://github.com/ledat98/nexusrag/blob/main/backend/app/api/documents.py): `backend/app/api/documents.py`
- [RAG endpoints](https://github.com/ledat98/nexusrag/blob/main/backend/app/api/rag.py): `backend/app/api/rag.py`
- [Agentic chat](https://github.com/ledat98/nexusrag/blob/main/backend/app/api/chat_agent.py): `backend/app/api/chat_agent.py`
- [Chat prompting](https://github.com/ledat98/nexusrag/blob/main/backend/app/api/chat_prompt.py): `backend/app/api/chat_prompt.py`
- [Workspace management](https://github.com/ledat98/nexusrag/blob/main/backend/app/api/workspaces.py): `backend/app/api/workspaces.py`

### Document ingestion

- [RAG orchestration](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/nexus_rag_service.py): `backend/app/services/nexus_rag_service.py`
- [Document parsers](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/document_parser/docling_parser.py): `backend/app/services/document_parser/docling_parser.py`
- [Parsed document model](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/models/parsed_document.py): `backend/app/services/models/parsed_document.py`
- [Semantic chunking](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/chunker.py): `backend/app/services/chunker.py`
- [Basic RAG service](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/rag_service.py): `backend/app/services/rag_service.py`

### Hybrid retrieval

- [Hybrid retriever](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/deep_retriever.py): `backend/app/services/deep_retriever.py`
- [Vector embeddings](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/embedder.py): `backend/app/services/embedder.py`
- [Vector index](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/vector_store.py): `backend/app/services/vector_store.py`
- [Knowledge graph](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/knowledge_graph_service.py): `backend/app/services/knowledge_graph_service.py`
- [Cross-encoder reranker](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/reranker.py): `backend/app/services/reranker.py`
- [LLM providers](https://github.com/ledat98/nexusrag/blob/main/backend/app/services/llm/__init__.py): `backend/app/services/llm/__init__.py`

### Persistence

- [Relational database](https://github.com/ledat98/nexusrag/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [Workspace and document records](https://github.com/ledat98/nexusrag/blob/main/backend/app/models/document.py): `backend/app/models/document.py`
- [Chat history records](https://github.com/ledat98/nexusrag/blob/main/backend/app/models/chat_message.py): `backend/app/models/chat_message.py`

### Other components

- **Knowledge worker**
- [MCP integration](https://github.com/ledat98/nexusrag/blob/main/mcp-server/src/index.ts): `mcp-server/src/index.ts`

## Connections

- Knowledge worker → Workspace UI: uses
- Workspace UI → Workspace pages: routes to (evidence: `frontend/src/App.tsx`)
- Knowledge worker → MCP integration: requests tools
- Workspace pages → HTTP API: calls API
- Chat and citations → HTTP API: streams chat
- Search results → HTTP API: requests search
- Document viewer → HTTP API: loads sources
- HTTP API → Document operations: routes to (evidence: `backend/app/api/router.py`)
- HTTP API → RAG endpoints: routes to (evidence: `backend/app/api/router.py`)
- Document operations → RAG orchestration: processes documents (evidence: `backend/app/api/documents.py`)
- RAG endpoints → RAG orchestration: reindexes documents (evidence: `backend/app/api/rag.py`)
- RAG endpoints → Basic RAG service: queries service (evidence: `backend/app/api/rag.py`)
- RAG endpoints → Agentic chat: dispatches chat (evidence: `backend/app/api/rag.py`)
- Agentic chat → Chat prompting: builds prompts (evidence: `backend/app/api/chat_agent.py`)
- Agentic chat → Basic RAG service: queries service (evidence: `backend/app/api/chat_agent.py`)
- Agentic chat → RAG orchestration: uses deep RAG (evidence: `backend/app/api/chat_agent.py`)
- RAG orchestration → Document parsers: parses documents (evidence: `backend/app/services/nexus_rag_service.py`)
- Document parsers → Parsed document model: produces parsed data (evidence: `backend/app/services/document_parser/docling_parser.py`)
- Document parsers → Semantic chunking: chunks content (evidence: `backend/app/services/document_parser/docling_parser.py`)
- RAG orchestration → Parsed document model: persists extracted media (evidence: `backend/app/services/nexus_rag_service.py`)
- RAG orchestration → Vector embeddings: embeds chunks (evidence: `backend/app/services/nexus_rag_service.py`)
- RAG orchestration → Vector index: indexes chunks (evidence: `backend/app/services/nexus_rag_service.py`)
- RAG orchestration → Knowledge graph: builds graph (evidence: `backend/app/services/nexus_rag_service.py`)
- Basic RAG service → Semantic chunking: chunks text (evidence: `backend/app/services/rag_service.py`)
- Basic RAG service → Vector embeddings: embeds chunks (evidence: `backend/app/services/rag_service.py`)
- Basic RAG service → Vector index: indexes chunks (evidence: `backend/app/services/rag_service.py`)
- Hybrid retriever → Vector embeddings: embeds query (evidence: `backend/app/services/deep_retriever.py`)
- Hybrid retriever → Vector index: retrieves candidates (evidence: `backend/app/services/deep_retriever.py`)
- Hybrid retriever → Knowledge graph: retrieves entities (evidence: `backend/app/services/deep_retriever.py`)
- Hybrid retriever → Cross-encoder reranker: reranks candidates (evidence: `backend/app/services/deep_retriever.py`)
- RAG orchestration → Hybrid retriever: retrieves context (evidence: `backend/app/services/nexus_rag_service.py`)
- Agentic chat → LLM providers: generates responses (evidence: `backend/app/api/chat_agent.py`)
- Knowledge graph → LLM providers: extracts graph knowledge (evidence: `backend/app/services/knowledge_graph_service.py`)
- Relational database → Workspace and document records: defines ORM base (evidence: `backend/app/models/document.py`)
- Relational database → Chat history records: defines ORM base (evidence: `backend/app/models/chat_message.py`)
- Document operations → Workspace and document records: reads and writes (evidence: `backend/app/api/documents.py`)
- RAG endpoints → Workspace and document records: reads and writes (evidence: `backend/app/api/rag.py`)
- RAG endpoints → Chat history records: loads history (evidence: `backend/app/api/rag.py`)
- RAG orchestration → Workspace and document records: updates document state (evidence: `backend/app/services/nexus_rag_service.py`)
