This document provides a high-level introduction to the Dify platform, covering its purpose, architecture, core components, and deployment options. For detailed technical architecture, see System Architecture Overview. For specific subsystems like the RAG pipeline or workflow engine, see sections 4 and 5 respectively.
Sources: README.md1-200
Dify is an open-source platform for developing LLM (Large Language Model) applications. It combines agentic AI workflows, RAG (Retrieval-Augmented Generation) pipelines, agent capabilities, model management, and observability features into a unified development environment. The platform supports rapid prototyping and production deployment of AI applications through both a visual interface and programmatic APIs.
Key Characteristics:
Sources: README.md63-114 api/pyproject.toml1-10
Dify is available in multiple editions:
| Edition | Description | Deployment |
|---|---|---|
| Dify Cloud | Hosted SaaS offering with 200 free GPT-4 calls in sandbox plan | https://dify.ai |
| Self-Hosted (Community) | Open-source edition for self-deployment | Docker Compose, Kubernetes |
| Enterprise | Additional features including SSO, custom branding, advanced permissions | Self-hosted or managed |
Sources: README.md116-128 docker/.env.example1-50
Architecture Notes:
langgenius/dify-api image runs in three modes controlled by the MODE environment variable:
MODE=api: HTTP API service (Flask/Gunicorn)MODE=worker: Background task processor (Celery)MODE=beat: Scheduled task scheduler (Celery Beat)DB_TYPE configurationVECTOR_STORE setting (Weaviate shown as default)Sources: docker/docker-compose.yaml1-700 docker/docker-compose-template.yaml1-300 docker/nginx/conf.d/default.conf.template1-50
api)The main application server exposing REST APIs for both console (admin) and service (public) endpoints.
Key Components:
DifyApp classMODE=apiAPI Routing:
/console/api/* - Admin console APIs (requires authentication)/api/* - Service APIs for app end-users/v1/* - OpenAI-compatible API endpointsSources: api/app.py1-38 api/app_factory.py1-100 docker/nginx/conf.d/default.conf.template7-20
worker)Background task processor using Celery for asynchronous operations.
Task Types:
Configuration:
CELERY_BROKER_URL=redis://:password@redis:6379/1)CELERY_WORKER_AMOUNT (default: 1)CELERY_AUTO_SCALE=trueSources: docker/.env.example371-391 docker/docker-compose-template.yaml64-100
worker_beat)Celery Beat scheduler for periodic tasks.
Scheduled Tasks:
Sources: docker/docker-compose-template.yaml102-131 api/schedule/queue_monitor_task.py1-80
web)Next.js 16 + React 19 frontend application.
Key Details:
CONSOLE_API_URL - Backend API URLAPP_API_URL - WebApp API URLSources: web/package.json1-60 docker/docker-compose-template.yaml133-161
sandbox)Isolated code execution environment built in Go.
Features:
SANDBOX_WORKER_TIMEOUT=15)SANDBOX_API_KEY)Sources: docker/docker-compose-template.yaml247-269 api/configs/feature/__init__.py103-192
plugin_daemon)Go-based service for plugin management and execution.
Key Configuration:
langgenius/dify-plugin-daemon:0.5.3-localDB_PLUGIN_DATABASE=dify_plugin)SERVER_KEYSources: docker/docker-compose-template.yaml271-300 docker/.env.example589-608
Options:
PostgreSQL 15 (default): docker/docker-compose-template.yaml163-197
db_postgrespostgres/difyai123456max_connections, shared_buffers, work_memMySQL 8.0: docker/docker-compose-template.yaml199-227
db_mysqlDB_TYPE=mysql configurationORM: SQLAlchemy 2.0 with connection pooling api/pyproject.toml80
Sources: docker/.env.example232-308 docker/docker-compose-template.yaml163-227
Redis 6 - Used for multiple purposes:
Configuration:
REDIS_HOST=redisREDIS_PORT=6379REDIS_PASSWORD=difyai123456Advanced Features:
Sources: docker/.env.example332-391 docker/docker-compose-template.yaml229-245
Dify supports 30+ vector database options via the VECTOR_STORE configuration:
| Type | Configuration Key | Default Port | Use Case |
|---|---|---|---|
| Weaviate | weaviate | 8080 | Default, full-featured |
| Qdrant | qdrant | 6333 | High performance |
| Milvus | milvus | 19530 | Large scale |
| PGVector | pgvector | 5432 | PostgreSQL extension |
| Chroma | chroma | 8000 | Local development |
| Elasticsearch | elasticsearch | 9200 | Full-text search |
Vector Store Factory: api/core/rag/datasource/vdb/vector_factory.py38-70 Vector Types Enum: api/core/rag/datasource/vdb/vector_type.py4-37
Sources: docker/.env.example536-708 api/core/rag/datasource/vdb/vector_type.py1-37 api/core/rag/datasource/vdb/vector_factory.py38-150
Dify uses a layered configuration system built on Pydantic Settings:
Configuration Classes:
Validation: Pydantic performs automatic type checking and validation at startup
Sources: api/configs/app_config.py api/configs/feature/__init__.py1-250 docker/.env.example1-200
| Category | Environment Variables | Purpose |
|---|---|---|
| Server | DIFY_PORT, SERVER_WORKER_AMOUNT, GUNICORN_TIMEOUT | API service configuration |
| Database | DB_TYPE, DB_HOST, DB_PORT, DB_DATABASE | Primary database connection |
| Cache | REDIS_HOST, REDIS_PASSWORD, CELERY_BROKER_URL | Redis configuration |
| Storage | STORAGE_TYPE, OPENDAL_SCHEME, S3_*, AZURE_* | File storage backend |
| Vector DB | VECTOR_STORE, WEAVIATE_*, QDRANT_*, etc. | Vector database selection |
| Security | SECRET_KEY, ACCESS_TOKEN_EXPIRE_MINUTES | Authentication & encryption |
| Features | CODE_EXECUTION_ENDPOINT, PLUGIN_DAEMON_URL | Service endpoints |
Sources: docker/.env.example1-700 api/configs/feature/__init__.py1-250
Quick Start:
Files:
Profiles:
postgresql - Use PostgreSQL (default)mysql - Use MySQL insteadcertbot - Enable automatic SSL certificate managementSources: README.md72-83 docker/README.md1-100
Community-contributed Helm Charts available:
Sources: README.md162-171
Terraform Support:
Sources: README.md172-196
| Component | Specification |
|---|---|
| CPU | >= 2 Cores |
| RAM | >= 4 GiB |
| Docker | Docker 20.10+ |
| Docker Compose | v2.0+ |
| Python | 3.11-3.12 (for API) |
| Node.js | >= 24 (for Web) |
Sources: README.md67-70 api/pyproject.toml4 web/package.json25-26
Core Framework:
LLM Integration:
Full dependency list: api/pyproject.toml6-97
Sources: api/pyproject.toml1-100
Core Framework:
State Management:
Full dependency list: web/package.json60-165
Sources: web/package.json1-165
Dify supports multiple storage backends through a unified interface:
Configuration Example (OpenDAL with S3):
Supported Backends:
Sources: docker/.env.example411-535 api/configs/middleware/__init__.py53-100
Dify provides administrative commands via Flask CLI:
Available Commands: api/commands.py58-500
Dataset Management:
Sources: api/commands.py1-700
All resources are scoped to a Tenant (workspace):
tenant_id foreign keyCelery-based async processing for:
Extensibility through plugin daemon:
Sources: docker/docker-compose-template.yaml271-300 api/configs/feature/__init__.py221-275
For deeper technical details:
Sources: README.md1-200 docker/README.md1-150
Refresh this wiki
This wiki was recently refreshed. Please wait 1 day to refresh again.