# infiniflow/ragflow architecture

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

- Interactive diagram: https://gitdiagram.com/infiniflow/ragflow
- Repository: https://github.com/infiniflow/ragflow

## Overview

RAGFlow is a RAG engine combining document ingestion, knowledge organization, retrieval, and agent workflows. The primary journey is to configure a parsing pipeline, ingest documents into a knowledge base, retrieve grounded evidence for a question, and return an answer through chat or an API. The graph includes those stages plus pipeline execution and agent orchestration. Several backend implementations are unsampled, so high-level relationships rely on README descriptions; unsampled subsystems are represented by their exact tree paths rather than assumed internal call chains.

Main entry points: [`internal/ingestion/pipeline/pipeline.go`](https://github.com/infiniflow/ragflow/blob/main/internal/ingestion/pipeline/pipeline.go) (Ingestion Pipeline), [`web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts`](https://github.com/infiniflow/ragflow/blob/main/web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts) (Document Pipeline Form), [`internal/service/chat_pipeline.go`](https://github.com/infiniflow/ragflow/blob/main/internal/service/chat_pipeline.go) (Chat Service), [`internal/handler/dify_retrieval_handler.go`](https://github.com/infiniflow/ragflow/blob/main/internal/handler/dify_retrieval_handler.go) (Retrieval API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Product Entry"]
  node_api["HTTP API<br/>[server.go]"]
  node_chat["Chat Service<br/>[chat_pipeline.go]"]
  node_channel["Messaging Channels"]
end

subgraph group_ingest["Ingestion and Knowledge"]
  node_taskservice["Ingestion Tasks"]
  node_ingestor["Ingestion Worker"]
  node_executor["Pipeline Executor"]
  node_pipeline["Ingestion Pipeline<br/>[pipeline.go]"]
  node_parsers["Document Parsers"]
  node_native["Native Analyzer<br/>[main.cpp]"]
  node_storage[("File Storage<br/>[storage_factory.go]")]
  node_dao[("Knowledge and Document Data")]
  node_compile["Knowledge Compilation<br/>[pipeline.go]"]
end

subgraph group_retrieve["Retrieval and Answers"]
  node_retrievalapi["Retrieval API"]
  node_retrieval["Retrieval Service"]
  node_agenticrag["Agentic RAG"]
end

subgraph group_agent["Agent Runtime"]
  node_agentpipe["Agent Pipeline"]
  node_canvas["Canvas Runtime<br/>[runner.go]"]
  node_pregel["Graph Engine<br/>[engine.go]"]
  node_components["Agent Components<br/>[registry.go]"]
  node_sandbox["Code Sandbox<br/>[manager.go]"]
end

subgraph group_config["Pipeline Configuration"]
  node_pipelineform["Document Pipeline Form"]
  node_tree["Parser Version Selector"]
  node_operator["Operator Config Mapping"]
  node_validation["Parser Config Validation"]
  node_forms["Operator Form Hook"]
end

node_user(("User"))

node_user -.->|"submits requests"| node_api
node_api -.->|"serves chat"| node_chat
node_user -.->|"configures parsing"| node_pipelineform
node_pipelineform -->|"selects pipeline"| node_tree
node_pipelineform -->|"loads operators"| node_forms
node_pipelineform -->|"transforms config"| node_operator
node_validation -->|"gets operator type"| node_operator
node_user -.->|"requests ingestion"| node_taskservice
node_taskservice -.->|"queues tasks"| node_ingestor
node_ingestor -.->|"runs document task"| node_executor
node_executor -.->|"executes pipeline"| node_pipeline
node_pipeline -.->|"parses documents"| node_parsers
node_parsers -.->|"uses analysis"| node_native
node_pipeline -.->|"stores files"| node_storage
node_pipeline -.->|"records knowledge"| node_dao
node_pipeline -.->|"compiles knowledge"| node_compile
node_user -.->|"asks question"| node_retrievalapi
node_retrievalapi -.->|"retrieves chunks"| node_retrieval
node_retrievalapi -->|"fetches documents"| node_dao
node_chat -.->|"retrieves evidence"| node_agenticrag
node_agenticrag -.->|"performs retrieval"| node_retrieval
node_chat -.->|"returns grounded answer"| node_user
node_user -.->|"messages agent"| node_channel
node_channel -.->|"routes interaction"| node_agentpipe
node_agentpipe -.->|"runs workflow"| node_canvas
node_canvas -.->|"executes graph"| node_pregel
node_canvas -.->|"dispatches components"| node_components
node_components -.->|"runs code tools"| node_sandbox

click node_api "https://github.com/infiniflow/ragflow/blob/main/internal/server/api/server.go"
click node_chat "https://github.com/infiniflow/ragflow/blob/main/internal/service/chat_pipeline.go"
click node_channel "https://github.com/infiniflow/ragflow/tree/main/internal/channels"
click node_taskservice "https://github.com/infiniflow/ragflow/blob/main/internal/service/ingestion_task_service.go"
click node_ingestor "https://github.com/infiniflow/ragflow/blob/main/internal/ingestion/service/ingestion_service.go"
click node_executor "https://github.com/infiniflow/ragflow/blob/main/internal/ingestion/task/pipeline_executor.go"
click node_pipeline "https://github.com/infiniflow/ragflow/blob/main/internal/ingestion/pipeline/pipeline.go"
click node_parsers "https://github.com/infiniflow/ragflow/tree/main/internal/deepdoc/parser"
click node_native "https://github.com/infiniflow/ragflow/blob/main/internal/binding/cpp/main.cpp"
click node_storage "https://github.com/infiniflow/ragflow/blob/main/internal/storage/storage_factory.go"
click node_dao "https://github.com/infiniflow/ragflow/tree/main/internal/dao"
click node_compile "https://github.com/infiniflow/ragflow/blob/main/internal/service/graph/pipeline.go"
click node_retrievalapi "https://github.com/infiniflow/ragflow/blob/main/internal/handler/dify_retrieval_handler.go"
click node_retrieval "https://github.com/infiniflow/ragflow/blob/main/internal/agent/tool/retrieval_service.go"
click node_agenticrag "https://github.com/infiniflow/ragflow/tree/main/internal/agentic_rag"
click node_agentpipe "https://github.com/infiniflow/ragflow/blob/main/internal/service/agentic_pipeline.go"
click node_canvas "https://github.com/infiniflow/ragflow/blob/main/internal/agent/canvas/runner.go"
click node_pregel "https://github.com/infiniflow/ragflow/blob/main/internal/harness/graph/pregel/engine.go"
click node_components "https://github.com/infiniflow/ragflow/blob/main/internal/agent/component/registry.go"
click node_sandbox "https://github.com/infiniflow/ragflow/blob/main/internal/agent/sandbox/manager.go"
click node_pipelineform "https://github.com/infiniflow/ragflow/blob/main/web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts"
click node_tree "https://github.com/infiniflow/ragflow/blob/main/web/src/components/parser-tree-select/use-parser-tree-data.tsx"
click node_operator "https://github.com/infiniflow/ragflow/blob/main/web/src/utils/pipeline-operator.ts"
click node_validation "https://github.com/infiniflow/ragflow/blob/main/web/src/components/pipeline-operator-tabs/parser-config-validation.ts"
click node_forms "https://github.com/infiniflow/ragflow/blob/main/web/src/hooks/use-pipeline-operator.ts"

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_api,node_chat,node_channel,node_user toneBlue
class node_taskservice,node_ingestor,node_executor,node_pipeline,node_parsers,node_native,node_storage,node_dao,node_compile toneAmber
class node_retrievalapi,node_retrieval,node_agenticrag toneMint
class node_agentpipe,node_canvas,node_pregel,node_components,node_sandbox toneRose
class node_pipelineform,node_tree,node_operator,node_validation,node_forms toneIndigo
```

## Components

### Product Entry

- [HTTP API](https://github.com/infiniflow/ragflow/blob/main/internal/server/api/server.go): `internal/server/api/server.go`
- [Chat Service](https://github.com/infiniflow/ragflow/blob/main/internal/service/chat_pipeline.go): `internal/service/chat_pipeline.go`
- [Messaging Channels](https://github.com/infiniflow/ragflow/tree/main/internal/channels): `internal/channels`

### Ingestion and Knowledge

- [Ingestion Tasks](https://github.com/infiniflow/ragflow/blob/main/internal/service/ingestion_task_service.go): `internal/service/ingestion_task_service.go`
- [Ingestion Worker](https://github.com/infiniflow/ragflow/blob/main/internal/ingestion/service/ingestion_service.go): `internal/ingestion/service/ingestion_service.go`
- [Pipeline Executor](https://github.com/infiniflow/ragflow/blob/main/internal/ingestion/task/pipeline_executor.go): `internal/ingestion/task/pipeline_executor.go`
- [Ingestion Pipeline](https://github.com/infiniflow/ragflow/blob/main/internal/ingestion/pipeline/pipeline.go): `internal/ingestion/pipeline/pipeline.go`
- [Document Parsers](https://github.com/infiniflow/ragflow/tree/main/internal/deepdoc/parser): `internal/deepdoc/parser`
- [Native Analyzer](https://github.com/infiniflow/ragflow/blob/main/internal/binding/cpp/main.cpp): `internal/binding/cpp/main.cpp`
- [File Storage](https://github.com/infiniflow/ragflow/blob/main/internal/storage/storage_factory.go): `internal/storage/storage_factory.go`
- [Knowledge and Document Data](https://github.com/infiniflow/ragflow/tree/main/internal/dao): `internal/dao`
- [Knowledge Compilation](https://github.com/infiniflow/ragflow/blob/main/internal/service/graph/pipeline.go): `internal/service/graph/pipeline.go`

### Retrieval and Answers

- [Retrieval API](https://github.com/infiniflow/ragflow/blob/main/internal/handler/dify_retrieval_handler.go): `internal/handler/dify_retrieval_handler.go`
- [Retrieval Service](https://github.com/infiniflow/ragflow/blob/main/internal/agent/tool/retrieval_service.go): `internal/agent/tool/retrieval_service.go`
- [Agentic RAG](https://github.com/infiniflow/ragflow/tree/main/internal/agentic_rag): `internal/agentic_rag`

### Agent Runtime

- [Agent Pipeline](https://github.com/infiniflow/ragflow/blob/main/internal/service/agentic_pipeline.go): `internal/service/agentic_pipeline.go`
- [Canvas Runtime](https://github.com/infiniflow/ragflow/blob/main/internal/agent/canvas/runner.go): `internal/agent/canvas/runner.go`
- [Graph Engine](https://github.com/infiniflow/ragflow/blob/main/internal/harness/graph/pregel/engine.go): `internal/harness/graph/pregel/engine.go`
- [Agent Components](https://github.com/infiniflow/ragflow/blob/main/internal/agent/component/registry.go): `internal/agent/component/registry.go`
- [Code Sandbox](https://github.com/infiniflow/ragflow/blob/main/internal/agent/sandbox/manager.go): `internal/agent/sandbox/manager.go`

### Pipeline Configuration

- [Document Pipeline Form](https://github.com/infiniflow/ragflow/blob/main/web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts): `web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts`
- [Parser Version Selector](https://github.com/infiniflow/ragflow/blob/main/web/src/components/parser-tree-select/use-parser-tree-data.tsx): `web/src/components/parser-tree-select/use-parser-tree-data.tsx`
- [Operator Config Mapping](https://github.com/infiniflow/ragflow/blob/main/web/src/utils/pipeline-operator.ts): `web/src/utils/pipeline-operator.ts`
- [Parser Config Validation](https://github.com/infiniflow/ragflow/blob/main/web/src/components/pipeline-operator-tabs/parser-config-validation.ts): `web/src/components/pipeline-operator-tabs/parser-config-validation.ts`
- [Operator Form Hook](https://github.com/infiniflow/ragflow/blob/main/web/src/hooks/use-pipeline-operator.ts): `web/src/hooks/use-pipeline-operator.ts`

### Other components

- **User**

## Connections

- User → HTTP API: submits requests (evidence: `README.md`)
- HTTP API → Chat Service: serves chat (evidence: `README.md`)
- User → Document Pipeline Form: configures parsing (evidence: `README.md`)
- Document Pipeline Form → Parser Version Selector: selects pipeline (evidence: `web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts`)
- Document Pipeline Form → Operator Form Hook: loads operators (evidence: `web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts`)
- Document Pipeline Form → Operator Config Mapping: transforms config (evidence: `web/src/components/document-pipeline-dialog/use-document-pipeline-form.ts`)
- Parser Config Validation → Operator Config Mapping: gets operator type (evidence: `web/src/components/pipeline-operator-tabs/parser-config-validation.ts`)
- User → Ingestion Tasks: requests ingestion (evidence: `README.md`)
- Ingestion Tasks → Ingestion Worker: queues tasks
- Ingestion Worker → Pipeline Executor: runs document task (evidence: `internal/ingestion/service/ingestion_service.go`)
- Pipeline Executor → Ingestion Pipeline: executes pipeline
- Ingestion Pipeline → Document Parsers: parses documents (evidence: `README.md`)
- Document Parsers → Native Analyzer: uses analysis
- Ingestion Pipeline → File Storage: stores files (evidence: `README.md`)
- Ingestion Pipeline → Knowledge and Document Data: records knowledge (evidence: `README.md`)
- Ingestion Pipeline → Knowledge Compilation: compiles knowledge (evidence: `README.md`)
- User → Retrieval API: asks question (evidence: `README.md`)
- Retrieval API → Retrieval Service: retrieves chunks (evidence: `internal/handler/dify_retrieval_handler.go`)
- Retrieval API → Knowledge and Document Data: fetches documents (evidence: `internal/handler/dify_retrieval_handler.go`)
- Chat Service → Agentic RAG: retrieves evidence (evidence: `README.md`)
- Agentic RAG → Retrieval Service: performs retrieval (evidence: `README.md`)
- Chat Service → User: returns grounded answer (evidence: `README.md`)
- User → Messaging Channels: messages agent (evidence: `README.md`)
- Messaging Channels → Agent Pipeline: routes interaction
- Agent Pipeline → Canvas Runtime: runs workflow
- Canvas Runtime → Graph Engine: executes graph
- Canvas Runtime → Agent Components: dispatches components
- Agent Components → Code Sandbox: runs code tools
