digraph HZHubArchitectureCN {
    graph [fontname="Noto Sans CJK SC", fontsize=24, bgcolor=white, margin=0, rankdir=TB, splines=ortho, nodesep=0.6, ranksep=1.2];
    node [fontname="Noto Sans CJK SC", shape=box, style="rounded,filled", fontsize=11, margin="0.3,0.2"];
    edge [fontname="Noto Sans CJK SC", fontsize=10, color="#666666"];

    // Title
    labelloc="t";
    label="HZHub 汇智中台 - 系统架构图\n企业级业务中台";

    // Frontend Layer
    subgraph cluster_frontend {
        label="前端接入层";
        style=filled;
        color="#E3F2FD";
        fontcolor="#1565C0";
        fontsize=14;
        labelloc=b;
        labeljust=left;

        admin [label="hzhub-admin\n管理后台\n• 模型管理\n• 知识库配置\n• 智能体编排", fillcolor="#BBDEFB", color="#1976D2"];
        company [label="hzhub-portal-company\n公司门户\n• 企业微信H5\n• 审批流程\n• 销售CRM\n• BI报表", fillcolor="#BBDEFB", color="#1976D2"];
        dealer [label="hzhub-portal-dealer\n经销商门户\n• 企业微信H5\n• 自助开单\n• 进销存\n• AI素材生成", fillcolor="#BBDEFB", color="#1976D2"];
    }

    // Gateway Layer
    subgraph cluster_gateway {
        label="API网关层";
        style=filled;
        color="#FFF3E0";
        fontcolor="#E65100";
        fontsize=14;
        labelloc=b;
        labeljust=left;

        gateway [label="HZHub-Gateway\nAPI网关\n• 统一鉴权\n• 路由转发\n• 限流熔断", fillcolor="#FFE0B2", color="#F57C00", width=4.5];
    }

    // Service Layer
    subgraph cluster_service {
        label="核心服务层";
        style=filled;
        color="#E8F5E9";
        fontcolor="#2E7D32";
        fontsize=14;
        labelloc=b;
        labeljust=left;

        ai [label="hzhub-ai\nAI服务\n• Spring Boot 4.0\n• Spring AI 2.0\n• LangChain4j\n• RAG/知识库\n• 多智能体", fillcolor="#C8E6C9", color="#388E3C"];
        erp [label="hzhub-erp\nERP服务\n• Spring Boot 4.0\n• JDBC/SQL Server\n• 数据适配层\n• 双数据源预留", fillcolor="#C8E6C9", color="#388E3C"];
        n8n [label="n8n\n工作流引擎\n• 流程编排\n• 审批自动化\n• 定时任务\n• Webhook集成", fillcolor="#F8BBD9", color="#C2185B"];
    }

    // Data Layer
    subgraph cluster_data {
        label="数据存储层";
        style=filled;
        color="#F3E5F5";
        fontcolor="#7B1FA2";
        fontsize=14;
        labelloc=b;
        labeljust=left;

        mysql [label="MySQL\n业务数据\n• 用户权限\n• 系统配置", fillcolor="#E1BEE7", color="#7B1FA2"];
        milvus [label="Milvus\n向量数据库\n• 文档向量\n• 语义检索", fillcolor="#E1BEE7", color="#7B1FA2"];
        sqlserver [label="SQL Server 2008 R2\nERP数据库\n• 存储过程\n• 直连访问", fillcolor="#E1BEE7", color="#7B1FA2"];
    }

    // Connections
    admin -> gateway;
    company -> gateway;
    dealer -> gateway;

    gateway -> ai;
    gateway -> erp;
    gateway -> n8n;

    ai -> mysql;
    ai -> milvus;
    erp -> sqlserver;

    // Workflow trigger (dashed)
    ai -> n8n [style=dashed, color="#9E9E9E", label="工作流触发"];

    // Rankings for layout
    {rank=same; admin; company; dealer}
    {rank=same; ai; erp; n8n}
    {rank=same; mysql; milvus; sqlserver}
}
