Files
AIclinicalresearch/启动指南.md
AI Clinical Dev Team 239c7ea85e feat: Day 21-22 - knowledge base frontend completed, fix CORS and file upload issues
- Complete knowledge base list and detail pages
- Complete document upload component
- Fix CORS config (add PUT/DELETE method support)
- Fix file upload issues (disabled state and beforeUpload return value)
- Add detailed debug logs (cleaned up)
- Create Day 21-22 completion summary document
2025-10-11 15:40:12 +08:00

243 lines
4.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AI临床研究平台 - 快速启动指南
## 📋 前提条件
确保以下服务已启动:
```bash
# 检查Docker服务
docker ps
# 应该看到以下容器:
# - ai_clinical_postgres (PostgreSQL 15)
# - ai_clinical_redis (Redis 7)
```
---
## 🚀 启动后端服务
### 方法1使用启动脚本推荐
**Windows:**
```bash
双击运行backend\启动后端.bat
```
**命令行:**
```bash
cd backend
npm run dev
```
### 方法2手动启动
```bash
# 1. 进入后端目录
cd backend
# 2. 安装依赖(首次运行)
npm install
# 3. 生成Prisma Client首次运行
npm run prisma:generate
# 4. 启动开发服务器
npm run dev
```
---
## ✅ 验证服务
### 1. 检查控制台输出
应该看到以下输出:
```
🔍 正在测试数据库连接...
✅ 数据库连接成功!
📊 数据库版本: PostgreSQL 15.14
============================================================
🚀 AI临床研究平台 - 后端服务器启动成功!
============================================================
📍 服务地址: http://localhost:3001
🔍 健康检查: http://localhost:3001/health
📡 API入口: http://localhost:3001/api/v1
🌍 运行环境: development
============================================================
```
### 2. 访问健康检查端点
**浏览器访问:**
```
http://localhost:3001/health
```
**预期响应:**
```json
{
"status": "ok",
"database": "connected",
"timestamp": "2025-10-10T07:50:03.123Z",
"uptime": 123.456
}
```
### 3. 访问API入口
**浏览器访问:**
```
http://localhost:3001/api/v1
```
**预期响应:**
```json
{
"message": "AI Clinical Research Platform API",
"version": "1.0.0",
"environment": "development"
}
```
### 4. 使用PowerShell测试
```powershell
# 测试健康检查
Invoke-WebRequest -Uri http://localhost:3001/health -UseBasicParsing | Select-Object -ExpandProperty Content
# 测试API入口
Invoke-WebRequest -Uri http://localhost:3001/api/v1 -UseBasicParsing | Select-Object -ExpandProperty Content
```
---
## 🛠️ 故障排查
### 问题1数据库连接失败
**错误信息:**
```
❌ 数据库连接失败,无法启动服务器
```
**解决方案:**
```bash
# 1. 检查PostgreSQL容器是否运行
docker ps | findstr postgres
# 2. 如果没有运行启动Docker服务
cd D:\MyCursor\AIclinicalresearch
docker-compose up -d
# 3. 检查.env文件中的DATABASE_URL是否正确
# DATABASE_URL="postgresql://ai_clinical:clinical123@localhost:5432/ai_clinical?schema=public"
```
### 问题2端口3001已被占用
**错误信息:**
```
Error: listen EADDRINUSE: address already in use :::3001
```
**解决方案:**
```powershell
# 1. 查找占用端口的进程
netstat -ano | findstr :3001
# 2. 结束该进程PID是最后一列的数字
taskkill /PID <进程ID> /F
# 3. 或者修改.env文件中的PORT
# PORT=3002
```
### 问题3Prisma Client未生成
**错误信息:**
```
Error: Cannot find module '@prisma/client'
```
**解决方案:**
```bash
cd backend
npm run prisma:generate
```
### 问题4依赖包缺失
**错误信息:**
```
Error: Cannot find module 'xxx'
```
**解决方案:**
```bash
cd backend
npm install
```
---
## 📚 常用命令
### 数据库管理
```bash
cd backend
# 生成Prisma Client
npm run prisma:generate
# 创建新的迁移
npm run prisma:migrate
# 打开Prisma Studio可视化数据库管理
npm run prisma:studio
```
### 开发命令
```bash
# 启动开发服务器(热重载)
npm run dev
# 构建生产版本
npm run build
# 启动生产服务器
npm start
```
---
## 🎯 下一步
后端服务启动成功后,您可以:
1. **查看数据库**:运行 `npm run prisma:studio`
2. **查看API文档**`docs/01-设计文档/API设计规范.md`
3. **开始开发前端**进入Day 6的前端开发任务
---
## 📞 技术支持
如果遇到其他问题,请:
1. 查看详细文档:`backend/README.md`
2. 查看Day 5总结`docs/05-每日进度/Day05-后端基础架构完成.md`
3. 查看开发里程碑:`docs/04-开发计划/开发里程碑.md`
---
**🎉 祝开发顺利!**