How spring-ai-alibaba/dataagent works
1. Purpose and deployable entry points
DataAgent is an enterprise AI data analyst: conversational NL-to-SQL, optional sandboxed Python analysis, and report/chart generation. The backend is a Java 17+/Spring Boot application rooted at data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/DataAgentApplication.java; its API surface is exposed by controllers such as data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/controller/ChatController.java and data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/controller/GraphController.java.
A separate Nuxt frontend provides the browser UI, entering through data-agent-frontend-nuxt/app/app.vue and route pages including data-agent-frontend-nuxt/app/pages/chat.vue. Container deployment is defined by docker-file/docker-compose.yml, docker-file/Dockerfile-backend, and docker-file/Dockerfile-frontend.
2. API, security, and application boundary
Controllers separate HTTP/WebFlux concerns from domain services for agents, data sources, knowledge, models, prompts, sessions, and graph execution. Responses use API/streaming-oriented value objects, including data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/vo/ChatResponse.java and data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/vo/SessionUpdateEvent.java.
Reactive API-key authentication is configured at data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/config/WebFluxSecurityConfiguration.java, implemented through data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/security/AgentApiKeyReactiveAuthenticationManager.java, and backed by credential lifecycle handling in data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/security/ApiKeyCredentialService.java.
3. Conversational graph orchestration
GraphServiceImpl is the orchestration boundary from chat requests into a stateful Spring AI Alibaba Graph workflow: data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/graph/GraphServiceImpl.java. Streaming and multi-turn state are managed by data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/graph/Context/StreamContext.java and data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/graph/Context/MultiTurnContextManager.java.
The workflow decomposes requests into graph nodes and dispatchers: recognize intent/feasibility, enhance the query, recall schema/evidence, validate semantics, plan and execute, then produce a report. Core node implementations live in data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/workflow/node/PlannerNode.java, data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/workflow/node/SqlGenerateNode.java, and data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/workflow/node/ReportGeneratorNode.java. Human feedback is an explicit control-flow branch via data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/workflow/node/HumanFeedbackNode.java.
4. Data access and NL2SQL execution
Agent-specific datasource configuration and schema metadata drive SQL generation and execution. data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/nl2sql/Nl2SqlServiceImpl.java provides the NL2SQL service boundary; prompt templates are externalized under data-agent-management/src/main/resources/prompts/, including new-sql-generate.txt and planner.txt.
The connector layer abstracts database access, dialect DDL, pools, and result conversion through data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/connector/SqlExecutor.java, data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/connector/accessor/AccessorFactory.java, and data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/connector/pool/DBConnectionPoolFactory.java. Concrete support includes MySQL, PostgreSQL, Oracle, SQL Server, Hive, H2, and Dameng. MySQL is the primary management-store runtime expectation, with schema at data-agent-management/src/main/resources/sql/schema.sql.
5. Knowledge, retrieval, and model runtime
Business knowledge, agent knowledge, semantic models, logical relations, and datasource schema are persisted as domain entities and used as retrieval context. The ingestion lifecycle is centered on data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/knowledge/AgentKnowledgeServiceImpl.java and asynchronous embedding events in data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/event/AgentKnowledgeEventListener.java.
Vector retrieval is abstracted behind data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/vectorstore/AgentVectorStoreServiceImpl.java; configurations indicate Milvus and Elasticsearch alternatives in data-agent-management/src/main/resources/application-milvus.yml and data-agent-management/src/main/resources/application-elasticsearch.yml. Hybrid Elasticsearch retrieval and reciprocal-rank fusion are implemented in data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/hybrid/retrieval/impl/ElasticsearchHybridRetrievalStrategy.java and data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/hybrid/fusion/impl/RrfFusionStrategy.java.
LLM and embedding providers are dynamically registered/configured via data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/aimodelconfig/AiModelRegistry.java and data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/aimodelconfig/DynamicModelFactory.java.
6. Analysis output, integrations, and frontend flow
Workflow plans may execute generated Python after SQL extraction; the isolation boundary is data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/code/sandbox/SaaSandboxPythonCodeExecutorService.java and its task runtime data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/code/sandbox/runtime/SaaSandboxRuntime.java. Docker is materially required for this sandbox path.
The backend can also operate as an MCP tool server through data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/mcp/McpServerService.java, and emits Langfuse-oriented node tracing through data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/langfuse/NodeTracingLifecycleListener.java.
The Nuxt UI calls backend service modules, maintains chat state, and renders streamed workflow progress/results: data-agent-frontend-nuxt/app/services/chat/index.ts, data-agent-frontend-nuxt/app/stores/chat.ts, and data-agent-frontend-nuxt/app/components/chat/ChatWorkflowTimeline.vue. Markdown reports and ECharts rendering are handled at data-agent-frontend-nuxt/app/components/chat/ChatMarkdownReport.vue and data-agent-frontend-nuxt/app/utils/markdown/markdown-plugin-echarts.ts.
Main entry points: PlannerNode.java Planning, SQL & reporting nodes · GraphServiceImpl.java Graph orchestrator · chat.vue Chat page & state · ChatController.java HTTP controllers
Components 22
Nuxt frontend
- Browser UI
data-agent-frontend-nuxt/app/app.vue - Chat page & state · Streams workflow progress and renders reports.
data-agent-frontend-nuxt/app/pages/chat.vue - Chat service
data-agent-frontend-nuxt/app/services/chat/index.ts - Workflow timeline
data-agent-frontend-nuxt/app/components/chat/ChatWorkflowTimeline.vue - Report & charts
data-agent-frontend-nuxt/app/components/chat/ChatMarkdownReport.vue
Backend API & security
- Spring Boot backend
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/DataAgentApplication.java - HTTP controllers · Chat and graph endpoints expose request and streaming APIs.
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/controller/ChatController.java - API-key security
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/config/WebFluxSecurityConfiguration.java - Credential lifecycle
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/security/ApiKeyCredentialService.java
AI workflow
- Graph orchestrator · Starts graph execution for conversational requests.
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/graph/GraphServiceImpl.java - Stream & multi-turn context
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/graph/Context/StreamContext.java - Planning, SQL & reporting nodes · Plans, generates SQL, executes workflow branches, and produces reports.
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/workflow/node/PlannerNode.java - Human feedback branch
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/workflow/node/HumanFeedbackNode.java
Data & AI runtime
- NL2SQL service · Uses schema, retrieval context, and external prompt templates.
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/nl2sql/Nl2SqlServiceImpl.java - SQL connector layer · Creates dialect-aware accessors, pools, and result conversion.
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/connector/SqlExecutor.java - Management store · Persists agents, knowledge, models, relations, and datasource metadata.
data-agent-management/src/main/resources/sql/schema.sql - Knowledge ingestion & retrieval · Embeds knowledge asynchronously and retrieves evidence.
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/knowledge/AgentKnowledgeServiceImpl.java - LLM & embedding runtime
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/aimodelconfig/AiModelRegistry.java
Execution & observability
- Python sandbox · Runs generated analysis code in an isolated task runtime.
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/code/sandbox/SaaSandboxPythonCodeExecutorService.java - MCP tool server
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/mcp/McpServerService.java - Node tracing
data-agent-management/src/main/java/com/alibaba/cloud/ai/dataagent/service/langfuse/NodeTracingLifecycleListener.java - Container deployment · Deploys frontend, backend, and required container runtime.
docker-file/docker-compose.yml
Connections 24
- Browser UI → Chat page & state
- Chat page & state → Chat service: chat requests
- Chat page & state → Workflow timeline: stream progress
- Chat page & state → Report & charts: report results
- Chat service → HTTP controllers: HTTP/streaming API
- Spring Boot backend → HTTP controllers: hosts
- HTTP controllers → API-key security: authenticated by
- API-key security → Credential lifecycle: validates keys
- HTTP controllers → Graph orchestrator: chat and graph requests
- Graph orchestrator → Stream & multi-turn context: maintains state
- Graph orchestrator → Planning, SQL & reporting nodes: dispatches
- Planning, SQL & reporting nodes → Human feedback branch: feedback branch
- Planning, SQL & reporting nodes → NL2SQL service: plans and generates SQL
- Planning, SQL & reporting nodes → Knowledge ingestion & retrieval: retrieves evidence
- Planning, SQL & reporting nodes → LLM & embedding runtime: LLM inference
- Planning, SQL & reporting nodes → Python sandbox: optional Python analysis
- NL2SQL service → SQL connector layer: execute SQL
- SQL connector layer → Management store: agent metadata and schema
- Knowledge ingestion & retrieval → Management store: knowledge metadata
- Graph orchestrator → Node tracing: node lifecycle events
- MCP tool server → Graph orchestrator: tool-driven execution
- Container deployment → Browser UI: deploys
- Container deployment → Spring Boot backend: deploys
- Container deployment → Python sandbox: Docker runtime