This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# A股智投分析平台 - 后端服务
## 技术栈
- Node.js 20.x LTS
- Express 4.x
- TypeScript 5.x
- Prisma ORM
- MySQL 8.0
- Redis 7
- Socket.io (WebSocket)
- Winston (日志)
## 快速开始
### 1. 安装依赖
```bash
cd backend
npm install
```
### 2. 配置环境变量
```bash
cp .env.example .env
# 编辑 .env 文件,配置数据库连接等信息
```
### 3. 数据库迁移
```bash
# 生成 Prisma Client
npx prisma generate
# 执行数据库迁移
npx prisma migrate dev --name init
# 导入种子数据
npx prisma db seed
```
### 4. 启动开发服务器
```bash
npm run dev
```
服务器将在 http://localhost:3000 启动
### 5. 生产部署
```bash
# 构建
npm run build
# 启动
npm start
```
## Docker 部署
### 使用 Docker Compose
```bash
# 启动所有服务
docker-compose up -d
# 查看日志
docker-compose logs -f app
# 停止服务
docker-compose down
```
### 单独构建镜像
```bash
docker build -t aguzhitou-backend .
docker run -p 3000:3000 --env-file .env aguzhitou-backend