# mohamed-aziiz/rag_uha architecture

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

- Interactive diagram: https://gitdiagram.com/mohamed-aziiz/rag_uha
- Repository: https://github.com/mohamed-aziiz/rag_uha

## Overview

Assistant UHA answers French or English questions about university documents through a shared interface, with classical RAG and GraphRAG offered side by side. The documented preparation stage loads and chunks source documents; both retrieval architectures use those same chunks and embeddings, then generate cited answers using a shared prompt. GraphRAG additionally extracts entities and relations and supplies a graph summary. Evaluation compares retrieval and answer quality, costs, and latency. README documents the main flow; some implementation details are unsampled, so links for those branches are limited to documented relationships.

Main entry points: [`src/rag_uha/pipelines/rag.py`](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/pipelines/rag.py) (Classical RAG), [`src/rag_uha/pipelines/graphrag.py`](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/pipelines/graphrag.py) (GraphRAG pipeline), [`app/streamlit_app.py`](https://github.com/mohamed-aziiz/rag_uha/blob/main/app/streamlit_app.py) (Streamlit interface), [`src/rag_uha/indexing/graph_index.py`](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/indexing/graph_index.py) (Graph index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Document preparation"]
  node_loader["Document loaders<br/>[loaders.py]"]
  node_chunks["Shared chunking<br/>[chunking.py]"]
end

subgraph group_retrieval["Retrieval architectures"]
  node_rag["Classical RAG<br/>[rag.py]"]
  node_vector[("Chroma vector index<br/>[vector_index.py]")]
  node_graphrag["GraphRAG pipeline<br/>[graphrag.py]"]
  node_graphidx[("Graph index<br/>[graph_index.py]")]
end

subgraph group_shared["Shared answer services"]
  node_pipeline["Pipeline selector<br/>[base.py]"]
  node_config["Settings<br/>[config.py]"]
  node_embed["BGE-M3 embeddings<br/>[embeddings.py]"]
  node_llm["LLM client<br/>[llm.py]"]
  node_prompt["Answer prompts<br/>[prompts.py]"]
  node_answer["Answer result<br/>[types.py]"]
end

subgraph group_product["Application and evaluation"]
  node_app["Streamlit interface<br/>[streamlit_app.py]"]
  node_evaldata["Evaluation questions<br/>[dataset.py]"]
  node_evalrun["Evaluation runner<br/>[runner.py]"]
  node_metrics["Retrieval metrics<br/>[metrics.py]"]
  node_ragas["RAGAS judging<br/>[ragas_eval.py]"]
  node_report["Evaluation reports<br/>[report.py]"]
  node_viz["Graph visualization<br/>[viz.py]"]
end

node_user(("Questioner"))
node_llmservice{{"LLM API"}}
node_embeddingservice{{"Embedding API"}}

node_user -->|"asks"| node_app
node_app -->|"selects"| node_pipeline
node_pipeline -->|"builds"| node_rag
node_pipeline -->|"builds"| node_graphrag
node_loader -->|"provides documents"| node_chunks
node_chunks -->|"indexes chunks"| node_vector
node_chunks -->|"indexes chunks"| node_graphidx
node_embed -->|"embeds chunks"| node_vector
node_embed -->|"embeds entities"| node_graphidx
node_graphidx -->|"extracts graph"| node_llm
node_rag -->|"searches"| node_vector
node_graphrag -->|"queries graph"| node_graphidx
node_rag -->|"formats context"| node_prompt
node_graphrag -->|"formats context"| node_prompt
node_rag -->|"generates answer"| node_llm
node_graphrag -->|"generates answer"| node_llm
node_llm -->|"calls"| node_llmservice
node_embed -->|"requests vectors"| node_embeddingservice
node_rag -->|"returns"| node_answer
node_graphrag -->|"returns"| node_answer
node_app -->|"renders graph"| node_viz
node_app -->|"reads graph data"| node_graphidx
node_evaldata -->|"supplies questions"| node_evalrun
node_evalrun -->|"runs questions"| node_pipeline
node_evalrun -->|"scores retrieval"| node_metrics
node_evalrun -->|"judges answers"| node_ragas
node_ragas -->|"uses judge model"| node_llm
node_metrics -->|"summarizes scores"| node_report
node_ragas -->|"provides scores"| node_report
node_answer -->|"displays results"| node_app

click node_app "https://github.com/mohamed-aziiz/rag_uha/blob/main/app/streamlit_app.py"
click node_pipeline "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/pipelines/base.py"
click node_loader "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/loaders.py"
click node_chunks "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/chunking.py"
click node_config "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/config.py"
click node_embed "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/embeddings.py"
click node_llm "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/llm.py"
click node_prompt "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/prompts.py"
click node_rag "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/pipelines/rag.py"
click node_vector "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/indexing/vector_index.py"
click node_graphrag "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/pipelines/graphrag.py"
click node_graphidx "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/indexing/graph_index.py"
click node_answer "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/types.py"
click node_evaldata "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/eval/dataset.py"
click node_evalrun "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/eval/runner.py"
click node_metrics "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/eval/metrics.py"
click node_ragas "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/eval/ragas_eval.py"
click node_report "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/eval/report.py"
click node_viz "https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/viz.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_loader,node_chunks toneBlue
class node_rag,node_vector,node_graphrag,node_graphidx toneAmber
class node_pipeline,node_config,node_embed,node_llm,node_prompt,node_answer,node_llmservice,node_embeddingservice toneMint
class node_app,node_evaldata,node_evalrun,node_metrics,node_ragas,node_report,node_viz toneRose
class node_user toneIndigo
```

## Components

### Document preparation

- [Document loaders](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/loaders.py): `src/rag_uha/loaders.py`
- [Shared chunking](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/chunking.py): `src/rag_uha/chunking.py`

### Retrieval architectures

- [Classical RAG](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/pipelines/rag.py): `src/rag_uha/pipelines/rag.py`
- [Chroma vector index](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/indexing/vector_index.py): `src/rag_uha/indexing/vector_index.py`
- [GraphRAG pipeline](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/pipelines/graphrag.py): `src/rag_uha/pipelines/graphrag.py`
- [Graph index](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/indexing/graph_index.py): `src/rag_uha/indexing/graph_index.py`

### Shared answer services

- [Pipeline selector](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/pipelines/base.py): `src/rag_uha/pipelines/base.py`
- [Settings](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/config.py): `src/rag_uha/config.py`
- [BGE-M3 embeddings](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/embeddings.py): `src/rag_uha/embeddings.py`
- [LLM client](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/llm.py): `src/rag_uha/llm.py`
- [Answer prompts](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/prompts.py): `src/rag_uha/prompts.py`
- [Answer result](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/types.py): `src/rag_uha/types.py`

### Application and evaluation

- [Streamlit interface](https://github.com/mohamed-aziiz/rag_uha/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [Evaluation questions](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/eval/dataset.py): `src/rag_uha/eval/dataset.py`
- [Evaluation runner](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/eval/runner.py): `src/rag_uha/eval/runner.py`
- [Retrieval metrics](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/eval/metrics.py): `src/rag_uha/eval/metrics.py`
- [RAGAS judging](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/eval/ragas_eval.py): `src/rag_uha/eval/ragas_eval.py`
- [Evaluation reports](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/eval/report.py): `src/rag_uha/eval/report.py`
- [Graph visualization](https://github.com/mohamed-aziiz/rag_uha/blob/main/src/rag_uha/viz.py): `src/rag_uha/viz.py`

### Other components

- **Questioner**
- **LLM API**
- **Embedding API**

## Connections

- Questioner → Streamlit interface: asks (evidence: `README.md`)
- Streamlit interface → Pipeline selector: selects (evidence: `app/streamlit_app.py`)
- Pipeline selector → Classical RAG: builds (evidence: `src/rag_uha/pipelines/base.py`)
- Pipeline selector → GraphRAG pipeline: builds (evidence: `src/rag_uha/pipelines/base.py`)
- Document loaders → Shared chunking: provides documents (evidence: `README.md`)
- Shared chunking → Chroma vector index: indexes chunks (evidence: `README.md`)
- Shared chunking → Graph index: indexes chunks (evidence: `README.md`)
- BGE-M3 embeddings → Chroma vector index: embeds chunks (evidence: `README.md`)
- BGE-M3 embeddings → Graph index: embeds entities (evidence: `README.md`)
- Graph index → LLM client: extracts graph (evidence: `README.md`)
- Classical RAG → Chroma vector index: searches (evidence: `src/rag_uha/pipelines/rag.py`)
- GraphRAG pipeline → Graph index: queries graph (evidence: `src/rag_uha/pipelines/graphrag.py`)
- Classical RAG → Answer prompts: formats context (evidence: `src/rag_uha/pipelines/rag.py`)
- GraphRAG pipeline → Answer prompts: formats context (evidence: `src/rag_uha/pipelines/graphrag.py`)
- Classical RAG → LLM client: generates answer (evidence: `src/rag_uha/pipelines/rag.py`)
- GraphRAG pipeline → LLM client: generates answer (evidence: `src/rag_uha/pipelines/graphrag.py`)
- LLM client → LLM API: calls (evidence: `src/rag_uha/llm.py`)
- BGE-M3 embeddings → Embedding API: requests vectors (evidence: `src/rag_uha/embeddings.py`)
- Classical RAG → Answer result: returns (evidence: `src/rag_uha/pipelines/rag.py`)
- GraphRAG pipeline → Answer result: returns (evidence: `src/rag_uha/pipelines/graphrag.py`)
- Streamlit interface → Graph visualization: renders graph (evidence: `app/streamlit_app.py`)
- Streamlit interface → Graph index: reads graph data (evidence: `app/streamlit_app.py`)
- Evaluation questions → Evaluation runner: supplies questions (evidence: `src/rag_uha/eval/runner.py`)
- Evaluation runner → Pipeline selector: runs questions (evidence: `src/rag_uha/eval/runner.py`)
- Evaluation runner → Retrieval metrics: scores retrieval (evidence: `src/rag_uha/eval/metrics.py`)
- Evaluation runner → RAGAS judging: judges answers (evidence: `README.md`)
- RAGAS judging → LLM client: uses judge model (evidence: `src/rag_uha/eval/ragas_eval.py`)
- Retrieval metrics → Evaluation reports: summarizes scores (evidence: `src/rag_uha/eval/report.py`)
- RAGAS judging → Evaluation reports: provides scores (evidence: `src/rag_uha/eval/report.py`)
- Answer result → Streamlit interface: displays results (evidence: `README.md`)
