Architecture
DB-GPT is organized as a Python monorepo with a ReAct-centered agent runtime. The Web UI sends requests to the application layer, the ReAct Agent executes in an agent runtime loop, and the agent uses tools, skills, databases, and knowledge resources to produce analysis results back to the UI.
Repository layoutâ
DB-GPT/
âââ packages/
â âââ dbgpt-core/ # Core agent, memory, planning, RAG, model abstractions
â âââ dbgpt-app/ # Application server, API routes, scenes, UI asset hosting
â âââ dbgpt-serve/ # Service layer: knowledge, flow, agent resources, app services
â âââ dbgpt-ext/ # Extensions: datasources, storage backends, RAG connectors
â âââ dbgpt-client/ # Python client SDK
â âââ dbgpt-sandbox/ # Sandbox execution runtime for safe code/tool execution
â âââ dbgpt-accelerator/ # Acceleration packages
âââ web/ # Next.js Web UI
âââ skills/ # Built-in skills and reusable workflows
âââ configs/ # TOML configuration files
âââ docs/ # Docusaurus documentation
Package rolesâ
| Package | Role |
|---|---|
dbgpt-core | Core agent framework, ReAct parser/action flow, memory, planning, RAG, model interfaces |
dbgpt-app | FastAPI application server, chat APIs, runtime orchestration, static UI hosting |
dbgpt-serve | Resource services for knowledge, datasource, flow, app, and agent support |
dbgpt-ext | External connectors such as database/storage/RAG integrations |
dbgpt-client | Client SDK for DB-GPT APIs |
dbgpt-sandbox | Isolated execution runtimes for code and tool execution |
skills/ | Packaged domain workflows, scripts, templates, and references |
High-level architectureâ
How it worksâ
- The user interacts with the Web UI or another client.
dbgpt-appreceives the request and routes it to the agent chat API.- The request enters the
agent_runtimeexecution loop. - The ReAct Agent reasons step by step and chooses the next action.
- The agent loads and uses external resources as needed:
- structured databases for SQL analysis
- unstructured knowledge spaces for retrieval
- skills for reusable workflows
- built-in tools for task execution
- sandbox runtimes for safe code execution
- The agent combines observations and produces the final analysis output.
- The result is streamed back to the UI for display.
Agent runtime modelâ
The runtime is the conceptual execution layer that drives the ReAct loop. In the codebase, this is implemented through the agent builder, resource manager, ReAct parser/action flow, and the API streaming handlers that connect to the UI.
Key implementation anchors:
packages/dbgpt-core/src/dbgpt/agent/expand/react_agent.pypackages/dbgpt-core/src/dbgpt/agent/util/react_parser.pypackages/dbgpt-app/src/dbgpt_app/openapi/api_v1/agentic_data_api.pyweb/hooks/use-react-agent-chat.tspackages/dbgpt-sandbox/src/dbgpt_sandbox/sandbox/execution_layer/runtime_factory.py
Resources used by the agentâ
Structured dataâ
Databases and queryable tabular sources are used for SQL-style analysis, schema linking, and report generation.
Unstructured dataâ
Knowledge spaces and document collections provide retrieval support for unstructured content.
Skillsâ
Built-in skills package repeatable workflows into reusable task units. The agent can load and execute them during a session.
Built-in toolsâ
Tools include SQL execution, shell/code execution, HTML rendering, search, and other task-specific operations registered through the resource manager.
Result deliveryâ
The output path is designed to be user-facing:
ReAct Agent â agent_runtime â streamed result â Web UI
This makes the architecture suitable for interactive data analysis, report generation, and tool-assisted reasoning.