Files
MiragenFlow/docs/miragenflow-architecture.json

199 lines
6.9 KiB
JSON

{
"schema_version": 1,
"diagram_type": "architecture",
"meta": {
"title": "MiragenFlow 全平台架构",
"locale": "zh-CN",
"output": "miragenflow-architecture.html",
"quality_profile": "showcase",
"views": [
{
"id": "request-and-auth",
"label": "请求与身份",
"focus": ["user-client", "admin-client", "contracts", "api", "security"],
"note": "从两个前端入口沿共享契约进入 API,并经过会话、权限与 CSRF 校验。"
},
{
"id": "task-execution",
"label": "任务执行",
"focus": ["api", "store", "queue", "worker", "provider", "objects"],
"note": "创建任务时预留余额,随后经 Outbox、队列、租约和供应商重试完成生成。"
},
{
"id": "events-and-persistence",
"label": "事件与持久化",
"focus": ["store", "events", "objects", "side-workers", "user-client", "admin-client"],
"note": "领域状态提交后发布可过滤事件,资产、消息和 WebDAV 由后台作业继续处理。"
}
]
},
"components": [
{
"id": "user-client",
"type": "frontend",
"label": "用户端",
"sublabel": "React · web/",
"tag": "工作台 / 画布 / 资产",
"pos": [30, 150],
"size": [180, 92]
},
{
"id": "admin-client",
"type": "frontend",
"label": "管理台",
"sublabel": "React + Redux · admin/",
"tag": "权限化运营界面",
"pos": [30, 390],
"size": [180, 92]
},
{
"id": "contracts",
"type": "backend",
"label": "共享契约",
"sublabel": "packages/contracts",
"tag": "任务 / 会话 / 事件类型",
"pos": [240, 270],
"size": [180, 92]
},
{
"id": "api",
"type": "backend",
"label": "HTTP API",
"sublabel": "http.ts · /api/v1",
"tag": "用户与管理路由统一分发",
"pos": [465, 266],
"size": [190, 100]
},
{
"id": "security",
"type": "security",
"label": "身份与权限",
"sublabel": "JWT · CSRF · MFA",
"tag": "角色 Scope 与会话族",
"pos": [465, 90],
"size": [190, 92]
},
{
"id": "store",
"type": "database",
"label": "领域状态与账本",
"sublabel": "Store · 持久化",
"tag": "余额 / 任务 / 审计 / 配置",
"pos": [700, 266],
"size": [200, 100]
},
{
"id": "queue",
"type": "messagebus",
"label": "任务队列与 Outbox",
"sublabel": "Memory / Redis · Outbox",
"tag": "优先级 · 租约 · 死信",
"pos": [700, 460],
"size": [200, 92]
},
{
"id": "worker",
"type": "backend",
"label": "任务 Worker",
"sublabel": "租约 · 重试 · 对账",
"tag": "Attempt 与断路器",
"pos": [930, 456],
"size": [180, 100]
},
{
"id": "provider",
"type": "external",
"label": "外部供应商",
"sublabel": "OpenAI 兼容端点",
"tag": "安全出站 · 超时分类",
"pos": [1140, 456],
"size": [180, 100]
},
{
"id": "objects",
"type": "cloud",
"label": "暂存对象与资产",
"sublabel": "staging · objects",
"tag": "生成结果落地",
"pos": [1140, 270],
"size": [180, 92]
},
{
"id": "events",
"type": "messagebus",
"label": "任务事件流",
"sublabel": "WS · 游标回放",
"tag": "去重与公开投影",
"pos": [700, 90],
"size": [200, 92]
},
{
"id": "side-workers",
"type": "backend",
"label": "后台作业",
"sublabel": "消息 · WebDAV · GC",
"tag": "恢复与定时维护",
"pos": [930, 660],
"size": [210, 100]
}
],
"boundaries": [
{
"kind": "region",
"label": "浏览器端",
"wraps": ["user-client", "admin-client"],
"pad": 28
},
{
"kind": "region",
"label": "MiragenFlow 服务端",
"wraps": ["api", "security", "store", "queue", "worker", "events", "side-workers"],
"pad": 34
},
{
"kind": "security-group",
"label": "受保护写路径",
"wraps": ["api", "security", "store", "queue"],
"pad": 18
},
{
"kind": "region",
"label": "外部边界",
"wraps": ["provider", "objects"],
"pad": 28
}
],
"connections": [
{ "id": "user-contracts", "from": "user-client", "to": "contracts", "label": "页面请求与类型", "variant": "emphasis", "labelAt": [210, 256] },
{ "id": "admin-contracts", "from": "admin-client", "to": "contracts", "label": "管理请求与类型", "variant": "emphasis", "labelAt": [210, 376] },
{ "id": "contracts-api", "from": "contracts", "to": "api", "label": "REST /api/v1", "labelAt": [442, 250] },
{ "id": "api-security", "from": "api", "to": "security", "label": "令牌 / CSRF / Scope", "variant": "security", "fromSide": "top", "toSide": "bottom" },
{ "id": "api-store", "from": "api", "to": "store", "label": "事务与领域命令", "labelAt": [678, 400] },
{ "id": "api-queue", "from": "api", "to": "queue", "label": "任务 + Outbox", "variant": "dashed", "fromSide": "bottom", "toSide": "top" },
{ "id": "queue-worker", "from": "queue", "to": "worker", "label": "租约派发", "variant": "emphasis", "labelAt": [915, 590] },
{ "id": "worker-provider", "from": "worker", "to": "provider", "label": "HTTPS 生成 / 重试" , "variant": "emphasis", "labelAt": [1125, 430]},
{ "id": "worker-objects", "from": "worker", "to": "objects", "label": "b64 / URL → 对象", "variant": "dashed", "fromSide": "top", "toSide": "bottom" },
{ "id": "worker-store", "from": "worker", "to": "store", "label": "结算与账本", "fromSide": "top", "toSide": "bottom" },
{ "id": "worker-events", "from": "worker", "to": "events", "label": "追加任务事件", "fromSide": "top", "toSide": "bottom" },
{ "id": "api-events", "from": "api", "to": "events", "label": "WS / 游标回放", "variant": "dashed" },
{ "id": "side-provider", "from": "side-workers", "to": "provider", "label": "WebDAV / 消息外部调用", "variant": "dashed", "fromSide": "right", "toSide": "bottom" }
],
"cards": [
{
"dot": "cyan",
"title": "入口与契约",
"items": ["用户端和管理台共享 TypeScript 合约", "统一 HTTP 分发,写请求带 CSRF 与幂等键", "管理台额外经过角色 Scope 门禁"]
},
{
"dot": "emerald",
"title": "任务主链",
"items": ["创建任务先校验、计价并预留余额", "Outbox → 队列 → Worker 租约保证可恢复", "渠道重试、断路器与消息/WebDAV 作业"]
},
{
"dot": "violet",
"title": "结果与一致性",
"items": ["输出统一落到暂存对象并生成资产", "结算、释放和审计写入同一领域状态", "未知结果对账;WebSocket 游标回放"]
}
]
}