# knowflow-ai/knowflow architecture

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

- Interactive diagram: https://gitdiagram.com/knowflow-ai/knowflow
- Repository: https://github.com/knowflow-ai/knowflow

## Overview

#### Purpose and deployment shape
KnowFlow is an enterprise knowledge-base platform built as an extension layer around RAGFlow v0.20.5. It combines document ingestion, parsing/chunking, indexed RAG retrieval, chat/agent workflows, and tenant/team access control. RAGFlow remains the primary API/backend; KnowFlow adds an independently deployable service for enhanced parsing and RBAC. Main runtime entry points are `api/ragflow_server.py`, `knowflow/server/app.py`, `web/src/main.ts`, and `knowflow/web/src/main.ts`.

#### API and application boundary
RAGFlow’s Python API is organized as domain application handlers over database services: files/documents, knowledge bases, chunks, conversations/dialogs, LLMs, agents/canvases, search, plugins, MCP, and tenant/user administration. Representative paths: `api/apps/document_app.py`, `api/apps/kb_app.py`, `api/apps/dialog_app.py`. Persistence models and service-layer operations are centralized in `api/db/db_models.py`, `api/db/services/knowledgebase_service.py`, and `api/db/services/conversation_service.py`.

KnowFlow exposes a separate server for enhanced document, knowledge-base, file, user/team, and RBAC operations: `knowflow/server/app.py`, `knowflow/server/routes/knowledgebases/routes.py`, `knowflow/server/routes/rbac/rbac_routes.py`.

#### Knowledge ingestion and parsing
The ingestion flow is: upload/link file → create document metadata → choose parsing engine and chunking strategy → persist source artifacts and chunks → index for retrieval. RAGFlow’s parser/chunker pipeline is represented by `rag/flow/pipeline.py`, `rag/flow/parser/parser.py`, and `rag/flow/chunker/chunker.py`.

KnowFlow’s knowledge-base service dispatches enhanced parsing and preserves coordinate-aware content mappings: `knowflow/server/services/knowledgebases/service.py`, `knowflow/server/services/knowledgebases/document_parser.py`, `knowflow/server/services/knowledgebases/common/coordinate_mappers.py`. It can call MinerU, DOTS, PaddleOCR, and format-conversion services through adapters such as `knowflow/server/services/knowledgebases/mineru_parse/fastapi_adapter.py` and `knowflow/server/services/knowledgebases/dots_parse/dots_fastapi_adapter.py`.

#### Chunking, retrieval, and graph enrichment
Chunking supports inherited RAGFlow strategies plus smart, title, regex, and parent-child approaches. Strategy implementations reside in `rag/app/smart.py`, `rag/app/title.py`, `rag/app/regex.py`, and `rag/app/parent_child.py`; parent-child NLP support is in `rag/nlp/parent_child_splitter.py`.

Retrieval couples embeddings/reranking/LLM adapters with search and document-store connectors: `rag/llm/embedding_model.py`, `rag/nlp/search.py`, and `rag/utils/storage_factory.py`. Optional GraphRAG builds entities, relations, communities, and graph-oriented search from indexed content: `graphrag/general/index.py`, `graphrag/general/graph_extractor.py`, `graphrag/search.py`.

#### Chat, agents, and programmable flows
Conversational applications retrieve relevant chunks and invoke configured LLMs, while agent workflows execute serialized graph DSLs with branching, iteration, tool calls, retrieval, and message stages. Core agent canvas/component execution is under `agent/canvas.py`, `agent/component/agent_with_tools.py`, and `agent/component/iteration.py`. Built-in integrations include search, retrieval, SQL execution, crawler, email, and finance/research tools in `agent/tools/retrieval.py`, `agent/tools/exesql.py`, and `agent/tools/tavily.py`.

MCP is a separate protocol boundary, with server/client entry points at `mcp/server/server.py` and `mcp/client/client.py`. Untrusted code execution is isolated in the container-oriented sandbox service: `sandbox/executor_manager/main.py` and `sandbox/executor_manager/services/execution.py`.

#### Frontend clients
The main RAGFlow UI is a TypeScript React-oriented application exposing knowledge, chat, search, agent, and data-flow canvases: `web/src/main.ts`, `web/src/pages/agent/index.tsx`, `web/src/pages/data-flow/index.tsx`. It communicates through domain service clients such as `web/src/services/knowledge-service.ts` and `web/src/services/chat-service.ts`.

KnowFlow also contains a separate Vue-based administrative UI focused on knowledge bases, documents, users, teams, and permissions: `knowflow/web/src/main.ts`, `knowflow/web/src/pages/knowledgebase/index.vue`, and `knowflow/web/src/pages/user-management/index.vue`.

#### Infrastructure and external dependencies
Docker Compose is the primary deployment topology, rooted in `docker/docker-compose.yml`; Nginx routes public traffic via `docker/nginx/nginx.conf`. RAGFlow/KnowFlow share MySQL for metadata, Elasticsearch/OpenSearch or Infinity for indexed retrieval, MinIO/object storage for files, and Redis for caching/task coordination. Deployment definitions demonstrate these dependencies in `docker/docker-compose-base.yml`, `helm/templates/ragflow.yaml`, and `helm/templates/redis.yaml`.

OCR/parser engines are externally callable services, optionally GPU-backed: `docker/mineru/docker-compose.yml`, `docker/dots/docker-compose.yml`, and `docker/paddleocr/docker-compose.yml`. LLM provider configuration is data-driven through `conf/llm_factories.json`.

Main entry points: [`agent/canvas.py`](https://github.com/knowflow-ai/knowflow/blob/main/agent/canvas.py) (Chat & agent runtime), [`rag/nlp/search.py`](https://github.com/knowflow-ai/knowflow/blob/main/rag/nlp/search.py) (Retrieval layer), [`docker/nginx/nginx.conf`](https://github.com/knowflow-ai/knowflow/blob/main/docker/nginx/nginx.conf) (Nginx), [`docker/docker-compose.yml`](https://github.com/knowflow-ai/knowflow/blob/main/docker/docker-compose.yml) (Docker Compose)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients"]
  node_ragflow_ui["RAGFlow UI<br/>React client<br/>[main.ts]"]
  node_knowflow_ui["KnowFlow Admin UI<br/>Vue client<br/>[main.ts]"]
end

subgraph group_ragflow["RAGFlow Core"]
  node_ragflow_api["RAGFlow API<br/>Python server<br/>[ragflow_server.py]"]
  node_domain_apps["Domain handlers<br/>application layer<br/>[document_app.py]"]
  node_metadata_services[("Metadata services<br/>persistence layer")]
  node_ingestion_pipeline["Ingestion pipeline<br/>parse and chunk flow<br/>[pipeline.py]"]
  node_chunk_strategies["Chunk strategies<br/>chunking<br/>[parent_child.py]"]
  node_retrieval["Retrieval layer<br/>RAG search<br/>[search.py]"]
  node_graphrag["GraphRAG<br/>optional enrichment<br/>[index.py]"]
  node_chat_agents["Chat &amp; agent runtime<br/>workflow execution<br/>[canvas.py]"]
  node_mcp["MCP boundary<br/>protocol service<br/>[server.py]"]
end

subgraph group_knowflow["KnowFlow Extension"]
  node_knowflow_api["KnowFlow server<br/>Python server<br/>[app.py]"]
  node_enhanced_kb["Enhanced KB service<br/>knowledge service<br/>[service.py]"]
  node_rbac["RBAC routes<br/>access control API<br/>[rbac_routes.py]"]
end

subgraph group_runtime["Deployment &amp; Dependencies"]
  node_nginx["Nginx<br/>public gateway<br/>[nginx.conf]"]
  node_sandbox["Code sandbox<br/>isolated executor<br/>[main.py]"]
  node_parser_engines["External parser engines<br/>OCR/parser services<br/>[docker-compose.yml]"]
  node_data_services[("Shared data services")]
  node_llm_providers["LLM providers<br/>model adapters<br/>[llm_factories.json]"]
  node_compose["Docker Compose<br/>deployment topology<br/>[docker-compose.yml]"]
end

node_ragflow_ui -->|"public requests"| node_nginx
node_knowflow_ui -->|"public requests"| node_nginx
node_nginx -->|"routes API"| node_ragflow_api
node_nginx -->|"routes admin API"| node_knowflow_api
node_ragflow_api -->|"dispatches"| node_domain_apps
node_domain_apps -->|"persists metadata"| node_metadata_services
node_domain_apps -->|"ingests documents"| node_ingestion_pipeline
node_ingestion_pipeline -->|"chunks content"| node_chunk_strategies
node_ingestion_pipeline -->|"indexes chunks"| node_retrieval
node_retrieval -->|"uses indexes and files"| node_data_services
node_metadata_services -->|"uses metadata store"| node_data_services
node_retrieval -->|"embeds and reranks"| node_llm_providers
node_retrieval -.->|"optional graph indexing"| node_graphrag
node_domain_apps -->|"runs chat and flows"| node_chat_agents
node_chat_agents -->|"retrieves context"| node_retrieval
node_chat_agents -->|"invokes models"| node_llm_providers
node_chat_agents -->|"uses integrations"| node_mcp
node_chat_agents -->|"executes untrusted code"| node_sandbox
node_knowflow_api -->|"serves KB operations"| node_enhanced_kb
node_knowflow_api -->|"enforces access control"| node_rbac
node_enhanced_kb -->|"calls adapters"| node_parser_engines
node_enhanced_kb -->|"stores artifacts and mappings"| node_data_services
node_compose -->|"deploys"| node_nginx
node_compose -->|"deploys"| node_data_services
node_compose -->|"deploys"| node_ragflow_api
node_compose -->|"deploys"| node_knowflow_api

click node_ragflow_ui "https://github.com/knowflow-ai/knowflow/blob/main/web/src/main.ts"
click node_knowflow_ui "https://github.com/knowflow-ai/knowflow/blob/main/knowflow/web/src/main.ts"
click node_nginx "https://github.com/knowflow-ai/knowflow/blob/main/docker/nginx/nginx.conf"
click node_ragflow_api "https://github.com/knowflow-ai/knowflow/blob/main/api/ragflow_server.py"
click node_domain_apps "https://github.com/knowflow-ai/knowflow/blob/main/api/apps/document_app.py"
click node_metadata_services "https://github.com/knowflow-ai/knowflow/blob/main/api/db/services/knowledgebase_service.py"
click node_ingestion_pipeline "https://github.com/knowflow-ai/knowflow/blob/main/rag/flow/pipeline.py"
click node_chunk_strategies "https://github.com/knowflow-ai/knowflow/blob/main/rag/app/parent_child.py"
click node_retrieval "https://github.com/knowflow-ai/knowflow/blob/main/rag/nlp/search.py"
click node_graphrag "https://github.com/knowflow-ai/knowflow/blob/main/graphrag/general/index.py"
click node_chat_agents "https://github.com/knowflow-ai/knowflow/blob/main/agent/canvas.py"
click node_mcp "https://github.com/knowflow-ai/knowflow/blob/main/mcp/server/server.py"
click node_sandbox "https://github.com/knowflow-ai/knowflow/blob/main/sandbox/executor_manager/main.py"
click node_knowflow_api "https://github.com/knowflow-ai/knowflow/blob/main/knowflow/server/app.py"
click node_enhanced_kb "https://github.com/knowflow-ai/knowflow/blob/main/knowflow/server/services/knowledgebases/service.py"
click node_rbac "https://github.com/knowflow-ai/knowflow/blob/main/knowflow/server/routes/rbac/rbac_routes.py"
click node_parser_engines "https://github.com/knowflow-ai/knowflow/blob/main/docker/mineru/docker-compose.yml"
click node_data_services "https://github.com/knowflow-ai/knowflow/blob/main/docker/docker-compose-base.yml"
click node_llm_providers "https://github.com/knowflow-ai/knowflow/blob/main/conf/llm_factories.json"
click node_compose "https://github.com/knowflow-ai/knowflow/blob/main/docker/docker-compose.yml"

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_ragflow_ui,node_knowflow_ui toneBlue
class node_ragflow_api,node_domain_apps,node_metadata_services,node_ingestion_pipeline,node_chunk_strategies,node_retrieval,node_graphrag,node_chat_agents,node_mcp toneAmber
class node_knowflow_api,node_enhanced_kb,node_rbac toneMint
class node_nginx,node_sandbox,node_parser_engines,node_data_services,node_llm_providers,node_compose toneRose
```

## Components

### Clients

- [RAGFlow UI](https://github.com/knowflow-ai/knowflow/blob/main/web/src/main.ts): React client · Knowledge, chat, search, agent, and data-flow canvases. · `web/src/main.ts`
- [KnowFlow Admin UI](https://github.com/knowflow-ai/knowflow/blob/main/knowflow/web/src/main.ts): Vue client · Administration for knowledge bases, users, teams, and permissions. · `knowflow/web/src/main.ts`

### RAGFlow Core

- [RAGFlow API](https://github.com/knowflow-ai/knowflow/blob/main/api/ragflow_server.py): Python server · Primary backend and domain application boundary. · `api/ragflow_server.py`
- [Domain handlers](https://github.com/knowflow-ai/knowflow/blob/main/api/apps/document_app.py): application layer · Document, knowledge-base, conversation, and administration APIs. · `api/apps/document_app.py`
- [Metadata services](https://github.com/knowflow-ai/knowflow/blob/main/api/db/services/knowledgebase_service.py): persistence layer · Database models and knowledge-base/conversation operations. · `api/db/services/knowledgebase_service.py`
- [Ingestion pipeline](https://github.com/knowflow-ai/knowflow/blob/main/rag/flow/pipeline.py): parse and chunk flow · Selects parsers and chunking before indexing. · `rag/flow/pipeline.py`
- [Chunk strategies](https://github.com/knowflow-ai/knowflow/blob/main/rag/app/parent_child.py): chunking · Smart, title, regex, and parent-child splitting. · `rag/app/parent_child.py`
- [Retrieval layer](https://github.com/knowflow-ai/knowflow/blob/main/rag/nlp/search.py): RAG search · Embeddings, reranking, search, and storage connectors. · `rag/nlp/search.py`
- [GraphRAG](https://github.com/knowflow-ai/knowflow/blob/main/graphrag/general/index.py): optional enrichment · Extracts graph entities and relations for graph search. · `graphrag/general/index.py`
- [Chat & agent runtime](https://github.com/knowflow-ai/knowflow/blob/main/agent/canvas.py): workflow execution · Retrieval-backed chat and serialized agent DSL execution. · `agent/canvas.py`
- [MCP boundary](https://github.com/knowflow-ai/knowflow/blob/main/mcp/server/server.py): protocol service · Client/server integration protocol. · `mcp/server/server.py`

### KnowFlow Extension

- [KnowFlow server](https://github.com/knowflow-ai/knowflow/blob/main/knowflow/server/app.py): Python server · Independent enhanced parsing and RBAC service. · `knowflow/server/app.py`
- [Enhanced KB service](https://github.com/knowflow-ai/knowflow/blob/main/knowflow/server/services/knowledgebases/service.py): knowledge service · Dispatches enhanced parsing and coordinate-aware mappings. · `knowflow/server/services/knowledgebases/service.py`
- [RBAC routes](https://github.com/knowflow-ai/knowflow/blob/main/knowflow/server/routes/rbac/rbac_routes.py): access control API · `knowflow/server/routes/rbac/rbac_routes.py`

### Deployment & Dependencies

- [Nginx](https://github.com/knowflow-ai/knowflow/blob/main/docker/nginx/nginx.conf): public gateway · `docker/nginx/nginx.conf`
- [Code sandbox](https://github.com/knowflow-ai/knowflow/blob/main/sandbox/executor_manager/main.py): isolated executor · Container-oriented untrusted code execution. · `sandbox/executor_manager/main.py`
- [External parser engines](https://github.com/knowflow-ai/knowflow/blob/main/docker/mineru/docker-compose.yml): OCR/parser services · MinerU, DOTS, PaddleOCR, and conversion services. · `docker/mineru/docker-compose.yml`
- [Shared data services](https://github.com/knowflow-ai/knowflow/blob/main/docker/docker-compose-base.yml): MySQL, search, object store, Redis · Metadata, indexes, source files, cache, and task coordination. · `docker/docker-compose-base.yml`
- [LLM providers](https://github.com/knowflow-ai/knowflow/blob/main/conf/llm_factories.json): model adapters · Data-driven embedding, reranking, and generation providers. · `conf/llm_factories.json`
- [Docker Compose](https://github.com/knowflow-ai/knowflow/blob/main/docker/docker-compose.yml): deployment topology · `docker/docker-compose.yml`

## Connections

- RAGFlow UI → Nginx: public requests
- KnowFlow Admin UI → Nginx: public requests
- Nginx → RAGFlow API: routes API
- Nginx → KnowFlow server: routes admin API
- RAGFlow API → Domain handlers: dispatches
- Domain handlers → Metadata services: persists metadata
- Domain handlers → Ingestion pipeline: ingests documents
- Ingestion pipeline → Chunk strategies: chunks content
- Ingestion pipeline → Retrieval layer: indexes chunks
- Retrieval layer → Shared data services: uses indexes and files
- Metadata services → Shared data services: uses metadata store
- Retrieval layer → LLM providers: embeds and reranks
- Retrieval layer → GraphRAG: optional graph indexing
- Domain handlers → Chat & agent runtime: runs chat and flows
- Chat & agent runtime → Retrieval layer: retrieves context
- Chat & agent runtime → LLM providers: invokes models
- Chat & agent runtime → MCP boundary: uses integrations
- Chat & agent runtime → Code sandbox: executes untrusted code
- KnowFlow server → Enhanced KB service: serves KB operations
- KnowFlow server → RBAC routes: enforces access control
- Enhanced KB service → External parser engines: calls adapters
- Enhanced KB service → Shared data services: stores artifacts and mappings
- Docker Compose → Nginx: deploys
- Docker Compose → Shared data services: deploys
- Docker Compose → RAGFlow API: deploys
- Docker Compose → KnowFlow server: deploys
