# zhan-zip/food-time architecture

> Architecture diagram of the GitHub repository zhan-zip/food-time, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zhan-zip/food-time
- Repository: https://github.com/zhan-zip/food-time

## Overview

食光记是面向个人饮食管理的全栈 AI 助手。用户从 Vue 页面进入食物浏览、DIY、饮食记录、营养评估、记账或美食社区等流程；Assistant 提供流式对话与工具调用，结果由 FastAPI 功能路由处理并持久化。图保留了 README 描述的主要产品分支；未采样模块的具体调用细节不作展开，外部 AI 与 MCP 连接按已提供的文档和代码标示。

Main entry points: [`server/src/database.py`](https://github.com/zhan-zip/food-time/blob/master/server/src/database.py) (应用数据库), [`client/src/App.vue`](https://github.com/zhan-zip/food-time/blob/master/client/src/App.vue) (Vue 应用), [`server/src/chat/service.py`](https://github.com/zhan-zip/food-time/blob/master/server/src/chat/service.py) (对话管线与工具), [`client/src/views/DIY.vue`](https://github.com/zhan-zip/food-time/blob/master/client/src/views/DIY.vue) (DIY 厨房)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["用户界面"]
  node_web["Vue 应用<br/>[App.vue]"]
  node_foodui["食物与今日<br/>[TodayEat.vue]"]
  node_diyui["DIY 厨房<br/>[DIY.vue]"]
  node_assistantui["Assistant 页面<br/>[Assistant.vue]"]
  node_personalui["记录与记账<br/>[Expense.vue]"]
  node_communityui["美食广场<br/>[Square.vue]"]
  node_adminui["管理后台<br/>[Admin.vue]"]
end

subgraph group_food["食物与烹饪"]
  node_foodapi["食物库接口<br/>[router.py]"]
  node_diyapi["DIY 食谱接口<br/>[router.py]"]
end

subgraph group_personal["个人饮食管理"]
  node_authapi["认证接口<br/>[router.py]"]
  node_dietapi["饮食与营养<br/>[router.py]"]
  node_expenseapi["账单与 OCR<br/>[router.py]"]
  node_db[("应用数据库<br/>[database.py]")]
end

subgraph group_community["社区与运营"]
  node_communityapi["社区食谱<br/>[router.py]"]
  node_adminapi["管理接口<br/>[router.py]"]
end

subgraph group_assistant["AI 与集成"]
  node_chatapi["对话接口<br/>[router.py]"]
  node_chatservice["对话管线与工具<br/>[service.py]"]
  node_tools["Agent 工具<br/>[tools.py]"]
  node_mcp["MCP Server<br/>[server.py]"]
  node_vector[("食物向量检索<br/>[vector_store.py]")]
end

node_user(("食光记用户"))
node_deepseek{{"DeepSeek"}}
node_qwen{{"Qwen VL"}}
node_externalagent(("外部 AI Agent"))

node_user -->|"使用页面"| node_web
node_web -->|"导航"| node_foodui
node_web -->|"导航"| node_diyui
node_web -->|"导航"| node_assistantui
node_web -->|"导航"| node_personalui
node_web -->|"导航"| node_communityui
node_user -->|"注册登录"| node_authapi
node_foodui -->|"搜索食物"| node_foodapi
node_diyui -->|"取食材"| node_foodapi
node_diyui -->|"建议与保存"| node_diyapi
node_personalui -->|"记录与评估"| node_dietapi
node_personalui -->|"记账与统计"| node_expenseapi
node_communityui -->|"浏览与互动"| node_communityapi
node_adminui -->|"管理数据"| node_adminapi
node_assistantui -->|"发送对话"| node_chatapi
node_chatapi -->|"运行对话"| node_chatservice
node_chatservice -->|"执行工具"| node_tools
node_chatservice -->|"语义检索"| node_vector
node_chatservice -.->|"对话与调用"| node_deepseek
node_expenseapi -.->|"识别账单"| node_qwen
node_externalagent -->|"调用饮食工具"| node_mcp
node_mcp -->|"复用工具"| node_tools
node_authapi -->|"读写用户"| node_db
node_foodapi -->|"读食物"| node_db
node_diyapi -->|"读写食谱"| node_db
node_dietapi -->|"读写记录"| node_db
node_expenseapi -->|"读写账单"| node_db
node_communityapi -->|"读写社区数据"| node_db
node_adminapi -->|"管理数据"| node_db
node_chatservice -->|"读取会话与记忆"| node_db
node_tools -->|"查询饮食数据"| node_db

click node_web "https://github.com/zhan-zip/food-time/blob/master/client/src/App.vue"
click node_foodui "https://github.com/zhan-zip/food-time/blob/master/client/src/views/TodayEat.vue"
click node_diyui "https://github.com/zhan-zip/food-time/blob/master/client/src/views/DIY.vue"
click node_assistantui "https://github.com/zhan-zip/food-time/blob/master/client/src/views/Assistant.vue"
click node_personalui "https://github.com/zhan-zip/food-time/blob/master/client/src/views/Expense.vue"
click node_communityui "https://github.com/zhan-zip/food-time/blob/master/client/src/views/Square.vue"
click node_adminui "https://github.com/zhan-zip/food-time/blob/master/client/src/views/Admin.vue"
click node_authapi "https://github.com/zhan-zip/food-time/blob/master/server/src/auth/router.py"
click node_foodapi "https://github.com/zhan-zip/food-time/blob/master/server/src/food/router.py"
click node_diyapi "https://github.com/zhan-zip/food-time/blob/master/server/src/custom_food/router.py"
click node_dietapi "https://github.com/zhan-zip/food-time/blob/master/server/src/diet/router.py"
click node_expenseapi "https://github.com/zhan-zip/food-time/blob/master/server/src/expense/router.py"
click node_communityapi "https://github.com/zhan-zip/food-time/blob/master/server/src/public_food/router.py"
click node_adminapi "https://github.com/zhan-zip/food-time/blob/master/server/src/admin/router.py"
click node_chatapi "https://github.com/zhan-zip/food-time/blob/master/server/src/chat/router.py"
click node_chatservice "https://github.com/zhan-zip/food-time/blob/master/server/src/chat/service.py"
click node_tools "https://github.com/zhan-zip/food-time/blob/master/server/src/chat/tools.py"
click node_mcp "https://github.com/zhan-zip/food-time/blob/master/server/src/mcp_integration/server.py"
click node_db "https://github.com/zhan-zip/food-time/blob/master/server/src/database.py"
click node_vector "https://github.com/zhan-zip/food-time/blob/master/server/src/services/vector_store.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_foodui,node_diyui,node_assistantui,node_personalui,node_communityui,node_adminui toneBlue
class node_foodapi,node_diyapi toneAmber
class node_authapi,node_dietapi,node_expenseapi,node_db toneMint
class node_communityapi,node_adminapi toneRose
class node_chatapi,node_chatservice,node_tools,node_mcp,node_vector,node_user,node_deepseek,node_qwen,node_externalagent toneIndigo
```

## Components

### 用户界面

- [Vue 应用](https://github.com/zhan-zip/food-time/blob/master/client/src/App.vue): `client/src/App.vue`
- [食物与今日](https://github.com/zhan-zip/food-time/blob/master/client/src/views/TodayEat.vue): `client/src/views/TodayEat.vue`
- [DIY 厨房](https://github.com/zhan-zip/food-time/blob/master/client/src/views/DIY.vue): `client/src/views/DIY.vue`
- [Assistant 页面](https://github.com/zhan-zip/food-time/blob/master/client/src/views/Assistant.vue): `client/src/views/Assistant.vue`
- [记录与记账](https://github.com/zhan-zip/food-time/blob/master/client/src/views/Expense.vue): `client/src/views/Expense.vue`
- [美食广场](https://github.com/zhan-zip/food-time/blob/master/client/src/views/Square.vue): `client/src/views/Square.vue`
- [管理后台](https://github.com/zhan-zip/food-time/blob/master/client/src/views/Admin.vue): `client/src/views/Admin.vue`

### 食物与烹饪

- [食物库接口](https://github.com/zhan-zip/food-time/blob/master/server/src/food/router.py): `server/src/food/router.py`
- [DIY 食谱接口](https://github.com/zhan-zip/food-time/blob/master/server/src/custom_food/router.py): `server/src/custom_food/router.py`

### 个人饮食管理

- [认证接口](https://github.com/zhan-zip/food-time/blob/master/server/src/auth/router.py): `server/src/auth/router.py`
- [饮食与营养](https://github.com/zhan-zip/food-time/blob/master/server/src/diet/router.py): `server/src/diet/router.py`
- [账单与 OCR](https://github.com/zhan-zip/food-time/blob/master/server/src/expense/router.py): `server/src/expense/router.py`
- [应用数据库](https://github.com/zhan-zip/food-time/blob/master/server/src/database.py): `server/src/database.py`

### 社区与运营

- [社区食谱](https://github.com/zhan-zip/food-time/blob/master/server/src/public_food/router.py): `server/src/public_food/router.py`
- [管理接口](https://github.com/zhan-zip/food-time/blob/master/server/src/admin/router.py): `server/src/admin/router.py`

### AI 与集成

- [对话接口](https://github.com/zhan-zip/food-time/blob/master/server/src/chat/router.py): `server/src/chat/router.py`
- [对话管线与工具](https://github.com/zhan-zip/food-time/blob/master/server/src/chat/service.py): `server/src/chat/service.py`
- [Agent 工具](https://github.com/zhan-zip/food-time/blob/master/server/src/chat/tools.py): `server/src/chat/tools.py`
- [MCP Server](https://github.com/zhan-zip/food-time/blob/master/server/src/mcp_integration/server.py): `server/src/mcp_integration/server.py`
- [食物向量检索](https://github.com/zhan-zip/food-time/blob/master/server/src/services/vector_store.py): `server/src/services/vector_store.py`

### Other components

- **食光记用户**
- **DeepSeek**
- **Qwen VL**
- **外部 AI Agent**

## Connections

- 食光记用户 → Vue 应用: 使用页面
- Vue 应用 → 食物与今日: 导航
- Vue 应用 → DIY 厨房: 导航
- Vue 应用 → Assistant 页面: 导航
- Vue 应用 → 记录与记账: 导航
- Vue 应用 → 美食广场: 导航
- 食光记用户 → 认证接口: 注册登录
- 食物与今日 → 食物库接口: 搜索食物
- DIY 厨房 → 食物库接口: 取食材
- DIY 厨房 → DIY 食谱接口: 建议与保存
- 记录与记账 → 饮食与营养: 记录与评估
- 记录与记账 → 账单与 OCR: 记账与统计
- 美食广场 → 社区食谱: 浏览与互动
- 管理后台 → 管理接口: 管理数据
- Assistant 页面 → 对话接口: 发送对话
- 对话接口 → 对话管线与工具: 运行对话
- 对话管线与工具 → Agent 工具: 执行工具
- 对话管线与工具 → 食物向量检索: 语义检索
- 对话管线与工具 → DeepSeek: 对话与调用
- 账单与 OCR → Qwen VL: 识别账单
- 外部 AI Agent → MCP Server: 调用饮食工具
- MCP Server → Agent 工具: 复用工具
- 认证接口 → 应用数据库: 读写用户
- 食物库接口 → 应用数据库: 读食物
- DIY 食谱接口 → 应用数据库: 读写食谱
- 饮食与营养 → 应用数据库: 读写记录
- 账单与 OCR → 应用数据库: 读写账单
- 社区食谱 → 应用数据库: 读写社区数据
- 管理接口 → 应用数据库: 管理数据
- 对话管线与工具 → 应用数据库: 读取会话与记忆
- Agent 工具 → 应用数据库: 查询饮食数据
