337 lines
7.1 KiB
Markdown
337 lines
7.1 KiB
Markdown
# 情绪博物馆 (Emotion Museum)
|
|
|
|
一个基于Spring Cloud Alibaba微服务架构的情绪管理和AI对话平台。
|
|
|
|
## 项目概述
|
|
|
|
情绪博物馆是一个创新的情绪健康管理平台,通过AI对话、情绪记录、数据分析等功能,帮助用户更好地理解和管理自己的情绪状态。
|
|
|
|
## 🚀 快速部署
|
|
|
|
### 一键部署(推荐)
|
|
|
|
```bash
|
|
# 克隆项目
|
|
git clone <repository-url>
|
|
cd EmotionMuseum
|
|
|
|
# 执行一键部署到阿里云服务器
|
|
./deploy-final.sh all
|
|
```
|
|
|
|
### 分步部署
|
|
|
|
```bash
|
|
# 1. 构建项目
|
|
./deploy-final.sh build
|
|
|
|
# 2. 配置服务器环境
|
|
./deploy-final.sh env
|
|
|
|
# 3. 部署数据库和中间件
|
|
./deploy-final.sh mysql
|
|
./deploy-final.sh redis
|
|
./deploy-final.sh nacos
|
|
|
|
# 4. 部署应用
|
|
./deploy-final.sh upload
|
|
./deploy-final.sh import-db
|
|
./deploy-final.sh deploy
|
|
|
|
# 5. 配置Web服务器
|
|
./deploy-final.sh nginx
|
|
|
|
# 6. 健康检查
|
|
./deploy-final.sh health
|
|
```
|
|
|
|
### 服务管理
|
|
|
|
```bash
|
|
# 查看服务状态
|
|
./deploy-final.sh status
|
|
|
|
# 启动/停止/重启服务
|
|
./deploy-final.sh start
|
|
./deploy-final.sh stop
|
|
./deploy-final.sh restart
|
|
|
|
# 查看服务日志
|
|
./deploy-final.sh logs gateway
|
|
./deploy-final.sh logs ai
|
|
./deploy-final.sh logs user
|
|
```
|
|
|
|
## 📋 部署后访问地址
|
|
|
|
- **前端应用**: http://47.111.10.27/emotion-museum/
|
|
- **API网关**: http://47.111.10.27:9000
|
|
- **Nacos控制台**: http://47.111.10.27:8848/nacos
|
|
|
|
## 🏗️ 技术架构
|
|
|
|
### 后端技术栈
|
|
- **框架**: Spring Boot 3.0.2 + Spring Cloud Alibaba
|
|
- **数据库**: MySQL 8.0
|
|
- **缓存**: Redis 7.0
|
|
- **注册中心**: Nacos 2.2.0
|
|
- **网关**: Spring Cloud Gateway
|
|
- **ORM**: MyBatis Plus
|
|
- **AI集成**: Spring AI + Coze平台
|
|
|
|
### 前端技术栈
|
|
- **框架**: Vue 3 + Vite
|
|
- **UI组件**: Ant Design Vue
|
|
- **状态管理**: Pinia
|
|
- **路由**: Vue Router
|
|
- **HTTP客户端**: Axios
|
|
|
|
## 📁 项目结构
|
|
|
|
```
|
|
EmotionMuseum/
|
|
├── backend/ # 后端微服务
|
|
│ ├── emotion-common/ # 公共模块
|
|
│ ├── emotion-gateway/ # API网关
|
|
│ ├── emotion-user/ # 用户服务
|
|
│ ├── emotion-ai/ # AI对话服务
|
|
│ ├── emotion-record/ # 情绪记录服务
|
|
│ ├── emotion-growth/ # 成长分析服务
|
|
│ ├── emotion-explore/ # 地图探索服务
|
|
│ ├── emotion-reward/ # 奖励系统服务
|
|
│ └── emotion-stats/ # 统计分析服务
|
|
├── web/ # 前端应用
|
|
├── deploy-final.sh # 一键部署脚本
|
|
├── docker-compose.prod.yml # 生产环境Docker配置
|
|
├── .env.prod # 生产环境配置
|
|
├── DEPLOYMENT.md # 详细部署指南
|
|
└── README.md # 项目说明
|
|
```
|
|
|
|
## 🛠️ 本地开发
|
|
|
|
### 环境要求
|
|
- Java 17+
|
|
- Maven 3.6+
|
|
- Node.js 18+
|
|
- MySQL 8.0+
|
|
- Redis 7.0+
|
|
|
|
### 开发环境启动
|
|
|
|
1. **克隆项目**
|
|
```bash
|
|
git clone <repository-url>
|
|
cd EmotionMuseum
|
|
```
|
|
|
|
2. **启动基础服务**
|
|
```bash
|
|
# 使用Docker Compose启动MySQL、Redis、Nacos
|
|
docker-compose up -d
|
|
```
|
|
|
|
3. **导入数据库**
|
|
```bash
|
|
# 导入数据库结构和初始数据
|
|
mysql -u root -p < backend/mysql_emotion_museum_final.sql
|
|
```
|
|
|
|
4. **构建并启动后端服务**
|
|
```bash
|
|
cd backend
|
|
mvn clean package -DskipTests
|
|
|
|
# 启动网关
|
|
java -jar emotion-gateway/target/emotion-gateway-1.0.0.jar
|
|
|
|
# 启动用户服务
|
|
java -jar emotion-user/target/emotion-user-1.0.0.jar
|
|
|
|
# 启动AI服务
|
|
java -jar emotion-ai/target/emotion-ai-1.0.0.jar
|
|
```
|
|
|
|
5. **启动前端应用**
|
|
```bash
|
|
cd web
|
|
npm install
|
|
npm run dev
|
|
```
|
|
|
|
## 🔧 配置说明
|
|
|
|
### 生产环境配置
|
|
|
|
主要配置文件:
|
|
- `.env.prod` - 生产环境变量配置
|
|
- `web/.env.production` - 前端生产环境配置
|
|
- `backend/*/src/main/resources/application-prod.yml` - 后端生产配置
|
|
|
|
### 关键配置项
|
|
|
|
```bash
|
|
# 服务器配置
|
|
SERVER_HOST=47.111.10.27
|
|
SERVER_USER=root
|
|
|
|
# 数据库配置
|
|
MYSQL_HOST=localhost
|
|
MYSQL_PORT=3306
|
|
MYSQL_DATABASE=emotion_museum
|
|
MYSQL_USERNAME=emotion
|
|
MYSQL_PASSWORD=EmotionDB2024!
|
|
|
|
# Redis配置
|
|
REDIS_HOST=localhost
|
|
REDIS_PORT=6379
|
|
|
|
# Nacos配置
|
|
NACOS_SERVER_ADDR=localhost:8848
|
|
|
|
# Coze API配置
|
|
COZE_API_TOKEN=your_token_here
|
|
```
|
|
|
|
## 🎯 核心功能
|
|
|
|
### 1. AI智能对话
|
|
- 基于Coze平台的智能对话
|
|
- 情绪识别和分析
|
|
- 个性化建议和指导
|
|
|
|
### 2. 情绪记录
|
|
- 多维度情绪数据记录
|
|
- 情绪变化趋势分析
|
|
- 情绪触发因素识别
|
|
|
|
### 3. 成长分析
|
|
- 个人成长轨迹追踪
|
|
- 情绪健康评估
|
|
- 目标设定和进度跟踪
|
|
|
|
### 4. 地图探索
|
|
- 情绪地图可视化
|
|
- 情绪热点区域分析
|
|
- 社区情绪趋势
|
|
|
|
### 5. 奖励系统
|
|
- 成就系统
|
|
- 积分奖励
|
|
- 等级提升
|
|
|
|
## 📚 API文档
|
|
|
|
### 用户服务 API
|
|
- `POST /api/user/register` - 用户注册
|
|
- `POST /api/user/login` - 用户登录
|
|
- `GET /api/user/profile` - 获取用户信息
|
|
|
|
### AI服务 API
|
|
- `POST /api/ai/chat` - AI对话
|
|
- `GET /api/ai/history` - 对话历史
|
|
- `POST /api/ai/analyze` - 情绪分析
|
|
|
|
### 记录服务 API
|
|
- `POST /api/record/emotion` - 记录情绪
|
|
- `GET /api/record/list` - 获取记录列表
|
|
- `GET /api/record/stats` - 统计数据
|
|
|
|
## 🔍 故障排除
|
|
|
|
### 常见问题
|
|
|
|
1. **服务无法启动**
|
|
```bash
|
|
# 检查服务状态
|
|
./deploy-final.sh status
|
|
|
|
# 查看日志
|
|
./deploy-final.sh logs <service>
|
|
```
|
|
|
|
2. **数据库连接失败**
|
|
```bash
|
|
# 检查MySQL容器状态
|
|
ssh root@47.111.10.27 "docker ps | grep mysql"
|
|
```
|
|
|
|
3. **前端页面无法访问**
|
|
```bash
|
|
# 检查Nginx状态
|
|
ssh root@47.111.10.27 "systemctl status nginx"
|
|
```
|
|
|
|
### 日志位置
|
|
- 应用日志: `/data/logs/emotion-museum/*/app.log`
|
|
- Nginx日志: `/var/log/nginx/`
|
|
- Docker日志: `docker logs <container-name>`
|
|
|
|
## 🔒 安全建议
|
|
|
|
1. **修改默认密码**
|
|
- MySQL root密码
|
|
- 应用数据库密码
|
|
- 服务器SSH密钥
|
|
|
|
2. **配置防火墙**
|
|
```bash
|
|
# 只开放必要端口
|
|
firewall-cmd --permanent --add-port=80/tcp
|
|
firewall-cmd --permanent --add-port=8848/tcp
|
|
firewall-cmd --reload
|
|
```
|
|
|
|
3. **定期备份**
|
|
```bash
|
|
# 数据库备份
|
|
docker exec emotion-mysql-prod mysqldump -uemotion -pEmotionDB2024! emotion_museum > backup.sql
|
|
```
|
|
|
|
## 📈 监控和运维
|
|
|
|
### 健康检查
|
|
```bash
|
|
# 执行完整健康检查
|
|
./deploy-final.sh health
|
|
```
|
|
|
|
### 性能监控
|
|
- Spring Boot Actuator端点
|
|
- JVM性能监控
|
|
- 数据库连接池监控
|
|
- Redis连接监控
|
|
|
|
## 🤝 贡献指南
|
|
|
|
1. Fork 项目
|
|
2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
|
|
3. 提交代码 (`git commit -m 'Add some AmazingFeature'`)
|
|
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
5. 创建 Pull Request
|
|
|
|
### 提交规范
|
|
```
|
|
feat: 新功能
|
|
fix: 修复bug
|
|
docs: 文档更新
|
|
style: 代码格式调整
|
|
refactor: 代码重构
|
|
test: 测试相关
|
|
chore: 构建过程或辅助工具的变动
|
|
```
|
|
|
|
## 📄 许可证
|
|
|
|
本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件
|
|
|
|
## 📞 联系我们
|
|
|
|
- 项目主页: [GitHub Repository]
|
|
- 问题反馈: [Issues]
|
|
- 邮箱: support@emotionmuseum.com
|
|
|
|
---
|
|
|
|
**注意**: 请确保在生产环境中修改默认密码和敏感配置信息。详细部署说明请参考 [DEPLOYMENT.md](DEPLOYMENT.md)。
|