RAGFlow provides a robust external data source connector system that allows users to synchronize content from over 30 external platforms directly into their knowledge bases. This system automates the ingestion of documents, spreadsheets, code repositories, and communication logs, integrating them into the RAGFlow document processing pipeline.
The connector system is built on a multi-tier architecture that handles authentication, periodic polling, incremental synchronization, and error recovery. It abstracts various APIs (REST, GraphQL, WebDAV, etc.) into a unified Document model that RAGFlow can parse and index.
Supported sources are defined in the FileSource enum common/constants.py141-179 and DocumentSource enum common/data_source/config.py43-79 They include:
The connector system bridges the gap between external API spaces and RAGFlow's internal storage and task execution layers.
The following diagram maps the logical components to their specific code implementations across the React frontend, the Python backend, and the Go service layer.
Diagram: Connector System Code Entities
Sources: web/src/pages/user-setting/data-source/constant/index.tsx18-54 api/db/services/connector_service.py38-40 rag/svr/sync_data_source.py110-122 internal/service/connector.go85-96 internal/handler/connector.go52-63
The synchronization process is managed by rag/svr/sync_data_source.py. It runs as a background worker that polls for scheduled tasks. The worker uses an asyncio.Semaphore named task_limiter to control concurrency, defaulting to 5 concurrent tasks rag/svr/sync_data_source.py90
Diagram: Sync Pipeline Data Flow
Sources: rag/svr/sync_data_source.py152-180 api/db/services/connector_service.py94-127 rag/svr/sync_data_source.py90
Every connector must implement or extend the logic found in common/data_source/.
id_column for stable identification common/data_source/rdbms_connector.py34-46 It includes a _sanitize_query method to handle SQL pasted from markdown fences common/data_source/rdbms_connector.py100-120common/data_source/blob_connector.py handle S3-compatible APIs, including R2, GCS, and OCI common/data_source/config.py33-41opendal for abstract storage access, supporting schemes like mysql for metadata and binary storage rag/utils/opendal_conn.py23-43ConnectorService manages the lifecycle of data source connections in the MySQL database.
ConnectorService.schedule_tasks() determines the poll_range_start and creates SYNC or PRUNE tasks api/db/services/connector_service.py94-127cleanup_stale_documents_for_task() removes documents that no longer exist in the source platform by comparing retain_doc_ids against existing document headers api/db/services/connector_service.py149-184ConnectorService.rebuild() allows for a complete re-indexing by deleting all documents associated with a connector and scheduling a fresh sync api/db/services/connector_service.py134-147RAGFlow handles complex OAuth2 flows for services like Google Drive, Gmail, Box, and Confluence.
_renew_credentials which checks if tokens are halfway to expiration and refreshes them via Atlassian's OAuth2 endpoints common/data_source/confluence_connector.py142-191StartGoogleWebOAuth and StartBoxWebOAuth internal/service/connector.go118-127 internal/service/connector.go188-198 It uses Redis for temporary flow state storage with a TTL of 15 minutes internal/service/connector.go49_redact_mailbox masks sensitive UPNs and email addresses in logs rag/svr/sync_data_source.py93-107 _redact_sensitive_url_params ensures credentials aren't leaked during HTTP logging common/http_client.py57-85The frontend uses a DataSourceKey enum to manage configuration for 30+ sources web/src/pages/user-setting/data-source/constant/index.tsx18-54
DataSourceFeatureVisibilityMap determines which sources support advanced features like syncDeletedFiles web/src/pages/user-setting/data-source/constant/index.tsx62-167generateDataSourceInfo function provides UI metadata including Lucide icons and SVG icons for each source web/src/pages/user-setting/data-source/constant/index.tsx180-240Connectors are governed by several environment variables and constants in common/data_source/config.py:
INDEX_BATCH_SIZE: Number of documents processed in one batch (Default: 2) common/data_source/config.py121REQUEST_TIMEOUT_SECONDS: Global timeout for external API requests (Default: 60s) common/data_source/config.py18CONTINUE_ON_CONNECTOR_FAILURE: If true, a single failed document won't stop the entire sync task common/data_source/config.py153CONFLUENCE_TIMEZONE_OFFSET: Adjusts timestamp comparisons for Confluence sync common/data_source/config.py183Sources: rag/svr/sync_data_source.py api/db/services/connector_service.py common/data_source/config.py common/constants.py web/src/pages/user-setting/data-source/constant/index.tsx common/data_source/rdbms_connector.py common/data_source/confluence_connector.py internal/service/connector.go internal/handler/connector.go rag/utils/opendal_conn.py common/http_client.py
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.