finai/backend/README.md

52 lines
1.2 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.

# 财务大模型智能问答客服系统后端
Python FastAPI 后端首版 MVP生产目标数据库为 PostgreSQL当前 ADP、SMS、文件存储均通过可替换集成层提供 mock 实现。
## 本地启动
```bash
cd code/backend
python -m uvicorn app.main:app --reload --port 8000
```
默认会使用 `sqlite:///./finance_ai.db`。生产环境请复制 `.env.example``.env`,并配置:
```env
DATABASE_URL=postgresql+psycopg://finai:finai@127.0.0.1:5432/finai
JWT_SECRET_KEY=replace-with-secret
```
## 默认账号
启动时自动创建默认系统管理员:
- 手机号:`13800000000`
- Mock 验证码:`123456`
## 已实现接口
- `GET /health`
- `POST /api/auth/sms-code`
- `POST /api/auth/login`
- `GET /api/auth/me`
- `POST /api/auth/logout`
- `GET/POST/PATCH /api/users`
- `GET/POST/PATCH/DELETE /api/documents`
- `POST /api/documents/{id}/retry-parse`
- `GET/POST /api/chat/sessions`
- `GET /api/chat/sessions/{id}/messages`
- `POST /api/chat/stream`
- `POST /api/chat/upload-image`
- `POST /api/chat/messages/{id}/feedback`
- `GET /api/audit-logs`
- `GET /api/stats/overview`
## 测试
```bash
cd code/backend
python -m unittest discover -s tests -p "test_*.py"
```
测试使用临时 SQLite 数据库,不需要 PostgreSQL。