ai-assistant-flow.md 4.1 KB

用户使用流程图 — AI助手

端口说明: 📱 小程序 | 🖥 管理后台 | 📋 规划师端 | ⚙️ 系统自动

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
    classDef portMiniApp fill:#e3f2fd,stroke:#1565c0,stroke-width:1px,stroke-dasharray:3 2
    classDef portAdmin fill:#fce4ec,stroke:#c62828,stroke-width:1px,stroke-dasharray:3 2
    classDef portGuide fill:#fff8e1,stroke:#f57f17,stroke-width:1px,stroke-dasharray:3 2
    classDef portSystem fill:#f3e5f5,stroke:#6a1b9a,stroke-width:1px,stroke-dasharray:3 2

    subgraph AI聊天
        A1(("👤 用户")):::portMiniApp --> A2[📱 发送聊天消息 /chat/send]:::portMiniApp
        A2 --> A3{📱 消息类型}:::portMiniApp
        A3 -->|普通咨询| A4[⚙️ Dify AI 响应]:::portSystem
        A3 -->|报告解读| A5[📱 传入reportId]:::portMiniApp
        A5 --> A6[⚙️ AI解读健康报告指标]:::portSystem
        A4 --> A7[📱 返回AI回答]:::portMiniApp
        A6 --> A7
    end

    subgraph 会话管理
        A7 --> B1[📱 获取会话列表 /chat/conversations]:::portMiniApp
        B1 --> B2[📱 获取消息历史 /chat/messages]:::portMiniApp
        B2 --> B3[📱 删除会话 /chat/conversations/:id/delete]:::portMiniApp
    end

    subgraph AI营养分析
        B3 --> C1[📱 发送营养分析 /nutrition/send]:::portMiniApp
        C1 --> C2[⚙️ 基于菌群报告]:::portSystem
        C2 --> C3[📱 AI生成营养建议]:::portMiniApp
    end

    subgraph AI管家
        C3 --> D1[📱 创建新会话 /sessions/create]:::portMiniApp
        D1 --> D2[📱 更新Dify会话ID /sessions/update-conversation]:::portMiniApp
        D2 --> D3[📱 归档会话 /sessions/archive]:::portMiniApp
        D3 --> D4[📱 获取会话列表 /sessions/list]:::portMiniApp
        D4 --> D5[📱 会话详情 /sessions/detail]:::portMiniApp
        D5 --> D6[📱 删除会话 /sessions/delete]:::portMiniApp
    end

    subgraph AI上下文
        D6 --> E1[📱 供LangGraph调用的上下文 /api/ai/context]:::portMiniApp
    end

    subgraph AI推荐
        E1 --> F1[📱 按标签搜索推荐 /recommend/search]:::portMiniApp
        F1 --> F2[📱 获取复购提醒 /recommend/repurchase-reminders]:::portMiniApp
        F2 --> F3[📱 标记提醒已点击 /repurchase-reminder/:id/click]:::portMiniApp
    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 最近反馈列表 📱小程序