This document provides an in-depth overview of RAGFlow's layered architecture, describing how the API gateway, service layer, worker layer, and storage layer interact to deliver document-based conversational AI capabilities. RAGFlow is a retrieval-augmented generation engine that combines deep document understanding with agentic workflows.
For specific implementation details:
For frontend architecture, see Frontend Application. For LLM integration patterns, see LLM Integration System. For document processing pipelines, see Document Processing Pipeline.
RAGFlow employs a five-layer microservices architecture that separates concerns across client interaction, API routing, business logic, asynchronous processing, and data persistence. The system is designed for horizontal scalability with stateless API servers and distributed worker processes communicating through Redis-backed message queues or NATS conf/service_conf.yaml51-70
The architecture follows these principles:
user_default_llm and default models conf/service_conf.yaml74-80--api, --admin, --ingestor, and --syncer cmd/ragflow_server.go81-94This diagram illustrates RAGFlow's modular subsystems and code entity mapping:
Sources:
api/ragflow_server.py163-165 cmd/ragflow_server.go81-94 conf/service_conf.yaml7-55 rag/utils/redis_conn.py61-114
A client uploads a document via the API server. The DocumentService handles metadata while the system tracks progress asynchronously. A dedicated thread in the Python server periodically updates processing progress api/ragflow_server.py55-71
Sources:
api/ragflow_server.py55-71 api/ragflow_server.py134-138 conf/service_conf.yaml67-70
Provides external interfaces. The Python SDK and Direct HTTP APIs interact with the ragflow service api/ragflow_server.py17-36
Manages synchronous requests. RAGFlow supports a dual-language entry point:
api/ragflow_server.py using Quart, initialized with database tables and superuser data api/ragflow_server.py106-121cmd/ragflow_server.go which handles --api and --admin modes cmd/ragflow_server.go81-94Encapsulates business logic. The Python side uses a service pattern (e.g., DocumentService api/db/services/document_service.py42-73), while the Go side provides a native internal/service/ layer for NLP and search internal/admin/handler.go25-30
Background workers process tasks from NATS or Redis Streams. The TaskExecutor in Python processes parsing, embedding, and GraphRAG tasks rag/svr/task_executor.py114-147 The Go-native ingestor handles document processing pipelines cmd/ragflow_server.go188-200
A polyglot strategy using:
max_connections and stale_timeout tuning conf/service_conf.yaml7-15This diagram maps high-level system concepts to specific Go and Python entities.
Sources:
internal/server/config.go19-30 rag/utils/redis_conn.py61-64 rag/svr/task_executor.py114-131 internal/admin/handler.go94-137 rag/nlp/search.py39-54
RAGFlow's architecture provides a modular, scalable platform to deliver retrieval-augmented generation. By utilizing a hybrid Python-Go backend, it balances the rapid development of AI features in Python with the high-performance execution of ingestion and agent workflows in Go.
Sources:
api/ragflow_server.py82-165 cmd/ragflow_server.go81-94 conf/service_conf.yaml1-80
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.