How knowflow-ai/knowflow works
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: canvas.py Chat & agent runtime · search.py Retrieval layer · nginx.conf Nginx · docker-compose.yml Docker Compose
Components 20
Clients
- RAGFlow UI · Knowledge, chat, search, agent, and data-flow canvases.
web/src/main.ts - KnowFlow Admin UI · Administration for knowledge bases, users, teams, and permissions.
knowflow/web/src/main.ts
RAGFlow Core
- RAGFlow API · Primary backend and domain application boundary.
api/ragflow_server.py - Domain handlers · Document, knowledge-base, conversation, and administration APIs.
api/apps/document_app.py - Metadata services · Database models and knowledge-base/conversation operations.
api/db/services/knowledgebase_service.py - Ingestion pipeline · Selects parsers and chunking before indexing.
rag/flow/pipeline.py - Chunk strategies · Smart, title, regex, and parent-child splitting.
rag/app/parent_child.py - Retrieval layer · Embeddings, reranking, search, and storage connectors.
rag/nlp/search.py - GraphRAG · Extracts graph entities and relations for graph search.
graphrag/general/index.py - Chat & agent runtime · Retrieval-backed chat and serialized agent DSL execution.
agent/canvas.py - MCP boundary · Client/server integration protocol.
mcp/server/server.py
KnowFlow Extension
- KnowFlow server · Independent enhanced parsing and RBAC service.
knowflow/server/app.py - Enhanced KB service · Dispatches enhanced parsing and coordinate-aware mappings.
knowflow/server/services/knowledgebases/service.py - RBAC routes
knowflow/server/routes/rbac/rbac_routes.py
Deployment & Dependencies
- Nginx
docker/nginx/nginx.conf - Code sandbox · Container-oriented untrusted code execution.
sandbox/executor_manager/main.py - External parser engines · MinerU, DOTS, PaddleOCR, and conversion services.
docker/mineru/docker-compose.yml - Shared data services · Metadata, indexes, source files, cache, and task coordination.
docker/docker-compose-base.yml - LLM providers · Data-driven embedding, reranking, and generation providers.
conf/llm_factories.json - Docker Compose
docker/docker-compose.yml
Connections 26
- 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