# 用户使用流程图 — AI助手 ```mermaid flowchart TD %% ============ 颜色定义 ============ classDef actor fill:#e1f5fe,stroke:#0288d1,stroke-width:2px classDef action fill:#fff3e0,stroke:#f57c00,stroke-width:1px classDef system fill:#e8f5e9,stroke:#388e3c,stroke-width:1px classDef decision fill:#fce4ec,stroke:#d32f2f,stroke-width:1px classDef role fill:#f3e5f5,stroke:#7b1fa2,stroke-width:1px classDef endpoint fill:#f5f5f5,stroke:#616161,stroke-width:1px,shape:box subgraph AI聊天 A1(("用户")) --> A2[发送聊天消息 /chat/send] A2 --> A3{消息类型} A3 -->|普通咨询| A4[Dify AI 响应] A3 -->|报告解读| A5[传入reportId] A5 --> A6[AI解读健康报告指标] A4 --> A7[返回AI回答] A6 --> A7 end subgraph 会话管理 A7 --> B1[获取会话列表 /chat/conversations] B1 --> B2[获取消息历史 /chat/messages] B2 --> B3[删除会话 /chat/conversations/{id}/delete] end subgraph AI营养分析 B3 --> C1[发送营养分析 /nutrition/send] C1 --> C2[基于菌群报告] C2 --> C3[AI生成营养建议] end subgraph AI管家 C3 --> D1[创建新会话 /sessions/create] D1 --> D2[更新Dify会话ID /sessions/update-conversation] D2 --> D3[归档会话 /sessions/archive] D3 --> D4[获取会话列表 /sessions/list] D4 --> D5[会话详情 /sessions/detail] D5 --> D6[删除会话 /sessions/delete] end subgraph AI上下文 D6 --> E1[供LangGraph调用的上下文 /api/ai/context] end subgraph AI推荐 E1 --> F1[按标签搜索推荐 /recommend/search] F1 --> F2[获取复购提醒 /recommend/repurchase-reminders] F2 --> F3[标记提醒已点击 /repurchase-reminder/{id}/click] end R1(("👤 用户")):::actor R2(("🤖 Dify AI引擎")):::system A1 -.- R1 A4 -.- R2 ``` ## 端点明细 | 端点 | 说明 | |------|------| | `/api/ai/chat/send` | 发送聊天消息 | | `/api/ai/chat/conversations` | 会话列表 | | `/api/ai/chat/messages` | 消息历史 | | `/api/ai/chat/conversations/{id}/delete` | 删除会话 | | `/api/ai/nutrition/send` | 营养分析消息 | | `/api/ai/butler/sessions/create` | 创建AI管家会话 | | `/api/ai/butler/sessions/update-conversation` | 更新会话ID | | `/api/ai/butler/sessions/archive` | 归档会话 | | `/api/ai/butler/sessions/list` | 会话列表 | | `/api/ai/butler/sessions/detail` | 会话详情 | | `/api/ai/butler/sessions/delete` | 删除会话 | | `/api/ai/context` | AI上下文数据 | | `/api/recommend/search` | 营养标签搜索 | | `/api/recommend/repurchase-reminders` | 复购提醒 | | `/api/recommend/repurchase-reminder/{id}/click` | 标记已点击 | | `/api/feedback/today` | 获取今日AI反馈 | | `/api/feedback/read` | 标记已读 | | `/api/feedback/recent` | 最近反馈列表 |