Files
YG_FT/backend/README.md
2026-07-27 09:12:47 +08:00

76 lines
2.4 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.
# Backend Service
后端工程使用 FastAPI定位为模型微调平台的应用平台服务负责用户中心、多租户、权限隔离、项目、数据集、模型、训练任务、审批、审计和算力平台编排。
## 目录结构
```text
backend/
app/
main.py # FastAPI 应用入口
api/v1/ # 对前端暴露的 接口路由
core/ # 配置、日志、中间件、权限等基础能力
db/ # 数据库连接、迁移集成、事务工具
modules/ # 业务模块
auth/
tenant/
project/
model/
dataset/
data_process/
fine_tune/
eval/
inference/
approval/
audit/
compute_gateway/
file_gateway/
engine_registry/
retention/
system/
schemas/ # Pydantic 入参/出参模型
services/ # 跨模块应用服务
workers/ # 后台任务入口
requirements.txt # 后端第三方依赖
logs/ # 本地开发日志目录,生产环境建议挂载到独立日志盘
```
## 企业治理接口说明
用户中心、租户、项目、审批、资源授权等能力已通过对应模块 `router.py``/modelTF` 下统一暴露。其中:
- 审计接口挂在 `system` 模块:`GET /modelTF/system/audit-logs``/modelTF/system/audit-logs/export`
- 留存策略为租户资源的嵌套接口:`PUT /modelTF/tenants/{id}/retention-policy`,未独立成 `/modelTF/retention-policies` 路由。
- 重置密码:`POST /modelTF/users/{id}/reset-password`(保护账号不可重置,空密码回退默认 `platform123`)。
- 资源授权:`GET/PUT /modelTF/resources/{type}/{id}/acl`
- 服务看板聚合:`GET /modelTF/dashboard/stats`
## 本地启动
```bash
cd backend
python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reload
```
健康检查:
```text
GET /modelTF/health
```
## 日志
日志模块位于 `app/core/logging.py`,使用说明见 `../docs/backend-logging.md`
默认日志文件:
```text
logs/backend-YYYY-MM-DD.log
logs/error-YYYY-MM-DD.log
```
文件日志为 JSON Lines 格式,单个文件不超过 20MB只保存最近 10 天,错误日志按 `ERROR` 级别独立拆分,便于 ELK/日志平台采集。