数字我 Digital Me:全量入库(大文件走 Git LFS)
nginx serve /uploads direct (audio speed) / patch-nginx (push) Failing after 1m34s

This commit is contained in:
2026-10-10 16:24:43 +08:00
commit 0593ff7e62
1893 changed files with 361723 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
# 数字我 / Digital Me — Backend
「有脸、有声音、有知识库的另一个你」的 API。个人 AI 数字分身平台后端。
## Quick start
```bash
cp .env.example .env # 填入 DASHSCOPE_API_KEY;本地 MongoDB 即可
npm install
npm run dev # → http://localhost:3701 (GET /health)
```
需要本机或远程 MongoDB(默认 `mongodb://localhost:27017`,DB `digital_me`)。
## MVP scope(第一阶段:个人 IP 分身)
复刻「你自己」→ 一键生成「你」讲某主题的口播视频 + 可嵌入的「和我分身聊天」。
| 能力 | 接口 |
|---|---|
| 注册 / 登录 | `POST /api/auth/register` · `POST /api/auth/login` · `GET /api/auth/me` |
| 创建你的分身 | `POST /api/twins` `{ displayName, persona?, characterPrompt?, lang? }` |
| 上传照片建形象 | `POST /api/twins/:id/avatar` (multipart `photo`) |
| 录音克隆声音 | `POST /api/twins/:id/voice` (multipart `sample`) |
| 喂知识(转 RAG) | `POST /api/twins/:id/knowledge` (`file` 或 `{ text, title }`) |
| 文字/语音对话 | `POST /api/twins/:id/ask` `{ question, speak?, lang? }` |
| 单独朗读 | `POST /api/twins/:id/speak` `{ text }` |
| **一键口播视频** | `POST /api/twins/:id/talk-video` → `{ jobId }`,轮询 `GET …/talk-video/:jobId` |
| 发布为可分享分身 | `PUT /api/twins/:id/publish` `{ isPublic, slug?, tagline? }` |
| **公开嵌入对话** | `GET /api/embed/:slug` · `POST /api/embed/:slug/ask`(无需登录,不入历史) |
所有 `/api/twins/*` 需 `Authorization: Bearer <token>`,并按 `ownerId` 隔离。
## 两个运行约束
1. AI 功能需 `DASHSCOPE_API_KEY`。
2. **捏脸 / 口播视频需 `PUBLIC_URL` 公网可达**——DashScope 按 URL 回拉素材,
`localhost` 会失败(对话/声音仍可用)。本地开发用内网穿透(如 cloudflared)。
详见 [../PLAN.md](../PLAN.md)(定位、差异化、路线图)与 [CLAUDE.md](./CLAUDE.md)。