面向校园场景的健康管理 Web 应用,以体重管理为核心模块,覆盖记录、目标、标签、异常检测、可视化全链路。 技术栈:Angular 20 + Node.js/Express/TypeORM + MySQL 8 + Python(数据洞察)。
analytics/):独立的 Python 分析脚本,基于 pandas + SQL 完成:zrd-nb666/
├── campus_health_app/
│ ├── backend/ # Express + TypeORM 后端
│ │ ├── database/ # init.sql / schema.sql / seed.sql
│ │ └── src/
│ │ ├── config/ # 数据库配置
│ │ ├── controllers/ # 路由处理
│ │ ├── services/ # 业务逻辑(统计/目标/标签)
│ │ ├── entities/ # TypeORM 实体
│ │ ├── dto/ # 请求校验
│ │ └── middlewares/ # 鉴权 / 错误 / 日志
│ ├── frontend/campus-health-app/ # Angular 20 前端
│ │ └── src/app/
│ │ ├── modules/ # weight / diet / exercise / dashboard / monitoring / ...
│ │ ├── shared/ # 通用组件(Modal / AI Chat / CalendarGrid)
│ │ └── services/ # HTTP 与 DeepSeek 服务
│ ├── analytics/ # ⭐ Python 数据分析
│ │ └── analyze.py # generate / report 两个子命令
│ └── docs/ # 架构图、ER 图、WBS、部署图(HTML)
└── requirements.txt # Python 依赖
# 启动 MySQL 后
mysql -u root -p < campus_health_app/backend/database/init.sql
mysql -u root -p campus_health < campus_health_app/backend/database/schema.sql
cd campus_health_app/backend
npm install
cp .env.example .env # 填入 DB_PASSWORD
npm run dev # http://localhost:3000/api
cd campus_health_app/frontend/campus-health-app
npm install
npm start # http://localhost:4200
pip install -r requirements.txt
# 让脚本能连上 MySQL
$env:DB_PASSWORD = "你的MySQL密码" # PowerShell
# 生成 180 天合成数据
python campus_health_app/analytics/analyze.py generate
# 跑分析报告(终端表格 + output/weight_trend.png)
python campus_health_app/analytics/analyze.py report
users 1───n weight_records n───n tags
│
├── 1 weight_goals (每用户当前目标)
└── n anomaly_logs (异常事件记录)
完整 ER 图见 docs/diagrams/report-database-er-new.html。
| Method | Path | 说明 |
|---|---|---|
| GET | /api/weight/records |
体重记录列表(按日期/条件/标签筛选 + 分页) |
| POST | /api/weight/records |
新增记录 |
| PUT | /api/weight/records/:id |
更新记录 |
| DELETE | /api/weight/records/:id |
软删除 |
| GET/POST/PUT | /api/weight/goal |
目标管理 |
| GET/POST | /api/weight/tags |
标签 |
| GET | /api/weight/stats |
统计汇总(当前体重、周均变化、目标 ETA) |
MIT