# ziqiwang0908/ragrouter-bench architecture

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

- Interactive diagram: https://gitdiagram.com/ziqiwang0908/ragrouter-bench
- Repository: https://github.com/ziqiwang0908/ragrouter-bench

## Overview

RAGRouter-Bench is a benchmark for comparing retrieval-augmented generation strategies across query–corpus pairs. Its primary workflow processes corpus documents into chunks and embeddings/graphs, runs a selected retrieval paradigm to produce answers, and evaluates answer quality and corpus properties. It also includes query generation and query classification. Relationships shown are limited to README-documented capabilities and references in the SOURCE INDEX; unsampled implementations may have additional wiring not represented here.

Main entry points: [`main.py`](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/main.py) (CLI), [`RAGCore/Prompt/PromptTemplate.py`](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Prompt/PromptTemplate.py) (Prompt templates), [`RAGCore/Retriever/IterativeRAG/IterativeRAGDo.py`](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/IterativeRAG/IterativeRAGDo.py) (Iterative RAG), [`RAGCore/Retriever/NaiveRAG/NaiveRAGDo.py`](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/NaiveRAG/NaiveRAGDo.py) (Naive RAG)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and orchestration"]
  node_cli["CLI<br/>[main.py]"]
end

subgraph group_corpus["Corpus preparation"]
  node_chunk["Chunking<br/>[ChunkDo.py]"]
  node_embedding["Embedding<br/>[EmbeddingDo.py]"]
  node_embedding_store[("Embedding store<br/>[EmbeddingSave.py]")]
  node_graph_build["Graph construction<br/>[GraphDo.py]"]
  node_graph_store[("Graph store<br/>[GraphSave.py]")]
  node_index["Indexing<br/>[IndexDo.py]"]
end

subgraph group_retrieval["Retrieval paradigms"]
  node_naive["Naive RAG<br/>[NaiveRAGDo.py]"]
  node_graph_rag["Graph RAG<br/>[GraphRAGDo.py]"]
  node_hybrid["Hybrid RAG<br/>[HybridRAGDo.py]"]
  node_iterative["Iterative RAG<br/>[IterativeRAGDo.py]"]
  node_direct["LLM-only<br/>[LLMDirectDo.py]"]
  node_prompts["Prompt templates<br/>[PromptTemplate.py]"]
end

subgraph group_benchmark["Benchmark and analysis"]
  node_result_eval["Answer evaluation<br/>[EvaluationDo.py]"]
  node_semantic_eval["Semantic corpus evaluation<br/>[EvaluationDo.py]"]
  node_structure_eval["Structure corpus evaluation<br/>[EvaluationDo.py]"]
end

subgraph group_queries["Query preparation"]
  node_query_gen["Query generation<br/>[GenerateDo.py]"]
  node_query_preprocess["Query preprocessing<br/>[ChainBuilder.py]"]
  node_query_validate["Query validation<br/>[ValidateDo.py]"]
  node_query_classify["Query classification<br/>[QueryClassifyDo.py]"]
end

node_user(("Benchmark user"))
node_llm_service(("LLM provider"))

node_user -->|"runs stages"| node_cli
node_cli -->|"dispatches to"| node_chunk
node_cli -->|"dispatches to"| node_embedding
node_cli -->|"dispatches to"| node_embedding_store
node_cli -->|"dispatches to"| node_graph_build
node_cli -->|"dispatches to"| node_graph_store
node_cli -->|"dispatches to"| node_index
node_cli -->|"dispatches to"| node_naive
node_cli -->|"dispatches to"| node_graph_rag
node_cli -->|"dispatches to"| node_hybrid
node_cli -->|"dispatches to"| node_iterative
node_cli -->|"dispatches to"| node_direct
node_cli -->|"dispatches to"| node_result_eval
node_cli -->|"dispatches to"| node_semantic_eval
node_cli -->|"dispatches to"| node_structure_eval
node_cli -->|"dispatches to"| node_query_classify
node_embedding -->|"embeds chunks"| node_chunk
node_embedding -->|"persists vectors"| node_embedding_store
node_graph_build -->|"uses chunks"| node_chunk
node_graph_build -->|"persists graph data"| node_graph_store
node_index -->|"loads embeddings"| node_embedding_store
node_naive -->|"uses embeddings"| node_embedding
node_graph_rag -->|"uses embeddings"| node_embedding
node_iterative -->|"may retrieve via"| node_naive
node_iterative -->|"may retrieve via"| node_graph_rag
node_naive -->|"gets messages"| node_prompts
node_graph_rag -->|"uses prompts"| node_prompts
node_hybrid -->|"uses prompts"| node_prompts
node_iterative -->|"uses prompts"| node_prompts
node_direct -->|"uses prompts"| node_prompts
node_naive -.->|"requests generation"| node_llm_service
node_graph_rag -.->|"requests generation"| node_llm_service
node_hybrid -.->|"requests generation"| node_llm_service
node_iterative -.->|"requests generation"| node_llm_service
node_direct -.->|"requests generation"| node_llm_service
node_result_eval -->|"uses prompts"| node_prompts
node_semantic_eval -->|"reads embeddings"| node_embedding_store
node_structure_eval -->|"reads graph data"| node_graph_store
node_query_preprocess -->|"builds context for"| node_query_gen
node_cli -->|"runs generation"| node_query_gen
node_cli -->|"runs validation"| node_query_validate

click node_cli "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/main.py"
click node_chunk "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Chunk/ChunkDo.py"
click node_embedding "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Embedding/EmbeddingDo.py"
click node_embedding_store "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Embedding/EmbeddingSave.py"
click node_graph_build "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Graph/GraphDo.py"
click node_graph_store "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Graph/GraphSave.py"
click node_index "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Index/IndexDo.py"
click node_naive "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/NaiveRAG/NaiveRAGDo.py"
click node_graph_rag "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/GraphRAG/GraphRAGDo.py"
click node_hybrid "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/HybridRAG/HybridRAGDo.py"
click node_iterative "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/IterativeRAG/IterativeRAGDo.py"
click node_direct "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/LLMDirect/LLMDirectDo.py"
click node_prompts "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Prompt/PromptTemplate.py"
click node_result_eval "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/Evaluation/ResultEvaluation/EvaluationDo.py"
click node_semantic_eval "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/Evaluation/CorpusEvaluation/SemanticEvaluation/EvaluationDo.py"
click node_structure_eval "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/Evaluation/CorpusEvaluation/StructureEvaluation/EvaluationDo.py"
click node_query_gen "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/QueryGeneration/GenerateDo.py"
click node_query_preprocess "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/QueryGeneration/Preprocess/ChainBuilder.py"
click node_query_validate "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/QueryGeneration/ValidateDo.py"
click node_query_classify "https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Query/QueryClassifyDo.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_cli,node_user toneBlue
class node_chunk,node_embedding,node_embedding_store,node_graph_build,node_graph_store,node_index toneAmber
class node_naive,node_graph_rag,node_hybrid,node_iterative,node_direct,node_prompts toneMint
class node_result_eval,node_semantic_eval,node_structure_eval toneRose
class node_query_gen,node_query_preprocess,node_query_validate,node_query_classify,node_llm_service toneIndigo
```

## Components

### Entry and orchestration

- [CLI](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/main.py): `main.py`

### Corpus preparation

- [Chunking](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Chunk/ChunkDo.py): `RAGCore/Chunk/ChunkDo.py`
- [Embedding](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Embedding/EmbeddingDo.py): `RAGCore/Embedding/EmbeddingDo.py`
- [Embedding store](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Embedding/EmbeddingSave.py): `RAGCore/Embedding/EmbeddingSave.py`
- [Graph construction](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Graph/GraphDo.py): `RAGCore/Graph/GraphDo.py`
- [Graph store](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Graph/GraphSave.py): `RAGCore/Graph/GraphSave.py`
- [Indexing](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Index/IndexDo.py): `RAGCore/Index/IndexDo.py`

### Retrieval paradigms

- [Naive RAG](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/NaiveRAG/NaiveRAGDo.py): `RAGCore/Retriever/NaiveRAG/NaiveRAGDo.py`
- [Graph RAG](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/GraphRAG/GraphRAGDo.py): `RAGCore/Retriever/GraphRAG/GraphRAGDo.py`
- [Hybrid RAG](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/HybridRAG/HybridRAGDo.py): `RAGCore/Retriever/HybridRAG/HybridRAGDo.py`
- [Iterative RAG](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/IterativeRAG/IterativeRAGDo.py): `RAGCore/Retriever/IterativeRAG/IterativeRAGDo.py`
- [LLM-only](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Retriever/LLMDirect/LLMDirectDo.py): `RAGCore/Retriever/LLMDirect/LLMDirectDo.py`
- [Prompt templates](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Prompt/PromptTemplate.py): `RAGCore/Prompt/PromptTemplate.py`

### Benchmark and analysis

- [Answer evaluation](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/Evaluation/ResultEvaluation/EvaluationDo.py): `BenchCore/Evaluation/ResultEvaluation/EvaluationDo.py`
- [Semantic corpus evaluation](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/Evaluation/CorpusEvaluation/SemanticEvaluation/EvaluationDo.py): `BenchCore/Evaluation/CorpusEvaluation/SemanticEvaluation/EvaluationDo.py`
- [Structure corpus evaluation](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/Evaluation/CorpusEvaluation/StructureEvaluation/EvaluationDo.py): `BenchCore/Evaluation/CorpusEvaluation/StructureEvaluation/EvaluationDo.py`

### Query preparation

- [Query generation](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/QueryGeneration/GenerateDo.py): `BenchCore/QueryGeneration/GenerateDo.py`
- [Query preprocessing](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/QueryGeneration/Preprocess/ChainBuilder.py): `BenchCore/QueryGeneration/Preprocess/ChainBuilder.py`
- [Query validation](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/BenchCore/QueryGeneration/ValidateDo.py): `BenchCore/QueryGeneration/ValidateDo.py`
- [Query classification](https://github.com/ziqiwang0908/ragrouter-bench/blob/master/RAGCore/Query/QueryClassifyDo.py): `RAGCore/Query/QueryClassifyDo.py`

### Other components

- **Benchmark user**
- **LLM provider**

## Connections

- Benchmark user → CLI: runs stages (evidence: `README.md`)
- CLI → Chunking: dispatches to (evidence: `main.py`)
- CLI → Embedding: dispatches to (evidence: `main.py`)
- CLI → Embedding store: dispatches to (evidence: `main.py`)
- CLI → Graph construction: dispatches to (evidence: `main.py`)
- CLI → Graph store: dispatches to (evidence: `main.py`)
- CLI → Indexing: dispatches to (evidence: `main.py`)
- CLI → Naive RAG: dispatches to (evidence: `main.py`)
- CLI → Graph RAG: dispatches to (evidence: `main.py`)
- CLI → Hybrid RAG: dispatches to (evidence: `main.py`)
- CLI → Iterative RAG: dispatches to (evidence: `main.py`)
- CLI → LLM-only: dispatches to (evidence: `main.py`)
- CLI → Answer evaluation: dispatches to (evidence: `main.py`)
- CLI → Semantic corpus evaluation: dispatches to (evidence: `main.py`)
- CLI → Structure corpus evaluation: dispatches to (evidence: `main.py`)
- CLI → Query classification: dispatches to (evidence: `main.py`)
- Embedding → Chunking: embeds chunks (evidence: `RAGCore/Embedding/EmbeddingDo.py`)
- Embedding → Embedding store: persists vectors (evidence: `RAGCore/Embedding/EmbeddingDo.py`)
- Graph construction → Chunking: uses chunks (evidence: `RAGCore/Graph/GraphDo.py`)
- Graph construction → Graph store: persists graph data (evidence: `RAGCore/Graph/GraphDo.py`)
- Indexing → Embedding store: loads embeddings (evidence: `RAGCore/Index/IndexSave.py`)
- Naive RAG → Embedding: uses embeddings (evidence: `RAGCore/Retriever/NaiveRAG/NaiveRAGDo.py`)
- Graph RAG → Embedding: uses embeddings (evidence: `RAGCore/Retriever/GraphRAG/GraphRAGDo.py`)
- Iterative RAG → Naive RAG: may retrieve via (evidence: `RAGCore/Retriever/IterativeRAG/IterativeRAGDo.py`)
- Iterative RAG → Graph RAG: may retrieve via (evidence: `RAGCore/Retriever/IterativeRAG/IterativeRAGDo.py`)
- Naive RAG → Prompt templates: gets messages (evidence: `RAGCore/Retriever/NaiveRAG/NaiveRAGDo.py`)
- Graph RAG → Prompt templates: uses prompts (evidence: `RAGCore/Retriever/GraphRAG/GraphRAGDo.py`)
- Hybrid RAG → Prompt templates: uses prompts (evidence: `RAGCore/Retriever/HybridRAG/HybridRAGDo.py`)
- Iterative RAG → Prompt templates: uses prompts (evidence: `RAGCore/Retriever/IterativeRAG/IterativeRAGDo.py`)
- LLM-only → Prompt templates: uses prompts (evidence: `RAGCore/Retriever/LLMDirect/LLMDirectDo.py`)
- Naive RAG → LLM provider: requests generation
- Graph RAG → LLM provider: requests generation
- Hybrid RAG → LLM provider: requests generation
- Iterative RAG → LLM provider: requests generation
- LLM-only → LLM provider: requests generation
- Answer evaluation → Prompt templates: uses prompts (evidence: `BenchCore/Evaluation/ResultEvaluation/EvaluationDo.py`)
- Semantic corpus evaluation → Embedding store: reads embeddings (evidence: `BenchCore/Evaluation/CorpusEvaluation/SemanticEvaluation/EvaluationDo.py`)
- Structure corpus evaluation → Graph store: reads graph data (evidence: `BenchCore/Evaluation/CorpusEvaluation/StructureEvaluation/EvaluationDo.py`)
- Query preprocessing → Query generation: builds context for (evidence: `BenchCore/QueryGeneration/Preprocess/ChainBuilder.py`)
- CLI → Query generation: runs generation
- CLI → Query validation: runs validation
