{
  "schema_version": 1,
  "diagram_type": "architecture",
  "meta": {
    "title": "DeerFlow 2.0 SuperAgent, Supervisor Fan-Out & Docker Sandbox Architecture",
    "quality_profile": "showcase",
    "repository": {
      "url": "https://github.com/bytedance/deer-flow",
      "revision": "72ba661b84452ed3b8271d77749b3f0e036e2809"
    },
    "views": [
      {
        "id": "supervisor-fanout",
        "label": "Supervisor Task Fanout",
        "focus": ["client-ui", "lead-agent", "worker-pool", "docker-sandbox"],
        "note": "Follow prompt routing through LeadAgent supervisor delegating tasks to dynamic subagent pool."
      },
      {
        "id": "sandbox-isolation",
        "label": "Docker Sandbox Isolation",
        "focus": ["worker-pool", "docker-sandbox", "terminal-fs"],
        "note": "Inspect secure execution boundary isolating untrusted Python and bash code in Docker container."
      },
      {
        "id": "persistence-hitl",
        "label": "Durable Checkpointing & HITL Gate",
        "focus": ["lead-agent", "pregel-harness", "postgres-store", "hitl-gate"],
        "note": "Trace state persistence and sensitive action human approval gates."
      }
    ]
  },
  "components": [
    {
      "id": "client-ui",
      "type": "external",
      "label": "DeerFlow Client",
      "sublabel": "Web UI / Chat API",
      "pos": [50, 270],
      "size": [140, 60],
      "tag": "Gateway"
    },
    {
      "id": "lead-agent",
      "type": "backend",
      "label": "Lead Supervisor",
      "sublabel": "Goal Decomposer",
      "pos": [260, 270],
      "size": [140, 60],
      "tag": "LeadAgent",
      "sources": [
        {
          "path": "backend/packages/harness/deerflow/agents/lead_agent/agent.py",
          "line": 40,
          "end_line": 95,
          "label": "LeadAgent Routing"
        }
      ]
    },
    {
      "id": "skill-loader",
      "type": "backend",
      "label": "Skill Loader",
      "sublabel": "SKILL.md Parser",
      "pos": [260, 110],
      "size": [140, 60],
      "tag": "Tool Registry"
    },
    {
      "id": "worker-pool",
      "type": "backend",
      "label": "Worker Subagents",
      "sublabel": "Specialized Agents",
      "pos": [470, 270],
      "size": [150, 60],
      "tag": "SubAgent Pool"
    },
    {
      "id": "pregel-harness",
      "type": "database",
      "label": "Pregel Harness",
      "sublabel": "Channel State",
      "pos": [470, 110],
      "size": [150, 60],
      "tag": "LangGraph Sync"
    },
    {
      "id": "docker-sandbox",
      "type": "cloud",
      "label": "Docker Sandbox",
      "sublabel": "Isolated Container",
      "pos": [690, 270],
      "size": [150, 60],
      "tag": "Linux Sandbox"
    },
    {
      "id": "hitl-gate",
      "type": "security",
      "label": "Human Gate",
      "sublabel": "Action Approval",
      "pos": [470, 430],
      "size": [150, 60],
      "tag": "interrupt_before",
      "sources": [
        {
          "path": "backend/packages/harness/deerflow/agents/human_input.py",
          "line": 20,
          "end_line": 65,
          "label": "HumanApprovalGate"
        }
      ]
    },
    {
      "id": "postgres-store",
      "type": "database",
      "label": "Postgres Checkpointer",
      "sublabel": "Durable Snapshots",
      "pos": [690, 110],
      "size": [150, 60],
      "tag": "PostgresSaver",
      "sources": [
        {
          "path": "backend/packages/harness/deerflow/checkpoint_patches.py",
          "line": 30,
          "end_line": 70,
          "label": "PostgresCheckpointer"
        }
      ]
    },
    {
      "id": "terminal-fs",
      "type": "database",
      "label": "Terminal & VFS",
      "sublabel": "Container Workspace",
      "pos": [910, 270],
      "size": [140, 60],
      "tag": "Safe IO"
    }
  ],
  "boundaries": [
    {
      "kind": "region",
      "label": "DeerFlow Control Plane",
      "wraps": ["lead-agent", "skill-loader", "worker-pool", "pregel-harness", "hitl-gate"]
    },
    {
      "kind": "security-group",
      "label": "Sandbox Isolation Boundary",
      "wraps": ["docker-sandbox", "postgres-store", "terminal-fs"]
    }
  ],
  "connections": [
    {
      "id": "client-to-lead",
      "from": "client-ui",
      "to": "lead-agent",
      "label": "goal",
      "variant": "emphasis"
    },
    {
      "id": "lead-to-skills",
      "from": "lead-agent",
      "to": "skill-loader",
      "label": "load skills",
      "fromSide": "top",
      "toSide": "bottom"
    },
    {
      "id": "lead-to-workers",
      "from": "lead-agent",
      "to": "worker-pool",
      "label": "delegate",
      "variant": "emphasis"
    },
    {
      "id": "workers-to-pregel",
      "from": "worker-pool",
      "to": "pregel-harness",
      "label": "channels",
      "fromSide": "top",
      "toSide": "bottom"
    },
    {
      "id": "pregel-to-postgres",
      "from": "pregel-harness",
      "to": "postgres-store",
      "label": "checkpoints"
    },
    {
      "id": "workers-to-sandbox",
      "from": "worker-pool",
      "to": "docker-sandbox",
      "label": "exec tools",
      "variant": "emphasis"
    },
    {
      "id": "workers-to-hitl",
      "from": "worker-pool",
      "to": "hitl-gate",
      "label": "prompt HITL",
      "fromSide": "bottom",
      "toSide": "top",
      "labelDy": 50
    },
    {
      "id": "sandbox-to-vfs",
      "from": "docker-sandbox",
      "to": "terminal-fs",
      "label": "mount"
    }
  ],
  "cards": [
    {
      "dot": "cyan",
      "title": "Lead Agent Supervisor",
      "items": [
        "Decomposes high-level user goals into structured sub-tasks",
        "Dynamically provisions specialized subagents with filtered toolsets"
      ]
    },
    {
      "dot": "emerald",
      "title": "Docker Sandbox Container",
      "items": [
        "Executes untrusted shell commands and Python scripts in isolated containers",
        "Mounts virtual workspace directories with strict permission controls"
      ]
    },
    {
      "dot": "violet",
      "title": "SKILL.md Declarative Parser",
      "items": [
        "Parses Markdown skill definitions at runtime into structured tool contracts",
        "Enables modular agent capability extension without code redeployments"
      ]
    }
  ]
}
