vibe-coding-cn/workflow/canvas-dev/prompts/01-架构分析.md

86 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 01-架构分析提示词
> 从现有代码自动生成 Obsidian Canvas 架构白板
## 使用场景
- 接手新项目,快速理解架构
- 为现有项目建立可视化文档
- 准备 Code Review 或技术分享
## 提示词
```markdown
你是一个代码架构分析专家。请分析以下项目结构,生成 Obsidian Canvas 格式的架构白板。
## 输入
项目路径:{PROJECT_PATH}
分析粒度:{GRANULARITY} (file/class/service)
## 输出要求
生成符合 Obsidian Canvas JSON 格式的 .canvas 文件,包含:
1. **节点 (nodes)**
- 每个模块/文件/类作为一个节点
- 节点包含id, type, x, y, width, height, text
- 按功能分区布局API层左侧数据层右侧
2. **连线 (edges)**
- 表示模块间的依赖/调用关系
- 包含id, fromNode, toNode, fromSide, toSide, label
- label 标注关系类型(调用/继承/依赖/数据流)
3. **分组 (groups)**
- 按功能域分组(如:用户模块、支付模块)
- 用颜色区分不同层级
## Canvas JSON 结构示例
```json
{
"nodes": [
{
"id": "node1",
"type": "text",
"x": 0,
"y": 0,
"width": 200,
"height": 100,
"text": "# UserService\n- createUser()\n- getUser()"
}
],
"edges": [
{
"id": "edge1",
"fromNode": "node1",
"toNode": "node2",
"fromSide": "right",
"toSide": "left",
"label": "调用"
}
]
}
```
## 分析步骤
1. 扫描项目目录结构
2. 识别入口文件和核心模块
3. 分析 import/require 语句提取依赖关系
4. 识别数据库操作、API调用、外部服务
5. 按调用层级布局节点位置
6. 生成完整的 .canvas JSON
```
## 使用示例
```
请分析 /home/user/my-project 项目,生成文件级别的架构白板。
重点关注:
- API 路由和处理函数
- 数据库模型和操作
- 外部服务调用
```
## 输出文件
生成的 `.canvas` 文件可直接用 Obsidian 打开查看和编辑。