Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

feat(diagram): add AI architecture components

tianma-if95ff1b36d832
diff --git a/apps/web/src/components/DiagramEditorPane.test.mjs b/apps/web/src/components/DiagramEditorPane.test.mjs
index 73372b25..39e169d2 100644
--- a/apps/web/src/components/DiagramEditorPane.test.mjs
+++ b/apps/web/src/components/DiagramEditorPane.test.mjs
@@ -313,6 +313,7 @@ describe("diagram editor canvas surface", () => {
expect(source).toContain('t("diagram.componentSearch")');
expect(source).toContain('labelKey: "diagram.componentCategoryExperience"');
expect(source).toContain('labelKey: "diagram.componentCategoryServices"');
+ expect(source).toContain('labelKey: "diagram.componentCategoryAi"');
expect(source).toContain('labelKey: "diagram.componentCategoryDatabases"');
expect(source).toContain('labelKey: "diagram.componentCategoryStorage"');
expect(source).toContain('labelKey: "diagram.componentCategoryMiddleware"');
@@ -320,6 +321,10 @@ describe("diagram editor canvas surface", () => {
expect(source).toContain('labelKey: "diagram.componentCategorySecurity"');
expect(source).toContain('labelKey: "diagram.componentCategoryObservability"');
expect(source).toContain('labelKey: "diagram.componentCategoryExternal"');
+ expect(source).toContain('labelKey: "diagram.architectureResources.largeLanguageModel"');
+ expect(source).toContain('labelKey: "diagram.architectureResources.vectorDatabase"');
+ expect(source).toContain('labelKey: "diagram.architectureResources.aiAgent"');
+ expect(source).toContain('labelKey: "diagram.architectureResources.mcpServer"');
expect(source).toContain("<Collapsible key={category.id} defaultOpen>");
expect(source).toContain("category.items.filter");
expect(source).toContain('className="grid grid-cols-7 gap-1 px-1 pb-2"');
diff --git a/apps/web/src/components/DiagramEditorPane.tsx b/apps/web/src/components/DiagramEditorPane.tsx
index d4c0bc6c..91b6045b 100644
--- a/apps/web/src/components/DiagramEditorPane.tsx
+++ b/apps/web/src/components/DiagramEditorPane.tsx
@@ -6,8 +6,12 @@ import * as m from "motion/react-m";
import {
Activity,
AppWindow,
+ ArrowDownUp,
+ Binary,
Blocks,
+ Bot,
Box,
+ BrainCircuit,
BrickWall,
Cable,
Check,
@@ -46,6 +50,7 @@ import {
MonitorSmartphone,
Network,
Pencil,
+ PlugZap,
RadioTower,
RefreshCw,
RotateCcw,
@@ -55,6 +60,7 @@ import {
ShieldCheck,
ShieldEllipsis,
Smartphone,
+ Sparkles,
SquareFunction,
Trash2,
Webhook,
@@ -239,6 +245,23 @@ const ARCHITECTURE_LIBRARY_CATEGORIES: Array<{
{ shape: "service", icon: SquareFunction, labelKey: "diagram.architectureResources.serverless" },
],
},
+ {
+ id: "ai",
+ labelKey: "diagram.componentCategoryAi",
+ tone: "text-fuchsia-600",
+ items: [
+ { shape: "service", icon: BrainCircuit, labelKey: "diagram.architectureResources.largeLanguageModel" },
+ { shape: "service", icon: Sparkles, labelKey: "diagram.architectureResources.multimodalModel" },
+ { shape: "service", icon: Binary, labelKey: "diagram.architectureResources.embeddingModel" },
+ { shape: "service", icon: ArrowDownUp, labelKey: "diagram.architectureResources.reranker" },
+ { shape: "service", icon: Cpu, labelKey: "diagram.architectureResources.modelInference" },
+ { shape: "database", icon: DatabaseZap, labelKey: "diagram.architectureResources.vectorDatabase" },
+ { shape: "service", icon: Workflow, labelKey: "diagram.architectureResources.ragPipeline" },
+ { shape: "service", icon: Bot, labelKey: "diagram.architectureResources.aiAgent" },
+ { shape: "service", icon: Router, labelKey: "diagram.architectureResources.modelGateway" },
+ { shape: "service", icon: PlugZap, labelKey: "diagram.architectureResources.mcpServer" },
+ ],
+ },
{
id: "data",
labelKey: "diagram.componentCategoryDatabases",
diff --git a/packages/shared/src/diagram-architecture-icons.ts b/packages/shared/src/diagram-architecture-icons.ts
index d1aff11c..de381cb7 100644
--- a/packages/shared/src/diagram-architecture-icons.ts
+++ b/packages/shared/src/diagram-architecture-icons.ts
@@ -18,6 +18,16 @@ export const ARCHITECTURE_RESOURCE_ICON_ELEMENTS: Record<ArchitectureResourceIco
container: [{ tagName: "path", attrs: { d: "M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z" } }, { tagName: "path", attrs: { d: "M10 21.9V14L2.1 9.1" } }, { tagName: "path", attrs: { d: "m10 14 11.9-6.9" } }, { tagName: "path", attrs: { d: "M14 19.8v-8.1" } }, { tagName: "path", attrs: { d: "M18 17.5V9.4" } }],
kubernetes: [{ tagName: "path", attrs: { d: "M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2" } }, { tagName: "rect", attrs: { x: "14", y: "2", width: "8", height: "8", rx: "1" } }],
serverless: [{ tagName: "rect", attrs: { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2" } }, { tagName: "path", attrs: { d: "M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3" } }, { tagName: "path", attrs: { d: "M9 11.2h5.7" } }],
+ largeLanguageModel: [{ tagName: "path", attrs: { d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z" } }, { tagName: "path", attrs: { d: "M9 13a4.5 4.5 0 0 0 3-4" } }, { tagName: "path", attrs: { d: "M6.003 5.125A3 3 0 0 0 6.401 6.5" } }, { tagName: "path", attrs: { d: "M3.477 10.896a4 4 0 0 1 .585-.396" } }, { tagName: "path", attrs: { d: "M6 18a4 4 0 0 1-1.967-.516" } }, { tagName: "path", attrs: { d: "M12 13h4" } }, { tagName: "path", attrs: { d: "M12 18h6a2 2 0 0 1 2 2v1" } }, { tagName: "path", attrs: { d: "M12 8h8" } }, { tagName: "path", attrs: { d: "M16 8V5a2 2 0 0 1 2-2" } }, { tagName: "circle", attrs: { cx: "16", cy: "13", r: ".5" } }, { tagName: "circle", attrs: { cx: "18", cy: "3", r: ".5" } }, { tagName: "circle", attrs: { cx: "20", cy: "21", r: ".5" } }, { tagName: "circle", attrs: { cx: "20", cy: "8", r: ".5" } }],
+ multimodalModel: [{ tagName: "path", attrs: { d: "M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z" } }, { tagName: "path", attrs: { d: "M20 2v4" } }, { tagName: "path", attrs: { d: "M22 4h-4" } }, { tagName: "circle", attrs: { cx: "4", cy: "20", r: "2" } }],
+ embeddingModel: [{ tagName: "rect", attrs: { x: "14", y: "14", width: "4", height: "6", rx: "2" } }, { tagName: "rect", attrs: { x: "6", y: "4", width: "4", height: "6", rx: "2" } }, { tagName: "path", attrs: { d: "M6 20h4" } }, { tagName: "path", attrs: { d: "M14 10h4" } }, { tagName: "path", attrs: { d: "M6 14h2v6" } }, { tagName: "path", attrs: { d: "M14 4h2v6" } }],
+ reranker: [{ tagName: "path", attrs: { d: "m3 16 4 4 4-4" } }, { tagName: "path", attrs: { d: "M7 20V4" } }, { tagName: "path", attrs: { d: "m21 8-4-4-4 4" } }, { tagName: "path", attrs: { d: "M17 4v16" } }],
+ modelInference: [{ tagName: "path", attrs: { d: "M12 20v2" } }, { tagName: "path", attrs: { d: "M12 2v2" } }, { tagName: "path", attrs: { d: "M17 20v2" } }, { tagName: "path", attrs: { d: "M17 2v2" } }, { tagName: "path", attrs: { d: "M2 12h2" } }, { tagName: "path", attrs: { d: "M2 17h2" } }, { tagName: "path", attrs: { d: "M2 7h2" } }, { tagName: "path", attrs: { d: "M20 12h2" } }, { tagName: "path", attrs: { d: "M20 17h2" } }, { tagName: "path", attrs: { d: "M20 7h2" } }, { tagName: "path", attrs: { d: "M7 20v2" } }, { tagName: "path", attrs: { d: "M7 2v2" } }, { tagName: "rect", attrs: { x: "4", y: "4", width: "16", height: "16", rx: "2" } }, { tagName: "rect", attrs: { x: "8", y: "8", width: "8", height: "8", rx: "1" } }],
+ vectorDatabase: [{ tagName: "ellipse", attrs: { cx: "12", cy: "5", rx: "9", ry: "3" } }, { tagName: "path", attrs: { d: "M3 5V19A9 3 0 0 0 15 21.84" } }, { tagName: "path", attrs: { d: "M21 5V8" } }, { tagName: "path", attrs: { d: "M21 12L18 17H22L19 22" } }, { tagName: "path", attrs: { d: "M3 12A9 3 0 0 0 14.59 14.87" } }],
+ ragPipeline: [{ tagName: "rect", attrs: { width: "8", height: "8", x: "3", y: "3", rx: "2" } }, { tagName: "path", attrs: { d: "M7 11v4a2 2 0 0 0 2 2h4" } }, { tagName: "rect", attrs: { width: "8", height: "8", x: "13", y: "13", rx: "2" } }],
+ aiAgent: [{ tagName: "path", attrs: { d: "M12 8V4H8" } }, { tagName: "rect", attrs: { width: "16", height: "12", x: "4", y: "8", rx: "2" } }, { tagName: "path", attrs: { d: "M2 14h2" } }, { tagName: "path", attrs: { d: "M20 14h2" } }, { tagName: "path", attrs: { d: "M15 13v2" } }, { tagName: "path", attrs: { d: "M9 13v2" } }],
+ modelGateway: [{ tagName: "rect", attrs: { width: "20", height: "8", x: "2", y: "14", rx: "2" } }, { tagName: "path", attrs: { d: "M6.01 18H6" } }, { tagName: "path", attrs: { d: "M10.01 18H10" } }, { tagName: "path", attrs: { d: "M15 10v4" } }, { tagName: "path", attrs: { d: "M17.84 7.17a4 4 0 0 0-5.66 0" } }, { tagName: "path", attrs: { d: "M20.66 4.34a8 8 0 0 0-11.31 0" } }],
+ mcpServer: [{ tagName: "path", attrs: { d: "M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z" } }, { tagName: "path", attrs: { d: "m2 22 3-3" } }, { tagName: "path", attrs: { d: "M7.5 13.5 10 11" } }, { tagName: "path", attrs: { d: "M10.5 16.5 13 14" } }, { tagName: "path", attrs: { d: "m18 3-4 4h6l-4 4" } }],
relationalDatabase: [{ tagName: "ellipse", attrs: { cx: "12", cy: "5", rx: "9", ry: "3" } }, { tagName: "path", attrs: { d: "M3 5V19A9 3 0 0 0 21 19V5" } }, { tagName: "path", attrs: { d: "M3 12A9 3 0 0 0 21 12" } }],
noSqlDatabase: [{ tagName: "ellipse", attrs: { cx: "12", cy: "5", rx: "9", ry: "3" } }, { tagName: "path", attrs: { d: "M3 5V19A9 3 0 0 0 15 21.84" } }, { tagName: "path", attrs: { d: "M21 5V8" } }, { tagName: "path", attrs: { d: "M21 12L18 17H22L19 22" } }, { tagName: "path", attrs: { d: "M3 12A9 3 0 0 0 14.59 14.87" } }],
cache: [{ tagName: "path", attrs: { d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" } }, { tagName: "path", attrs: { d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" } }, { tagName: "path", attrs: { d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" } }],
@@ -53,4 +63,4 @@ export const ARCHITECTURE_RESOURCE_ICON_ELEMENTS: Record<ArchitectureResourceIco
saas: [{ tagName: "path", attrs: { d: "m10.852 19.772-.383.924" } }, { tagName: "path", attrs: { d: "m13.148 14.228.383-.923" } }, { tagName: "path", attrs: { d: "M13.148 19.772a3 3 0 1 0-2.296-5.544l-.383-.923" } }, { tagName: "path", attrs: { d: "m13.53 20.696-.382-.924a3 3 0 1 1-2.296-5.544" } }, { tagName: "path", attrs: { d: "m14.772 15.852.923-.383" } }, { tagName: "path", attrs: { d: "m14.772 18.148.923.383" } }, { tagName: "path", attrs: { d: "M4.2 15.1a7 7 0 1 1 9.93-9.858A7 7 0 0 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.2" } }, { tagName: "path", attrs: { d: "m9.228 15.852-.923-.383" } }, { tagName: "path", attrs: { d: "m9.228 18.148-.923.383" } }],
externalApi: [{ tagName: "path", attrs: { d: "M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2" } }, { tagName: "path", attrs: { d: "m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06" } }, { tagName: "path", attrs: { d: "m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8" } }],
thirdPartyService: [{ tagName: "path", attrs: { d: "M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z" } }],
-};
\ No newline at end of file
+};
diff --git a/packages/shared/src/diagram.test.mjs b/packages/shared/src/diagram.test.mjs
index a09cf612..e337a87c 100644
--- a/packages/shared/src/diagram.test.mjs
+++ b/packages/shared/src/diagram.test.mjs
@@ -189,6 +189,29 @@ describe("diagram document", () => {
expect(["normal", "manhattan"]).toContain(projected.edges[0].router.name);
});
+ test("round-trips AI architecture resources", () => {
+ const document = createDefaultDiagramDocument("architecture");
+ const resourceIcons = [
+ "largeLanguageModel", "multimodalModel", "embeddingModel", "reranker", "modelInference",
+ "vectorDatabase", "ragPipeline", "aiAgent", "modelGateway", "mcpServer",
+ ];
+ document.nodes = resourceIcons.map((resourceIcon, index) => ({
+ id: `ai-${index}`,
+ label: resourceIcon,
+ x: index * 40,
+ y: index * 24,
+ width: 120,
+ height: 64,
+ shape: resourceIcon === "vectorDatabase" ? "database" : "service",
+ resourceIcon,
+ }));
+ document.edges = [];
+ expect(parseDiagramDocument(serializeDiagramDocument(document))).toEqual(document);
+ const projection = diagramDocumentToX6Cells(document, "light");
+ expect(projection.nodes).toHaveLength(resourceIcons.length);
+ expect(projection.nodes.every((node) => node.markup.some((item) => item.selector === "architectureIcon0"))).toBe(true);
+ });
+
test("rejects malformed and dangling graph data", () => {
expect(parseDiagramDocument("ordinary note")).toBeNull();
const document = createDefaultDiagramDocument("flowchart");
diff --git a/packages/shared/src/diagram.ts b/packages/shared/src/diagram.ts
index 5a23fb91..e6edae88 100644
--- a/packages/shared/src/diagram.ts
+++ b/packages/shared/src/diagram.ts
@@ -90,6 +90,8 @@ export const resolveDiagramStructure = (structure?: DiagramStructure): DiagramSt
export const ARCHITECTURE_RESOURCE_ICONS = [
"client", "webApp", "mobileApp", "website", "apiClient",
"service", "virtualMachine", "container", "kubernetes", "serverless",
+ "largeLanguageModel", "multimodalModel", "embeddingModel", "reranker", "modelInference",
+ "vectorDatabase", "ragPipeline", "aiAgent", "modelGateway", "mcpServer",
"relationalDatabase", "noSqlDatabase", "cache", "dataWarehouse", "searchEngine",
"objectStorage", "fileStorage", "blockStorage", "backup", "cdn",
"messageQueue", "eventBus", "streamProcessing", "webhook", "serviceMesh",
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 7a6ea9ac..1c2b024f 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -309,6 +309,7 @@ export const enUS = {
componentSearch: "Search architecture components",
componentCategoryExperience: "Apps & clients",
componentCategoryServices: "Compute & services",
+ componentCategoryAi: "AI & machine learning",
componentCategoryDatabases: "Databases",
componentCategoryStorage: "Storage & CDN",
componentCategoryMiddleware: "Internet middleware",
@@ -328,6 +329,16 @@ export const enUS = {
container: "Container",
kubernetes: "Kubernetes",
serverless: "Serverless function",
+ largeLanguageModel: "Large language model",
+ multimodalModel: "Multimodal model",
+ embeddingModel: "Embedding model",
+ reranker: "Reranker model",
+ modelInference: "Model inference service",
+ vectorDatabase: "Vector database",
+ ragPipeline: "RAG pipeline",
+ aiAgent: "AI agent",
+ modelGateway: "Model gateway",
+ mcpServer: "MCP server",
relationalDatabase: "Relational database",
noSqlDatabase: "NoSQL database",
cache: "Cache",
diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.ts
index ce3ca24e..efc39902 100644
--- a/packages/shared/src/i18n/ja.ts
+++ b/packages/shared/src/i18n/ja.ts
@@ -309,6 +309,7 @@ export const ja = {
componentSearch: "アーキテクチャコンポーネントを検索",
componentCategoryExperience: "アプリとクライアント",
componentCategoryServices: "コンピューティングとサービス",
+ componentCategoryAi: "AI と機械学習",
componentCategoryDatabases: "データベース",
componentCategoryStorage: "ストレージと CDN",
componentCategoryMiddleware: "インターネットミドルウェア",
@@ -328,6 +329,16 @@ export const ja = {
container: "コンテナ",
kubernetes: "Kubernetes",
serverless: "サーバーレス関数",
+ largeLanguageModel: "大規模言語モデル",
+ multimodalModel: "マルチモーダルモデル",
+ embeddingModel: "埋め込みモデル",
+ reranker: "リランカーモデル",
+ modelInference: "モデル推論サービス",
+ vectorDatabase: "ベクトルデータベース",
+ ragPipeline: "RAG パイプライン",
+ aiAgent: "AI エージェント",
+ modelGateway: "モデルゲートウェイ",
+ mcpServer: "MCP サーバー",
relationalDatabase: "リレーショナルデータベース",
noSqlDatabase: "NoSQL データベース",
cache: "キャッシュ",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index df715421..cc776921 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -309,6 +309,7 @@ export const zhCN = {
componentSearch: "搜索架构组件",
componentCategoryExperience: "应用与客户端",
componentCategoryServices: "计算与服务",
+ componentCategoryAi: "AI 与机器学习",
componentCategoryDatabases: "数据库",
componentCategoryStorage: "存储与 CDN",
componentCategoryMiddleware: "互联网中间件",
@@ -328,6 +329,16 @@ export const zhCN = {
container: "容器",
kubernetes: "Kubernetes",
serverless: "无服务器函数",
+ largeLanguageModel: "大语言模型",
+ multimodalModel: "多模态模型",
+ embeddingModel: "嵌入模型",
+ reranker: "重排序模型",
+ modelInference: "模型推理服务",
+ vectorDatabase: "向量数据库",
+ ragPipeline: "RAG 检索增强生成",
+ aiAgent: "AI 智能体",
+ modelGateway: "模型网关",
+ mcpServer: "MCP 服务器",
relationalDatabase: "关系型数据库",
noSqlDatabase: "NoSQL 数据库",
cache: "缓存",