Connector Architecture#
RAGFlow's Connector system provides scheduled, automated ingestion of external data sources — such as S3, Google Drive, Notion, Slack, and 30+ others — into knowledge bases. Connectors run on a configurable polling cadence, track sync state across runs, and tag every ingested document with a source_type so the system can distinguish connector-managed documents from manually uploaded files.
Core Data Models#
Three database models form the backbone of the system (all defined in api/db/db_models.py):
| Model | Table | Purpose |
|---|---|---|
Connector | connector | One record per configured data source. Holds source, config, scheduling frequencies, and status. |
Connector2Kb | connector2kb | Many-to-many join between connectors and knowledge bases. Carries the auto_parse flag per KB link. |
SyncLogs | sync_logs | Append-only task log. Each sync or prune run writes a row tracking status, document counts, errors, and the poll time window. |
Key Connector fields :
source— matches a value from theFileSource/DocumentSourceenums (e.g.,"google_drive","s3","notion").input_type— alwaysPOLLfor user-created connectors; possible values arepoll,event,load_state,slim_retrieval.config— source-specific credentials and settings stored as JSON.refresh_freq/prune_freq— polling interval in minutes for sync and prune tasks respectively.status— lifecycle state, values fromTaskStatus:"0"(unstart),"1"(running),"2"(cancel),"3"(done),"5"(schedule).
Supported Data Sources#
The FileSource enum in common/constants.py enumerates all recognized source identifiers. FileSource.LOCAL (empty string "") is reserved for manually uploaded files. Connector sources include:
- Cloud storage: S3, R2, Google Cloud Storage, Azure Blob, OCI Storage, Dropbox, Box, OneDrive
- Collaboration/docs: Google Drive, Notion, Confluence, SharePoint, WebDAV, Seafile
- Messaging: Slack, Teams, Discord, Gmail, Outlook, IMAP
- Dev tools: GitHub, GitLab, Bitbucket, Jira
- Databases: MySQL, PostgreSQL, BigQuery, DingTalk AI Table
- Other SaaS: Airtable, Asana, Zendesk, Salesforce, Moodle, RSS, REST API
OAuth is supported for Google Drive, Gmail, and Box via dedicated endpoints in the connector API .
source_type Field and Document Provenance#
Every Document row carries a source_type field (default: "local"). Every File row carries the same field (default: "").
When a connector indexes a document, source_type is set to the composite string "{connector.source}/{connector.id}" . This two-part format lets the system:
- Filter all documents belonging to a specific connector instance — used in
rebuild()and stale-document cleanup . - Distinguish connector-managed documents from local uploads at query time.
Service Layer#
ConnectorService in api/db/services/connector_service.py is the primary service class. Key methods:
schedule_tasks(connector_id)— enqueues SYNC and optionally PRUNE tasks for each linked KB . Prune is only scheduled whenconfig.sync_deleted_filesis truthy.cancel_tasks(connector_id)— transitions all SCHEDULE/RUNNING tasks for the connector to CANCEL .rebuild(kb_id, connector_id, tenant_id)— clears all sync logs and connector-sourced documents for a KB, then re-schedules a full sync .cleanup_stale_documents_for_task(...)— removes documents no longer present in the upstream source by diffing the retained file list against all documents with the connector'ssource_type.accessible(connector_id, user_id)— tenant-scoped authorization check .
Task types are defined in ConnectorTaskType: SYNC and PRUNE.
REST API#
All connector endpoints live in api/apps/restful_apis/connector_api.py:
| Method | Path | Description |
|---|---|---|
POST | /connectors | Create a connector |
GET | /connectors | List tenant's connectors |
GET | /connectors/<id> | Get connector details |
PATCH | /connectors/<id> | Update config / reschedule / cancel |
DELETE | /connectors/<id> | Delete connector and cancel tasks |
POST | /connectors/<id>/rebuild | Trigger full re-index for a KB |
GET | /connectors/<id>/logs | Paginated sync log history |
POST | /connectors/<id>/test | Validate connector config |
UI Integration#
The dataset settings page exposes connector linking via link-data-source.tsx. Each linked connector is shown as a DataSourceItem with controls to toggle auto_parse, trigger a rebuild, or unlink the connector from the KB . The auto_parse field on Connector2Kb determines whether newly synced documents are automatically sent through the parsing pipeline .