# datawhalechina/all-in-rag architecture

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

- Interactive diagram: https://gitdiagram.com/datawhalechina/all-in-rag
- Repository: https://github.com/datawhalechina/all-in-rag

## Overview

All-in-RAG is a tutorial repository of runnable RAG examples, not one unified deployed application. Its learning path runs from document loading and chunking through embeddings/indexes and retrieval to generation and evaluation, with integrated recipe-assistant projects as larger examples. The graph retains documented branches for multimodal search, agentic RAG, Graph RAG, Text2SQL, and the PowerRAG SDK demo. Relationships between tutorial chapters are documented capabilities; internal call edges are limited to those visible in excerpts or the source index.

Main entry points: [`code/C8/main.py`](https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/main.py) (Recipe RAG system), [`code/C4/01_hybrid_search.py`](https://github.com/datawhalechina/all-in-rag/blob/main/code/C4/01_hybrid_search.py) (Hybrid retrieval), [`code/C3/visual_bge/visual_bge/eva_clip/openai.py`](https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/openai.py) (CLIP compatibility), [`code/C9/rag_modules/intelligent_query_router.py`](https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/intelligent_query_router.py) (Intelligent router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_foundations["Data foundations"]
  node_loading["Document loading"]
  node_chunking["Text chunking"]
end

subgraph group_indexing["Indexing and search"]
  node_textembed["Text embeddings"]
  node_vectorindex[("Vector indexes<br/>[04_multi_milvus.py]")]
  node_visualmodel["Visual BGE model<br/>[modeling.py]"]
  node_clipmodel["EVA CLIP model<br/>[model.py]"]
  node_clipopenai["CLIP compatibility<br/>[openai.py]"]
  node_clipweights["Pretrained weights<br/>[pretrained.py]"]
  node_cliprope["RoPE utilities<br/>[rope.py]"]
  node_cliptransformer["CLIP transformer<br/>[transformer.py]"]
end

subgraph group_applications["RAG applications"]
  node_generation["Structured generation"]
  node_evaluation["RAG evaluation"]
  node_agentic["Agentic RAG<br/>[agent.py]"]
  node_c8main["Recipe RAG system<br/>[main.py]"]
  node_c8data["Data preparation"]
  node_c8index["Index construction"]
  node_c8retrieval["Retrieval optimization"]
  node_c8generation["Generation integration"]
  node_recipeagent["Recipe AI agent<br/>[recipe_ai_agent.py]"]
end

subgraph group_advanced["Advanced retrieval"]
  node_retrieval["Hybrid retrieval"]
  node_text2sql[("Text2SQL<br/>[knowledge_base.py]")]
  node_routing["Query routing"]
  node_graphdata["Graph data preparation"]
  node_graphindex[("Graph indexing<br/>[graph_indexing.py]")]
  node_hybrid["Graph hybrid search"]
  node_graphrag["Graph RAG retrieval"]
  node_router["Intelligent router"]
end

subgraph group_extras["Extensions"]
  node_powerrag["PowerRAG SDK demo<br/>[main.py]"]
  node_omni["Omni embeddings"]
end

node_learner(("Developer"))

node_learner -->|"learns from"| node_loading
node_loading -->|"prepares data"| node_chunking
node_chunking -->|"feeds embeddings"| node_textembed
node_textembed -->|"builds indexes"| node_vectorindex
node_visualmodel -->|"uses compatibility"| node_clipopenai
node_clipopenai -->|"imports model"| node_clipmodel
node_clipopenai -->|"imports weights"| node_clipweights
node_cliptransformer -->|"imports utilities"| node_cliprope
node_vectorindex -->|"enables retrieval"| node_retrieval
node_retrieval -->|"supports query strategies"| node_routing
node_retrieval -->|"extends retrieval"| node_text2sql
node_retrieval -->|"supplies context"| node_generation
node_generation -->|"evaluated by"| node_evaluation
node_learner -->|"explores agents"| node_agentic
node_c8main -.->|"uses preparation"| node_c8data
node_c8main -.->|"uses indexing"| node_c8index
node_c8main -.->|"uses retrieval"| node_c8retrieval
node_c8main -.->|"uses generation"| node_c8generation
node_c8main -->|"queries chunks"| node_c8retrieval
node_c8main -->|"routes and answers"| node_c8generation
node_graphdata -.->|"prepares graph data"| node_graphindex
node_hybrid -->|"uses graph keys"| node_graphindex
node_router -.->|"selects strategy"| node_hybrid
node_router -.->|"selects strategy"| node_graphrag
node_learner -->|"tries SDK demo"| node_powerrag
node_learner -->|"explores multimodal"| node_omni

click node_loading "https://github.com/datawhalechina/all-in-rag/blob/main/code/C2/01_unstructured_example.py"
click node_chunking "https://github.com/datawhalechina/all-in-rag/tree/main/code/C2"
click node_textembed "https://github.com/datawhalechina/all-in-rag/tree/main/code/C3"
click node_vectorindex "https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/04_multi_milvus.py"
click node_visualmodel "https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/modeling.py"
click node_clipmodel "https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/model.py"
click node_clipopenai "https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/openai.py"
click node_clipweights "https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/pretrained.py"
click node_cliprope "https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/rope.py"
click node_cliptransformer "https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/transformer.py"
click node_retrieval "https://github.com/datawhalechina/all-in-rag/blob/main/code/C4/01_hybrid_search.py"
click node_text2sql "https://github.com/datawhalechina/all-in-rag/blob/main/code/C4/text2sql/knowledge_base.py"
click node_routing "https://github.com/datawhalechina/all-in-rag/blob/main/code/C4/05_llm_based_routing.py"
click node_generation "https://github.com/datawhalechina/all-in-rag/blob/main/code/C5/02_function_calling_example.py"
click node_evaluation "https://github.com/datawhalechina/all-in-rag/blob/main/code/C6/01_llamaindex_evaluation_example.py"
click node_agentic "https://github.com/datawhalechina/all-in-rag/blob/main/code/C7/agentic_rag/agent.py"
click node_c8main "https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/main.py"
click node_c8data "https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/rag_modules/data_preparation.py"
click node_c8index "https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/rag_modules/index_construction.py"
click node_c8retrieval "https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/rag_modules/retrieval_optimization.py"
click node_c8generation "https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/rag_modules/generation_integration.py"
click node_graphdata "https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/graph_data_preparation.py"
click node_graphindex "https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/graph_indexing.py"
click node_hybrid "https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/hybrid_retrieval.py"
click node_graphrag "https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/graph_rag_retrieval.py"
click node_router "https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/intelligent_query_router.py"
click node_recipeagent "https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/agent(%E4%BB%A3%E7%A0%81%E7%B3%BBai%E7%94%9F%E6%88%90)/recipe_ai_agent.py"
click node_powerrag "https://github.com/datawhalechina/all-in-rag/blob/main/Extra-chapter/PowerRAG-SDK-Text-QA/code/main.py"
click node_omni "https://github.com/datawhalechina/all-in-rag/blob/main/Extra-chapter/multimodal-embedding-omni-practice/code/08_jina_embedding_omni.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_loading,node_chunking toneBlue
class node_textembed,node_vectorindex,node_visualmodel,node_clipmodel,node_clipopenai,node_clipweights,node_cliprope,node_cliptransformer toneAmber
class node_generation,node_evaluation,node_agentic,node_c8main,node_c8data,node_c8index,node_c8retrieval,node_c8generation,node_recipeagent toneMint
class node_retrieval,node_text2sql,node_routing,node_graphdata,node_graphindex,node_hybrid,node_graphrag,node_router toneRose
class node_powerrag,node_omni,node_learner toneIndigo
```

## Components

### Data foundations

- [Document loading](https://github.com/datawhalechina/all-in-rag/blob/main/code/C2/01_unstructured_example.py): `code/C2/01_unstructured_example.py`
- [Text chunking](https://github.com/datawhalechina/all-in-rag/tree/main/code/C2): `code/C2`

### Indexing and search

- [Text embeddings](https://github.com/datawhalechina/all-in-rag/tree/main/code/C3): `code/C3`
- [Vector indexes](https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/04_multi_milvus.py): `code/C3/04_multi_milvus.py`
- [Visual BGE model](https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/modeling.py): `code/C3/visual_bge/visual_bge/modeling.py`
- [EVA CLIP model](https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/model.py): `code/C3/visual_bge/visual_bge/eva_clip/model.py`
- [CLIP compatibility](https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/openai.py): `code/C3/visual_bge/visual_bge/eva_clip/openai.py`
- [Pretrained weights](https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/pretrained.py): `code/C3/visual_bge/visual_bge/eva_clip/pretrained.py`
- [RoPE utilities](https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/rope.py): `code/C3/visual_bge/visual_bge/eva_clip/rope.py`
- [CLIP transformer](https://github.com/datawhalechina/all-in-rag/blob/main/code/C3/visual_bge/visual_bge/eva_clip/transformer.py): `code/C3/visual_bge/visual_bge/eva_clip/transformer.py`

### RAG applications

- [Structured generation](https://github.com/datawhalechina/all-in-rag/blob/main/code/C5/02_function_calling_example.py): `code/C5/02_function_calling_example.py`
- [RAG evaluation](https://github.com/datawhalechina/all-in-rag/blob/main/code/C6/01_llamaindex_evaluation_example.py): `code/C6/01_llamaindex_evaluation_example.py`
- [Agentic RAG](https://github.com/datawhalechina/all-in-rag/blob/main/code/C7/agentic_rag/agent.py): `code/C7/agentic_rag/agent.py`
- [Recipe RAG system](https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/main.py): `code/C8/main.py`
- [Data preparation](https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/rag_modules/data_preparation.py): `code/C8/rag_modules/data_preparation.py`
- [Index construction](https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/rag_modules/index_construction.py): `code/C8/rag_modules/index_construction.py`
- [Retrieval optimization](https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/rag_modules/retrieval_optimization.py): `code/C8/rag_modules/retrieval_optimization.py`
- [Generation integration](https://github.com/datawhalechina/all-in-rag/blob/main/code/C8/rag_modules/generation_integration.py): `code/C8/rag_modules/generation_integration.py`
- [Recipe AI agent](https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/agent(%E4%BB%A3%E7%A0%81%E7%B3%BBai%E7%94%9F%E6%88%90)/recipe_ai_agent.py): `code/C9/agent(代码系ai生成)/recipe_ai_agent.py`

### Advanced retrieval

- [Hybrid retrieval](https://github.com/datawhalechina/all-in-rag/blob/main/code/C4/01_hybrid_search.py): `code/C4/01_hybrid_search.py`
- [Text2SQL](https://github.com/datawhalechina/all-in-rag/blob/main/code/C4/text2sql/knowledge_base.py): `code/C4/text2sql/knowledge_base.py`
- [Query routing](https://github.com/datawhalechina/all-in-rag/blob/main/code/C4/05_llm_based_routing.py): `code/C4/05_llm_based_routing.py`
- [Graph data preparation](https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/graph_data_preparation.py): `code/C9/rag_modules/graph_data_preparation.py`
- [Graph indexing](https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/graph_indexing.py): `code/C9/rag_modules/graph_indexing.py`
- [Graph hybrid search](https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/hybrid_retrieval.py): `code/C9/rag_modules/hybrid_retrieval.py`
- [Graph RAG retrieval](https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/graph_rag_retrieval.py): `code/C9/rag_modules/graph_rag_retrieval.py`
- [Intelligent router](https://github.com/datawhalechina/all-in-rag/blob/main/code/C9/rag_modules/intelligent_query_router.py): `code/C9/rag_modules/intelligent_query_router.py`

### Extensions

- [PowerRAG SDK demo](https://github.com/datawhalechina/all-in-rag/blob/main/Extra-chapter/PowerRAG-SDK-Text-QA/code/main.py): `Extra-chapter/PowerRAG-SDK-Text-QA/code/main.py`
- [Omni embeddings](https://github.com/datawhalechina/all-in-rag/blob/main/Extra-chapter/multimodal-embedding-omni-practice/code/08_jina_embedding_omni.py): `Extra-chapter/multimodal-embedding-omni-practice/code/08_jina_embedding_omni.py`

### Other components

- **Developer**

## Connections

- Developer → Document loading: learns from (evidence: `README.md`)
- Document loading → Text chunking: prepares data (evidence: `README.md`)
- Text chunking → Text embeddings: feeds embeddings (evidence: `README.md`)
- Text embeddings → Vector indexes: builds indexes (evidence: `README.md`)
- Visual BGE model → CLIP compatibility: uses compatibility (evidence: `code/C3/visual_bge/visual_bge/modeling.py`)
- CLIP compatibility → EVA CLIP model: imports model (evidence: `code/C3/visual_bge/visual_bge/eva_clip/openai.py`)
- CLIP compatibility → Pretrained weights: imports weights (evidence: `code/C3/visual_bge/visual_bge/eva_clip/openai.py`)
- CLIP transformer → RoPE utilities: imports utilities (evidence: `code/C3/visual_bge/visual_bge/eva_clip/transformer.py`)
- Vector indexes → Hybrid retrieval: enables retrieval (evidence: `README.md`)
- Hybrid retrieval → Query routing: supports query strategies (evidence: `README.md`)
- Hybrid retrieval → Text2SQL: extends retrieval (evidence: `README.md`)
- Hybrid retrieval → Structured generation: supplies context (evidence: `README.md`)
- Structured generation → RAG evaluation: evaluated by (evidence: `README.md`)
- Developer → Agentic RAG: explores agents (evidence: `README.md`)
- Recipe RAG system → Data preparation: uses preparation
- Recipe RAG system → Index construction: uses indexing
- Recipe RAG system → Retrieval optimization: uses retrieval
- Recipe RAG system → Generation integration: uses generation
- Recipe RAG system → Retrieval optimization: queries chunks (evidence: `code/C8/main.py`)
- Recipe RAG system → Generation integration: routes and answers (evidence: `code/C8/main.py`)
- Graph data preparation → Graph indexing: prepares graph data
- Graph hybrid search → Graph indexing: uses graph keys (evidence: `code/C9/rag_modules/hybrid_retrieval.py`)
- Intelligent router → Graph hybrid search: selects strategy
- Intelligent router → Graph RAG retrieval: selects strategy
- Developer → PowerRAG SDK demo: tries SDK demo (evidence: `README.md`)
- Developer → Omni embeddings: explores multimodal (evidence: `README.md`)
