# henryhenry618/datapilot architecture

> Architecture diagram of the GitHub repository henryhenry618/datapilot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/henryhenry618/datapilot
- Repository: https://github.com/henryhenry618/datapilot

## Overview

DataPilot is a lightweight data-job scheduling platform. Users organize projects, upload scripts, define jobs and schedules, trigger runs, then inspect execution records and logs. The API creates queued execution records; scheduled triggers use the same job-run path. AI diagnosis and MCP agent tools extend the platform, while the static frontend provides its web entry point. The README describes email/DingTalk alerts and Kettle migration as product goals, but sampled implementation does not establish their runtime wiring. Worker-to-API execution details are likewise not shown.

Main entry points: [`api/main.py`](https://github.com/henryhenry618/datapilot/blob/main/api/main.py) (FastAPI App), [`api/routers/jobs.py`](https://github.com/henryhenry618/datapilot/blob/main/api/routers/jobs.py) (Job Management), [`api/database.py`](https://github.com/henryhenry618/datapilot/blob/main/api/database.py) (DB Sessions), [`api/mcp_server.py`](https://github.com/henryhenry618/datapilot/blob/main/api/mcp_server.py) (MCP Tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_management["Project and Job Management"]
  node_projects["Projects<br/>[projects.py]"]
  node_jobs["Job Management<br/>[jobs.py]"]
  node_files["Script Files<br/>[files.py]"]
  node_env["Environment Editor<br/>[env_editor.py]"]
  node_settings["Settings API<br/>[settings_api.py]"]
end

subgraph group_runtime["Scheduling and Execution"]
  node_database["DB Sessions<br/>[database.py]"]
  node_models["Domain Records<br/>[models.py]"]
  node_scheduler["Cron Scheduler<br/>[scheduler.py]"]
  node_executions["Execution History<br/>[executions.py]"]
  node_worker["Script Executor<br/>[executor.py]"]
end

subgraph group_assist["AI and Agent Tools"]
  node_ai_api["AI Analysis API<br/>[ai.py]"]
  node_ai_service["AI Diagnosis<br/>[ai_service.py]"]
  node_ai_provider{{"AI Provider"}}
  node_mcp["MCP Tools<br/>[mcp_server.py]"]
end

subgraph group_interface["User Interface"]
  node_frontend["Web Frontend<br/>[index.html]"]
  node_api["FastAPI App<br/>[main.py]"]
end

node_user(("Operator"))
node_mysql[("MySQL")]
node_agent(("AI Agent"))

node_user -.->|"uses"| node_frontend
node_api -->|"serves static"| node_frontend
node_api -->|"mounts routes"| node_projects
node_api -->|"mounts routes"| node_jobs
node_api -->|"mounts routes"| node_files
node_api -->|"mounts routes"| node_executions
node_api -->|"mounts routes"| node_env
node_api -->|"mounts routes"| node_ai_api
node_api -->|"mounts routes"| node_settings
node_api -->|"mounts routes"| node_mcp
node_database -->|"connects"| node_mysql
node_models -->|"uses base"| node_database
node_projects -->|"queries records"| node_database
node_jobs -->|"queries records"| node_database
node_jobs -->|"adds or removes"| node_scheduler
node_scheduler -->|"triggers run"| node_jobs
node_jobs -->|"creates execution"| node_models
node_executions -->|"queries records"| node_database
node_files -.->|"shares script storage"| node_worker
node_worker -.->|"processes queued runs"| node_executions
node_ai_api -->|"loads execution data"| node_database
node_ai_api -->|"requests diagnosis"| node_ai_service
node_ai_service -->|"sends analysis request"| node_ai_provider
node_settings -.->|"shares AI settings"| node_ai_service
node_agent -->|"calls tools"| node_mcp
node_mcp -->|"requests job operations"| node_jobs
node_mcp -->|"requests execution data"| node_executions
node_mcp -->|"requests analysis"| node_ai_api

click node_frontend "https://github.com/henryhenry618/datapilot/blob/main/frontend/index.html"
click node_api "https://github.com/henryhenry618/datapilot/blob/main/api/main.py"
click node_projects "https://github.com/henryhenry618/datapilot/blob/main/api/routers/projects.py"
click node_jobs "https://github.com/henryhenry618/datapilot/blob/main/api/routers/jobs.py"
click node_files "https://github.com/henryhenry618/datapilot/blob/main/api/routers/files.py"
click node_env "https://github.com/henryhenry618/datapilot/blob/main/api/routers/env_editor.py"
click node_settings "https://github.com/henryhenry618/datapilot/blob/main/api/routers/settings_api.py"
click node_database "https://github.com/henryhenry618/datapilot/blob/main/api/database.py"
click node_models "https://github.com/henryhenry618/datapilot/blob/main/api/models.py"
click node_scheduler "https://github.com/henryhenry618/datapilot/blob/main/api/scheduler.py"
click node_executions "https://github.com/henryhenry618/datapilot/blob/main/api/routers/executions.py"
click node_worker "https://github.com/henryhenry618/datapilot/blob/main/worker/executor.py"
click node_ai_api "https://github.com/henryhenry618/datapilot/blob/main/api/routers/ai.py"
click node_ai_service "https://github.com/henryhenry618/datapilot/blob/main/api/ai_service.py"
click node_mcp "https://github.com/henryhenry618/datapilot/blob/main/api/mcp_server.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_projects,node_jobs,node_files,node_env,node_settings toneBlue
class node_database,node_models,node_scheduler,node_executions,node_worker,node_mysql toneAmber
class node_ai_api,node_ai_service,node_ai_provider,node_mcp toneMint
class node_frontend,node_api toneRose
class node_user,node_agent toneIndigo
```

## Components

### Project and Job Management

- [Projects](https://github.com/henryhenry618/datapilot/blob/main/api/routers/projects.py): `api/routers/projects.py`
- [Job Management](https://github.com/henryhenry618/datapilot/blob/main/api/routers/jobs.py): `api/routers/jobs.py`
- [Script Files](https://github.com/henryhenry618/datapilot/blob/main/api/routers/files.py): `api/routers/files.py`
- [Environment Editor](https://github.com/henryhenry618/datapilot/blob/main/api/routers/env_editor.py): `api/routers/env_editor.py`
- [Settings API](https://github.com/henryhenry618/datapilot/blob/main/api/routers/settings_api.py): `api/routers/settings_api.py`

### Scheduling and Execution

- [DB Sessions](https://github.com/henryhenry618/datapilot/blob/main/api/database.py): `api/database.py`
- [Domain Records](https://github.com/henryhenry618/datapilot/blob/main/api/models.py): `api/models.py`
- [Cron Scheduler](https://github.com/henryhenry618/datapilot/blob/main/api/scheduler.py): `api/scheduler.py`
- [Execution History](https://github.com/henryhenry618/datapilot/blob/main/api/routers/executions.py): `api/routers/executions.py`
- [Script Executor](https://github.com/henryhenry618/datapilot/blob/main/worker/executor.py): `worker/executor.py`

### AI and Agent Tools

- [AI Analysis API](https://github.com/henryhenry618/datapilot/blob/main/api/routers/ai.py): `api/routers/ai.py`
- [AI Diagnosis](https://github.com/henryhenry618/datapilot/blob/main/api/ai_service.py): `api/ai_service.py`
- **AI Provider**
- [MCP Tools](https://github.com/henryhenry618/datapilot/blob/main/api/mcp_server.py): `api/mcp_server.py`

### User Interface

- [Web Frontend](https://github.com/henryhenry618/datapilot/blob/main/frontend/index.html): `frontend/index.html`
- [FastAPI App](https://github.com/henryhenry618/datapilot/blob/main/api/main.py): `api/main.py`

### Other components

- **Operator**
- **MySQL**
- **AI Agent**

## Connections

- Operator → Web Frontend: uses (evidence: `README.md`)
- FastAPI App → Web Frontend: serves static (evidence: `api/main.py`)
- FastAPI App → Projects: mounts routes (evidence: `api/main.py`)
- FastAPI App → Job Management: mounts routes (evidence: `api/main.py`)
- FastAPI App → Script Files: mounts routes (evidence: `api/main.py`)
- FastAPI App → Execution History: mounts routes (evidence: `api/main.py`)
- FastAPI App → Environment Editor: mounts routes (evidence: `api/main.py`)
- FastAPI App → AI Analysis API: mounts routes (evidence: `api/main.py`)
- FastAPI App → Settings API: mounts routes (evidence: `api/main.py`)
- FastAPI App → MCP Tools: mounts routes (evidence: `api/main.py`)
- DB Sessions → MySQL: connects (evidence: `api/database.py`)
- Domain Records → DB Sessions: uses base (evidence: `api/models.py`)
- Projects → DB Sessions: queries records (evidence: `api/routers/projects.py`)
- Job Management → DB Sessions: queries records (evidence: `api/routers/jobs.py`)
- Job Management → Cron Scheduler: adds or removes (evidence: `api/routers/jobs.py`)
- Cron Scheduler → Job Management: triggers run (evidence: `api/routers/jobs.py`)
- Job Management → Domain Records: creates execution (evidence: `api/routers/jobs.py`)
- Execution History → DB Sessions: queries records (evidence: `api/routers/executions.py`)
- Script Files → Script Executor: shares script storage
- Script Executor → Execution History: processes queued runs
- AI Analysis API → DB Sessions: loads execution data (evidence: `api/routers/ai.py`)
- AI Analysis API → AI Diagnosis: requests diagnosis (evidence: `api/routers/ai.py`)
- AI Diagnosis → AI Provider: sends analysis request (evidence: `api/ai_service.py`)
- Settings API → AI Diagnosis: shares AI settings
- AI Agent → MCP Tools: calls tools (evidence: `api/mcp_server.py`)
- MCP Tools → Job Management: requests job operations (evidence: `api/mcp_server.py`)
- MCP Tools → Execution History: requests execution data (evidence: `api/mcp_server.py`)
- MCP Tools → AI Analysis API: requests analysis (evidence: `api/mcp_server.py`)
