How amp2byte/dify works
Dify is an open-source LLM application development platform. Its main creator workflow is to configure an app or visual workflow, connect models and tools, and run it for end users; RAG adds document ingestion and retrieval, while agents support tool-driven tasks. The map also includes model/provider management, persistence, and operational logging. The README documents product capabilities, but most implementation files were not sampled, so several subsystem boundaries are shown without speculative internal call chains.
Main entry points: apps App runners · rag_pipeline.py RAG pipeline · agent Autonomous agent · datasets Knowledge management
Components 27
App creation
- Creator interface
api/controllers/console/app - Visual workflows
api/core/app/apps/workflow - Prompt IDE
api/core/app/app_config - App configuration
api/models/model.py
Application runtime
- Run interfaces
api/controllers/service_api/app - App runners
api/core/app/apps - Invocation context
api/core/app/entities/app_invoke_entities.py - Model providers
api/controllers/console/workspace/model_providers.py - Tool engine
api/core/tools/tool_engine.py - App response
api/controllers/service_api/app/app.py
RAG and knowledge
- Knowledge management
api/controllers/console/datasets - RAG pipeline
api/services/rag_pipeline/rag_pipeline.py - Document ingestion
api/tasks/rag_pipeline/rag_pipeline_run_task.py - Retrieval service
api/core/rag/datasource/retrieval_service.py - Dataset records
api/models/dataset.py
Platform services
- Database extension
api/extensions/ext_database.py - Database engine
api/models/engine.py - File storage
api/extensions/ext_storage.py - Account records
api/models/account.py - Login and identity
api/libs/login.py - External API helpers
api/libs/external_api.py - Run observability
api/repositories/workflow_app_log_query_repository.py
Agent execution
- Autonomous agent
api/core/agent - Shell configuration
dify-agent/src/dify_agent/layers/shell/configs.py - Sandbox runtime
Other components
- App creator
- End user
Connections 24
- App creator → Creator interface: configures apps
README.md - Creator interface → Visual workflows: builds workflows
README.md - App creator → Prompt IDE: crafts prompts
README.md - Prompt IDE → App configuration: configures apps
README.md - App configuration → App runners: configures runs
api/core/app/apps/pipeline/pipeline_generator.py - End user → Run interfaces: runs apps
README.md - Run interfaces → App runners: invokes apps
- App runners → Invocation context: uses context
api/core/app/apps/pipeline/pipeline_queue_manager.py - App runners → Model providers: calls models
README.md - App runners → Tool engine: uses tools
README.md - App runners → App response: returns results
- Knowledge management → RAG pipeline: configures ingestion
README.md - RAG pipeline → Document ingestion: ingests documents
- Document ingestion → Dataset records: stores documents
api/tasks/rag_pipeline/rag_pipeline_run_task.py - RAG pipeline → Retrieval service: retrieves context
README.md - Retrieval service → Dataset records: searches datasets
api/core/rag/datasource/retrieval_service.py - Database extension → Database engine: initializes
api/extensions/ext_database.py - Knowledge management → File storage: stores files
- Login and identity → Account records: uses identity
- App runners → Run observability: records runs
- App runners → Autonomous agent: runs agent
README.md - Autonomous agent → Shell configuration: uses shell settings
- Shell configuration → Sandbox runtime: configures shell
- Autonomous agent → Tool engine: connects tools
README.md