# chahmed12/enterprise-rag-assistant architecture

> Architecture diagram of the GitHub repository chahmed12/enterprise-rag-assistant, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chahmed12/enterprise-rag-assistant
- Repository: https://github.com/chahmed12/enterprise-rag-assistant

## Overview

Masrvi is an enterprise RAG question-answering assistant. Users ask questions in the Angular chat; the Spring backend manages sessions and messages, calls the FastAPI RAG service, and returns answers with sources. The RAG service retrieves passages from Qdrant and generates responses; its API also accepts document ingestion and corpus reload requests. The README describes the three-service architecture and model integrations. Some cross-service links are supported by documented HTTP contracts; unsampled implementation details are not inferred.

Main entry points: [`masrvi-rag-engine/retrieval/qdrant_client.py`](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/retrieval/qdrant_client.py) (Vector retrieval), [`masrvi-rag-engine/app/main.py`](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/app/main.py) (RAG API), [`masrvi-frontend/src/app/services/chat.service.ts`](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-frontend/src/app/services/chat.service.ts) (Chat API client), [`masrvi-core-backend/src/main/java/com/masrvi/core/service/ChatService.java`](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/service/ChatService.java) (Chat orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat interface"]
  node_chat_ui["Chat interface<br/>[chat-area.ts]"]
  node_sidebar["Session sidebar<br/>[sidebar.ts]"]
  node_chat_api_client["Chat API client<br/>[chat.service.ts]"]
end

subgraph group_backend["Core API"]
  node_chat_controller["Chat endpoints"]
  node_session_controller["Session endpoints"]
  node_document_controller["Document endpoints"]
  node_chat_service["Chat orchestration<br/>[ChatService.java]"]
  node_rag_client["RAG HTTP client"]
end

subgraph group_rag["RAG engine"]
  node_rag_api["RAG API<br/>[main.py]"]
  node_document_processing["Document processing"]
  node_answer_generation["Answer generation<br/>[exchange.py]"]
  node_semantic_chunking["Semantic chunking"]
  node_vector_access["Vector retrieval<br/>[qdrant_client.py]"]
  node_model_clients["Model clients<br/>[clients.py]"]
end

subgraph group_storage["Persistence and retrieval"]
  node_relational_repos["Chat repositories"]
  node_chat_entities["Chat records"]
end

node_user(("User"))
node_qdrant[("Qdrant")]
node_language_models{{"Embedding and LLM services"}}
node_relational_db[("Relational database")]

node_user -->|"asks"| node_chat_ui
node_chat_ui -->|"uses"| node_chat_api_client
node_sidebar -->|"loads sessions"| node_chat_api_client
node_chat_api_client -->|"HTTP chat requests"| node_chat_controller
node_chat_api_client -->|"HTTP session requests"| node_session_controller
node_chat_controller -->|"delegates to"| node_chat_service
node_session_controller -->|"delegates to"| node_chat_service
node_document_controller -->|"calls"| node_rag_client
node_chat_service -->|"asks question"| node_rag_client
node_chat_service -->|"reads and saves"| node_relational_repos
node_relational_repos -->|"persists"| node_chat_entities
node_relational_repos -.->|"accesses"| node_relational_db
node_rag_client -->|"calls HTTP endpoints"| node_rag_api
node_rag_api -->|"generates answer"| node_answer_generation
node_rag_api -->|"queues ingestion"| node_document_processing
node_rag_api -->|"checks and clears index"| node_vector_access
node_document_processing -->|"chunks documents"| node_semantic_chunking
node_document_processing -->|"indexes documents"| node_vector_access
node_answer_generation -->|"searches passages"| node_vector_access
node_vector_access -->|"gets embeddings"| node_model_clients
node_vector_access -->|"queries and updates"| node_qdrant
node_model_clients -->|"uses configured models"| node_language_models

click node_chat_ui "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-frontend/src/app/components/chat-area/chat-area.ts"
click node_sidebar "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-frontend/src/app/components/sidebar/sidebar.ts"
click node_chat_api_client "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-frontend/src/app/services/chat.service.ts"
click node_chat_controller "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/controller/ChatController.java"
click node_session_controller "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/controller/ChatSessionController.java"
click node_document_controller "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/controller/DocumentController.java"
click node_chat_service "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/service/ChatService.java"
click node_rag_client "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/client/RagEngineClient.java"
click node_relational_repos "https://github.com/chahmed12/enterprise-rag-assistant/tree/main/masrvi-core-backend/src/main/java/com/masrvi/core/repository"
click node_chat_entities "https://github.com/chahmed12/enterprise-rag-assistant/tree/main/masrvi-core-backend/src/main/java/com/masrvi/core/entity"
click node_rag_api "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/app/main.py"
click node_document_processing "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/core/process_document.py"
click node_answer_generation "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/core/exchange.py"
click node_semantic_chunking "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/retrieval/semantic_chunker.py"
click node_vector_access "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/retrieval/qdrant_client.py"
click node_model_clients "https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/utils/clients.py"

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_chat_ui,node_sidebar,node_chat_api_client,node_user toneBlue
class node_chat_controller,node_session_controller,node_document_controller,node_chat_service,node_rag_client,node_qdrant,node_relational_db toneAmber
class node_rag_api,node_document_processing,node_answer_generation,node_semantic_chunking,node_vector_access,node_model_clients toneMint
class node_relational_repos,node_chat_entities toneRose
class node_language_models toneIndigo
```

## Components

### Chat interface

- [Chat interface](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-frontend/src/app/components/chat-area/chat-area.ts): `masrvi-frontend/src/app/components/chat-area/chat-area.ts`
- [Session sidebar](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-frontend/src/app/components/sidebar/sidebar.ts): `masrvi-frontend/src/app/components/sidebar/sidebar.ts`
- [Chat API client](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-frontend/src/app/services/chat.service.ts): `masrvi-frontend/src/app/services/chat.service.ts`

### Core API

- [Chat endpoints](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/controller/ChatController.java): `masrvi-core-backend/src/main/java/com/masrvi/core/controller/ChatController.java`
- [Session endpoints](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/controller/ChatSessionController.java): `masrvi-core-backend/src/main/java/com/masrvi/core/controller/ChatSessionController.java`
- [Document endpoints](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/controller/DocumentController.java): `masrvi-core-backend/src/main/java/com/masrvi/core/controller/DocumentController.java`
- [Chat orchestration](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/service/ChatService.java): `masrvi-core-backend/src/main/java/com/masrvi/core/service/ChatService.java`
- [RAG HTTP client](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-core-backend/src/main/java/com/masrvi/core/client/RagEngineClient.java): `masrvi-core-backend/src/main/java/com/masrvi/core/client/RagEngineClient.java`

### RAG engine

- [RAG API](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/app/main.py): `masrvi-rag-engine/app/main.py`
- [Document processing](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/core/process_document.py): `masrvi-rag-engine/core/process_document.py`
- [Answer generation](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/core/exchange.py): `masrvi-rag-engine/core/exchange.py`
- [Semantic chunking](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/retrieval/semantic_chunker.py): `masrvi-rag-engine/retrieval/semantic_chunker.py`
- [Vector retrieval](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/retrieval/qdrant_client.py): `masrvi-rag-engine/retrieval/qdrant_client.py`
- [Model clients](https://github.com/chahmed12/enterprise-rag-assistant/blob/main/masrvi-rag-engine/utils/clients.py): `masrvi-rag-engine/utils/clients.py`

### Persistence and retrieval

- [Chat repositories](https://github.com/chahmed12/enterprise-rag-assistant/tree/main/masrvi-core-backend/src/main/java/com/masrvi/core/repository): `masrvi-core-backend/src/main/java/com/masrvi/core/repository`
- [Chat records](https://github.com/chahmed12/enterprise-rag-assistant/tree/main/masrvi-core-backend/src/main/java/com/masrvi/core/entity): `masrvi-core-backend/src/main/java/com/masrvi/core/entity`

### Other components

- **User**
- **Qdrant**
- **Embedding and LLM services**
- **Relational database**

## Connections

- User → Chat interface: asks
- Chat interface → Chat API client: uses (evidence: `masrvi-frontend/src/app/components/chat-area/chat-area.ts`)
- Session sidebar → Chat API client: loads sessions (evidence: `masrvi-frontend/src/app/components/sidebar/sidebar.ts`)
- Chat API client → Chat endpoints: HTTP chat requests (evidence: `masrvi-frontend/src/app/services/chat.service.ts`)
- Chat API client → Session endpoints: HTTP session requests (evidence: `masrvi-frontend/src/app/services/chat.service.ts`)
- Chat endpoints → Chat orchestration: delegates to (evidence: `masrvi-core-backend/src/main/java/com/masrvi/core/controller/ChatController.java`)
- Session endpoints → Chat orchestration: delegates to (evidence: `masrvi-core-backend/src/main/java/com/masrvi/core/controller/ChatSessionController.java`)
- Document endpoints → RAG HTTP client: calls (evidence: `masrvi-core-backend/src/main/java/com/masrvi/core/controller/DocumentController.java`)
- Chat orchestration → RAG HTTP client: asks question (evidence: `masrvi-core-backend/src/main/java/com/masrvi/core/service/ChatService.java`)
- Chat orchestration → Chat repositories: reads and saves (evidence: `masrvi-core-backend/src/main/java/com/masrvi/core/service/ChatService.java`)
- Chat repositories → Chat records: persists (evidence: `masrvi-core-backend/src/main/java/com/masrvi/core/repository/MessageRepository.java`)
- Chat repositories → Relational database: accesses
- RAG HTTP client → RAG API: calls HTTP endpoints (evidence: `masrvi-core-backend/src/main/java/com/masrvi/core/client/RagEngineClient.java`)
- RAG API → Answer generation: generates answer (evidence: `masrvi-rag-engine/app/main.py`)
- RAG API → Document processing: queues ingestion (evidence: `masrvi-rag-engine/app/main.py`)
- RAG API → Vector retrieval: checks and clears index (evidence: `masrvi-rag-engine/app/main.py`)
- Document processing → Semantic chunking: chunks documents (evidence: `masrvi-rag-engine/core/process_document.py`)
- Document processing → Vector retrieval: indexes documents (evidence: `masrvi-rag-engine/core/process_document.py`)
- Answer generation → Vector retrieval: searches passages (evidence: `masrvi-rag-engine/core/exchange.py`)
- Vector retrieval → Model clients: gets embeddings (evidence: `masrvi-rag-engine/retrieval/qdrant_client.py`)
- Vector retrieval → Qdrant: queries and updates (evidence: `masrvi-rag-engine/retrieval/qdrant_client.py`)
- Model clients → Embedding and LLM services: uses configured models
