This document describes the high-level system architecture of DB-GPT, explaining how the framework's components are organized and how they interact. DB-GPT follows a modular, layered architecture implemented as a monorepo with seven packages.
For detailed information about specific subsystems, see:
DB-GPT implements a four-layer architecture that separates concerns and enables modular development:
Sources: README.md62-81 pyproject.toml31-40
The architecture follows these principles:
| Principle | Implementation |
|---|---|
| Modularity | Seven independent packages with clear boundaries |
| Layering | Strict dependency hierarchy (no circular dependencies) |
| Extensibility | Plugin-based storage, model adapters, and operators |
| Optional Features | Feature-specific dependencies through extras |
| Type Safety | Pydantic models and type hints throughout |
The monorepo structure enables:
uv package managerSources: packages/dbgpt-core/pyproject.toml1-26 packages/dbgpt-app/pyproject.toml1-21
DB-GPT's codebase is organized as a monorepo with seven packages, each serving a distinct purpose:
Sources: pyproject.toml31-40 packages/dbgpt-ext/pyproject.toml12-15 packages/dbgpt-serve/pyproject.toml12-14 packages/dbgpt-client/pyproject.toml12-22 packages/dbgpt-app/pyproject.toml12-20
dbgpt package)The foundation package providing core abstractions and interfaces.
Key Components:
dbgpt.core.awel - AWEL workflow engine (DAG execution, operators, triggers)dbgpt.core.interface.storage - Storage interfaces (StorageInterface, QuerySpec, ResourceIdentifier)dbgpt.agent - Multi-agent framework (agent profiles, memory, tools)dbgpt.rag - RAG framework (knowledge management, retrieval strategies)dbgpt.datasource - Data source abstraction layerdbgpt.model - Model management interfacesOptional Dependencies (selected via extras):
Sources: packages/dbgpt-core/pyproject.toml1-205 packages/dbgpt-core/src/dbgpt/_version.py1
Concrete implementations of storage backends and data sources.
Key Components:
dbgpt_ext.storage.vector_store - Vector database implementations (Milvus, Chroma, Elasticsearch, PGVector, Weaviate, OceanBase)dbgpt_ext.storage.knowledge_graph - Graph database implementations (TuGraph, Neo4j)dbgpt_ext.datasource - Database connectors (MySQL, PostgreSQL, Oracle, ClickHouse, Hive, DuckDB, MSSQL)dbgpt_ext.rag - Document parsers and chunking strategiesOptional Dependencies:
Sources: packages/dbgpt-ext/pyproject.toml1-106 packages/dbgpt-ext/src/dbgpt_ext/_version.py1
Service-layer implementations providing business logic.
Key Services:
Dependencies: dbgpt-ext (provides storage implementations)
Sources: packages/dbgpt-serve/pyproject.toml1-44 packages/dbgpt-serve/src/dbgpt_serve/_version.py1
Python SDK for interacting with DB-GPT services.
Key Components:
Dependencies: dbgpt[client,cli], dbgpt_ext, SQLAlchemy, cloudpickle
Sources: packages/dbgpt-client/pyproject.toml1-47 packages/dbgpt-client/src/dbgpt_client/_version.py1
Top-level application orchestration and integration.
Key Components:
Dependencies: All other packages (dbgpt-acc-auto, dbgpt, dbgpt-ext, dbgpt-serve, dbgpt-client)
Optional Dependencies:
Sources: packages/dbgpt-app/pyproject.toml1-65 packages/dbgpt-app/src/dbgpt_app/_version.py1
Hardware acceleration for model inference.
Sub-packages:
dbgpt-acc-auto - Automatic acceleration selection based on hardwaredbgpt-acc-flash-attn - Flash Attention integrationHardware Support:
Sources: packages/dbgpt-accelerator/dbgpt-acc-auto/pyproject.toml1-150 packages/dbgpt-accelerator/dbgpt-acc-flash-attn/pyproject.toml1-33
Isolated code execution environment for agent tasks.
Sources: pyproject.toml38
The storage layer demonstrates DB-GPT's abstraction pattern:
Key Classes:
| Class | Location | Purpose |
|---|---|---|
StorageInterface[T, D] | dbgpt.core.interface.storage | Generic storage interface with type parameters for domain object (T) and data model (D) |
StorageItemAdapter[T, D] | dbgpt.core.interface.storage | Converts between domain objects and storage models |
QuerySpec | dbgpt.core.interface.storage | Database-agnostic query specification |
SQLAlchemyStorage | dbgpt_ext.storage.metadata.db_storage | SQLAlchemy-based implementation |
DatabaseManager | dbgpt_ext.storage.metadata.db_manager | Session and connection management |
Sources: packages/dbgpt-core/src/dbgpt/storage/metadata/db_storage.py1-136
Configuration is managed through:
tomli (reading TOML files) and tomlkit (writing TOML files)pydantic>=2.6.0)clickSources: packages/dbgpt-core/pyproject.toml14-25
DB-GPT provides multiple extension points for customization:
The framework uses Python extras to provide optional features without bloating the base installation:
Conflict Resolution:
The monorepo uses uv conflict specifications to prevent incompatible extras:
Sources: packages/dbgpt-core/pyproject.toml176-193 packages/dbgpt-accelerator/dbgpt-acc-auto/pyproject.toml110-118
Vector stores, knowledge graphs, and data sources are implemented as plugins in dbgpt-ext:
| Storage Type | Implementations | Installation Extra |
|---|---|---|
| Vector Store | Milvus, Chroma, Elasticsearch, PGVector, Weaviate, OceanBase | storage_milvus, storage_chromadb, etc. |
| Knowledge Graph | TuGraph, Neo4j | graph_rag |
| Data Source | MySQL, PostgreSQL, Oracle, ClickHouse, Hive, DuckDB, MSSQL | datasource_mysql, datasource_postgres, etc. |
Sources: packages/dbgpt-ext/pyproject.toml27-89
Model integrations support both local and proxy (API) deployments:
Local Models:
llama_cpp - LLAMA.cpp for CPU/Metal inferencehf - HuggingFace Transformersvllm - High-throughput inference (Linux only)mlx - Apple Silicon optimized (macOS only)Proxy Models:
proxy_openai - OpenAI API compatibleproxy_ollama - Ollama local serverproxy_zhipuai - Zhipu AI (ChatGLM)proxy_tongyi - Alibaba Tongyiproxy_qianfan - Baidu Qianfanproxy_anthropic - Anthropic ClaudeSources: packages/dbgpt-core/pyproject.toml116-143
DB-GPT uses uv as its package manager for fast, reliable dependency resolution:
Key Features:
uv.lock)Sources: pyproject.toml42-61 uv.lock1-4
All packages use hatchling as the build backend:
This provides:
Sources: packages/dbgpt-core/pyproject.toml167-203 packages/dbgpt-ext/pyproject.toml96-105
All packages maintain synchronized versioning:
Sources: packages/dbgpt-core/src/dbgpt/_version.py1 packages/dbgpt-ext/src/dbgpt_ext/_version.py1 packages/dbgpt-app/src/dbgpt_app/_version.py1 packages/dbgpt-serve/src/dbgpt_serve/_version.py1 packages/dbgpt-client/src/dbgpt_client/_version.py1
DB-GPT's architecture achieves modularity through:
The monorepo structure with uv provides efficient development while maintaining clear boundaries. Each package can be installed independently based on deployment requirements, from lightweight clients to full-featured servers.
For implementation details of specific subsystems, refer to:
Sources: README.md1-363 pyproject.toml1-86 all package pyproject.toml files
Refresh this wiki