# mohamedhishm/newgen-tech-rag-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/mohamedhishm/newgen-tech-rag-assistant
- Repository: https://github.com/mohamedhishm/newgen-tech-rag-assistant

## Overview

NewGen Tech is a web-based company knowledge assistant. Employees ask questions in the chat UI; the API retrieves relevant passages, asks the LLM for a grounded answer, and returns source snippets for verification. A separate re-index action rebuilds the local knowledge base, while health monitoring reports service and index status. The graph separates ingestion, retrieval, and answer generation. Sampled source shows the runtime calls; other documented capabilities are included where README evidence supports them.

Main entry points: [`backend/main.py`](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/main.py) (HTTP API), [`backend/config.py`](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/config.py) (Application settings), [`frontend/script.js`](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/frontend/script.js) (Chat and controls), [`backend/services.py`](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/services.py) (Answer service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Employee experience"]
  node_web_ui["Chat and controls<br/>[script.js]"]
end

subgraph group_api["API and orchestration"]
  node_api_routes["HTTP API<br/>[main.py]"]
  node_settings["Application settings<br/>[config.py]"]
  node_citations["Answer and citations<br/>[main.py]"]
end

subgraph group_knowledge["Knowledge indexing and retrieval"]
  node_source_docs["Company documents"]
  node_doc_loading["Document loading<br/>[rag_pipeline.py]"]
  node_chunking["Text chunking<br/>[rag_pipeline.py]"]
  node_embedding_model["Embedding model"]
  node_embedding_builder["Embedding builder<br/>[rag_pipeline.py]"]
  node_vector_store[("Persistent vector store<br/>[rag_pipeline.py]")]
  node_retrieval["Similarity retrieval<br/>[rag_pipeline.py]"]
end

subgraph group_answer["Grounded answer generation"]
  node_context_prompt["Context and prompt<br/>[services.py]"]
  node_groq["Groq LLM"]
  node_answer_service["Answer service<br/>[services.py]"]
end

node_employee(("Employee"))

node_employee -->|"asks or re-indexes"| node_web_ui
node_web_ui -->|"submits query"| node_api_routes
node_web_ui -->|"checks health"| node_api_routes
node_web_ui -->|"requests re-index"| node_api_routes
node_api_routes -->|"serves interface"| node_web_ui
node_api_routes -->|"loads configuration"| node_settings
node_api_routes -->|"retrieves chunks"| node_retrieval
node_api_routes -->|"requests answer"| node_answer_service
node_api_routes -->|"builds response"| node_citations
node_citations -->|"returns answer and sources"| node_web_ui
node_source_docs -->|"loads files"| node_doc_loading
node_doc_loading -->|"splits documents"| node_chunking
node_chunking -->|"adds chunks"| node_vector_store
node_embedding_builder -->|"creates embeddings"| node_embedding_model
node_embedding_builder -->|"configures embeddings"| node_vector_store
node_settings -->|"sets data directory"| node_doc_loading
node_settings -->|"sets chunk limits"| node_chunking
node_settings -->|"sets store location"| node_vector_store
node_settings -->|"sets retrieval limits"| node_retrieval
node_retrieval -->|"searches vectors"| node_vector_store
node_answer_service -->|"formats context"| node_context_prompt
node_context_prompt -->|"sends prompt"| node_groq
node_settings -->|"sets model configuration"| node_answer_service
node_answer_service -->|"returns answer"| node_api_routes

click node_web_ui "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/frontend/script.js"
click node_api_routes "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/main.py"
click node_settings "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/config.py"
click node_source_docs "https://github.com/mohamedhishm/newgen-tech-rag-assistant/tree/main/data"
click node_doc_loading "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/rag_pipeline.py"
click node_chunking "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/rag_pipeline.py"
click node_embedding_builder "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/rag_pipeline.py"
click node_vector_store "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/rag_pipeline.py"
click node_retrieval "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/rag_pipeline.py"
click node_context_prompt "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/services.py"
click node_answer_service "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/services.py"
click node_citations "https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/main.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_web_ui toneBlue
class node_api_routes,node_settings,node_citations toneAmber
class node_source_docs,node_doc_loading,node_chunking,node_embedding_model,node_embedding_builder,node_vector_store,node_retrieval toneMint
class node_context_prompt,node_groq,node_answer_service toneRose
class node_employee toneIndigo
```

## Components

### Employee experience

- [Chat and controls](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/frontend/script.js): `frontend/script.js`

### API and orchestration

- [HTTP API](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/main.py): `backend/main.py`
- [Application settings](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/config.py): `backend/config.py`
- [Answer and citations](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/main.py): `backend/main.py`

### Knowledge indexing and retrieval

- [Company documents](https://github.com/mohamedhishm/newgen-tech-rag-assistant/tree/main/data): `data`
- [Document loading](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/rag_pipeline.py): `backend/rag_pipeline.py`
- [Text chunking](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/rag_pipeline.py): `backend/rag_pipeline.py`
- **Embedding model**
- [Embedding builder](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/rag_pipeline.py): `backend/rag_pipeline.py`
- [Persistent vector store](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/rag_pipeline.py): `backend/rag_pipeline.py`
- [Similarity retrieval](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/rag_pipeline.py): `backend/rag_pipeline.py`

### Grounded answer generation

- [Context and prompt](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/services.py): `backend/services.py`
- **Groq LLM**
- [Answer service](https://github.com/mohamedhishm/newgen-tech-rag-assistant/blob/main/backend/services.py): `backend/services.py`

### Other components

- **Employee**

## Connections

- Employee → Chat and controls: asks or re-indexes (evidence: `README.md`)
- Chat and controls → HTTP API: submits query (evidence: `frontend/script.js`)
- Chat and controls → HTTP API: checks health (evidence: `frontend/script.js`)
- Chat and controls → HTTP API: requests re-index (evidence: `frontend/script.js`)
- HTTP API → Chat and controls: serves interface (evidence: `backend/main.py`)
- HTTP API → Application settings: loads configuration (evidence: `backend/main.py`)
- HTTP API → Similarity retrieval: retrieves chunks (evidence: `backend/main.py`)
- HTTP API → Answer service: requests answer (evidence: `backend/main.py`)
- HTTP API → Answer and citations: builds response (evidence: `backend/main.py`)
- Answer and citations → Chat and controls: returns answer and sources (evidence: `frontend/script.js`)
- Company documents → Document loading: loads files (evidence: `README.md`)
- Document loading → Text chunking: splits documents (evidence: `backend/rag_pipeline.py`)
- Text chunking → Persistent vector store: adds chunks (evidence: `backend/rag_pipeline.py`)
- Embedding builder → Embedding model: creates embeddings (evidence: `README.md`)
- Embedding builder → Persistent vector store: configures embeddings (evidence: `backend/rag_pipeline.py`)
- Application settings → Document loading: sets data directory (evidence: `backend/rag_pipeline.py`)
- Application settings → Text chunking: sets chunk limits (evidence: `backend/rag_pipeline.py`)
- Application settings → Persistent vector store: sets store location (evidence: `backend/rag_pipeline.py`)
- Application settings → Similarity retrieval: sets retrieval limits (evidence: `backend/rag_pipeline.py`)
- Similarity retrieval → Persistent vector store: searches vectors (evidence: `backend/rag_pipeline.py`)
- Answer service → Context and prompt: formats context (evidence: `backend/services.py`)
- Context and prompt → Groq LLM: sends prompt (evidence: `backend/services.py`)
- Application settings → Answer service: sets model configuration (evidence: `backend/services.py`)
- Answer service → HTTP API: returns answer (evidence: `backend/main.py`)
