Files
Blizzard c7a02c3905 feat: 初始化 sundynix-agentix 分层式 AI Agent 平台脚手架
5 层 + 1 条 NATS 零拷贝消息总线的 monorepo(Monolith First → Microservices Morph B)。
纵向主干(任务流 + Token 流回流)已真实跑通,横向各层能力为带注释的桩。

已贯通(real code):
- sundynix-shared: 共享契约 + JetStream/core NATS 真实收发(bus) + 内嵌 NATS(devnats) + e2e 测试
- sundynix-gateway: Gin 接入 + DSL 解析组装 + NATS Publish + SSE 流式输出
- sundynix-dispatcher: NATS 消费 + Eino Orchestrator 流式回流 + 熔断器 + LLM Pool 占位流式
- 链路: HTTP POST → DSL → sundynix.tasks.* → Dispatcher → Token 经 sundynix.streams.<id> 回流 → SSE
- 基础设施: docker-compose(nats/postgres/redis/neo4j/milvus) + Makefile(make demo/e2e)

待填(桩):
- Eino 图编排 compose.NewGraph、LLM Pool 接 vLLM/Ollama
- Gateway store 换真实 pgx/redis
- sundynix-mcp-go: Bleve+Milvus+Neo4j 混合检索 / UniOffice / 外部 API
- sundynix-mcp-py: gVisor 沙箱 / MinerU(PaddleOCR) / Docker 解释器
- sundynix-desktop: React Flow 画布 → DSL 导出 → SSE 展示
2026-06-10 11:00:29 +08:00

6.1 KiB
Raw Permalink Blame History

sundynix-agentix · 系统架构图

分层式 AI Agent 平台 — Monolith First → Microservices (Morph B) 演进。 共 5 层 + 1 条 NATS 零拷贝消息总线

下方 Mermaid 图在 GitHub / VS Code(装 Mermaid 插件) / Typora / Obsidian 中可直接渲染。

flowchart TB

%% ===================== 1. CLIENT =====================
subgraph CLIENT["1 · CLIENT LAYER (Edge Interaction)"]
  direction TB
  subgraph DESKTOP["sundynix-desktop (User Device App)"]
    UI["UI Representation Layer<br/>React 19 + TypeScript"]
    SHAD["shadcn/ui + Tailwind CSS<br/>Styles / Components"]
    RF["React Flow Canvas<br/>Agent Orchestration"]
    DSL["JSON DSL export"]
    WIKI["LLM Wiki Management Panel"]
    WAILS["Wails Local Go Runtime"]
    BIND["Strong Binding TS/Go"]
    FS["Local File System I/O"]
    UI --> SHAD --> RF --> DSL
    RF --> WIKI --> WAILS
    WAILS --> BIND
    WAILS --> FS
  end
end

%% ===================== 2. GATEWAY =====================
subgraph GATEWAY["2 · BUSINESS GATEWAY LAYER"]
  direction TB
  subgraph GW["sundynix-gateway (Gin 微服务 · Monolith First)"]
    GIN["Gin 微服务 / 统一接入层"]
    MAINDB[("MainDB<br/>PgSQL: Users, Billing, DSL")]
    CACHE1[("CacheDB<br/>Session / Rate Limit")]
    CACHE2[("CacheDB<br/>Redis: Session, Rate Limit")]
    BILL["商业化与计费模块"]
    GUARD["Harness: Input/Output Guardrail"]
    PARSER["Task DSL Parser & Assembly"]
    GIN --> MAINDB
    GIN --> CACHE1
    GIN --> CACHE2
    GIN --> BILL
    GIN --> GUARD
    GIN --> PARSER
  end
end

%% ===================== 3. NATS =====================
subgraph NATS["3 · MESSAGE BUS — NATS 零拷贝骨干网"]
  direction LR
  QUEUE["NATS Queue<br/>分布式任务队列<br/>sundynix.tasks.*"]
  STREAM["NATS Stream<br/>零拷贝字节管道<br/>sundynix.streams.*"]
end

%% ===================== 4. DISPATCHER =====================
subgraph DISPATCHER["4 · AI AGENT DISPATCHER LAYER"]
  direction TB
  LLMPOOL[("LLM Pool<br/>vLLM / Ollama 集群")]
  subgraph DISP["sundynix-dispatcher (Go / Eino 集群)"]
    EINO["Eino 图编排引擎"]
    NATSGO["nats.go client"]
    EVAL["Harness: LLM 自动化评测"]
    FUSE["Harness: 熔断降级中心"]
    EINO <--> NATSGO
  end
  LLMPOOL <-->|"EinoCore · Eino 回调机制"| EINO
end

%% ===================== 5. MCP TOOLS =====================
subgraph TOOLS["5 · MICROSERVICE MCP TOOLS LAYER (Morph B)"]
  direction TB
  subgraph MCPGO["sundynix-mcp-go (Go 微服务 · I/O 型)"]
    GGW["MCP Protocol Gateway"]
    SEARCH["LLM Wiki 搜索引擎<br/>Hybrid: Bleve · Milvus Go SDK · Neo4j Go Driver"]
    MILVUS[("Milvus · Vector DB")]
    BLEVE["Bleve · Go Search Index"]
    NEO1[("Neo4j · Knowledge Graph")]
    NEO2[("Neo4j · Graph")]
    UNI["UniOffice · Word/Doc Rendering"]
    EXT["External APIs"]
    GGW --> SEARCH --> MILVUS & BLEVE & NEO1 & NEO2
    GGW --> UNI
    GGW --> EXT
  end
  subgraph MCPPY["sundynix-mcp-py (Python 微服务 · 算法型)"]
    PGW["MCP Protocol Gateway"]
    SANDBOX["Harness: Secure Code Sandbox<br/>gVisor / KataVM · Static Code Guard"]
    MINERU["MinerU · Multimodal Parser (PaddleOCR)"]
    DOCKER["Docker 隔离沙箱 · Code Interpreter"]
    PGW --> SANDBOX --> MINERU --> DOCKER
  end
end

%% ===================== 跨层连线 =====================
DESKTOP <==>|"4 · PHYSICAL COMMUNICATION<br/>HTTPS / WebSocket / SSE<br/>sundynix.streams.task_id (Token Stream)"| GIN
PARSER  ==>|"1 · Publish Task DSL"| QUEUE
STREAM  ==>|"4 · Subscribe Stream"| GIN
QUEUE   <==>|"4 · Subscribe Stream"| NATSGO
STREAM  <==> NATSGO
NATS    ==> MCPGO
NATS    ==> MCPPY

%% ===================== 配色 =====================
classDef client     fill:#fdf2e3,stroke:#e0a85a,color:#1c2b3a;
classDef gateway    fill:#dcecf7,stroke:#5fa9d4,color:#1c2b3a;
classDef nats       fill:#e7f4e1,stroke:#86c06a,color:#1c2b3a;
classDef dispatcher fill:#efe5f8,stroke:#a984cf,color:#1c2b3a;
classDef gotools    fill:#d6e7f3,stroke:#5fa9d4,color:#1c2b3a;
classDef pytools    fill:#fbf3cf,stroke:#d8bf52,color:#1c2b3a;

class CLIENT,DESKTOP,UI,SHAD,RF,DSL,WIKI,WAILS,BIND,FS client;
class GATEWAY,GW,GIN,MAINDB,CACHE1,CACHE2,BILL,GUARD,PARSER gateway;
class NATS,QUEUE,STREAM nats;
class DISPATCHER,DISP,LLMPOOL,EINO,NATSGO,EVAL,FUSE dispatcher;
class TOOLS,MCPGO,GGW,SEARCH,MILVUS,BLEVE,NEO1,NEO2,UNI,EXT gotools;
class MCPPY,PGW,SANDBOX,MINERU,DOCKER pytools;

分层说明

组件 技术栈 / 职责 配色
1. Client sundynix-desktop React 19 + TS、shadcn/ui + Tailwind、React Flow 画布(Agent 编排 → 导出 JSON DSL)、LLM Wiki 面板、Wails 本地 Go 运行时、TS/Go 强绑定、本地文件 I/O 🟧
2. Gateway sundynix-gateway Gin 统一接入层;MainDB(PgSQL: Users/Billing/DSL) + CacheDB(Redis: Session/Rate Limit);商业化计费;输入/输出 Guardrail;Task DSL 解析与组装 🟦
3. 消息总线 NATS Server (Go) 零拷贝骨干网:Queue(sundynix.tasks.* 分布式任务队列) + Stream(sundynix.streams.* 零拷贝字节管道) 🟩 绿
4. Dispatcher sundynix-dispatcher Go/Eino 集群:Eino 图编排引擎 + nats.go client,经 EinoCore/回调驱动 LLM Pool(vLLM/Ollama)LLM 自动化评测、熔断降级中心 🟪
5a. MCP Go sundynix-mcp-go Go I/O 型:MCP 协议网关、Wiki 混合检索(Bleve+Milvus+Neo4j)、UniOffice 文档渲染、外部 API 🟦
5b. MCP Py sundynix-mcp-py Python 算法型:MCP 协议网关、安全代码沙箱(gVisor/KataVM)、MinerU 多模态解析(PaddleOCR)、Docker 代码解释器 🟨

核心数据流(图中编号)

  1. Publish Task DSL — Gateway 解析 DSL 后发布任务到 NATS Queue (sundynix.tasks.*)
  2. 订阅与编排 — Dispatcher 经 nats.go 订阅任务,Eino 图编排引擎驱动 LLM Pool 推理
  3. 调用 MCP 工具 — Dispatcher / Gateway 经 NATS 调用第 5 层 Go(I/O 型) + Python(算法型) 工具
  4. Token Stream 回流 — 推理结果以零拷贝流经 sundynix.streams.task_id 回 Gateway → 经 SSE/WebSocket 推送给 Client