Files
book-mcp/db/schema_doc.md
Quentin 9b0910ccb1 Initial commit: book-mcp 教辅处理 MCP server + Arco Vue 管理端
后端 (book_mcp_server.py, 335 行, 15 个 MCP 工具):
- create_book / add_document / mark_html_ready / mark_json_ready / mark_failed
- update_book_status / soft_delete_book / retry_failed
- get_book / list_books / get_document / list_documents / get_document_url
- upload_to_rustfs / health
- 走 JSON-RPC + stateless_http + json_response(前端可直接调)
- launchd 守护 / 6 秒拉起(macOS)
- systemd 守护脚本(Linux/codelab)

存储:
- MongoDB (mongo:8.0 容器) - book/book_document/document_file 三表
- RustFS 对象存储(fs.code-lab.cn/scan/)- book/<id>/docs/<doc_id>/{docx,html,json}
- 幂等设计: zip_sha256 唯一 + (book_id+original_path) 唯一

前端 (Vue 3 + TS + Arco Design):
- 列表页 /book/list - 搜索 + 状态过滤 + 进度
- 详情页 /book/:id - 文档折叠 + 文件下载
- MCP 客户端 src/api/mcp.ts (JSON-RPC over fetch)

部署:
- deploy/install.sh (codelab 一键装 backend + systemd)
- deploy/install-frontend.sh (vite dev / 生产构建)
- docs/deploy.md (运维手册)

测试:
- tests/test_basic.py (sanity 7 项)
- tests/test_e2e.py (完整 e2e: docx→HTML→入库→上传→校验)
2026-10-11 18:03:57 +08:00

77 lines
2.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.

# MongoDB Schema — book-mcp
3 个 collection(无固定 schema,字段约束在 `db/models.py`):
## book(教辅)
| 字段 | 类型 | 索引 |
|---|---|---|
| `_id` | int | PK(自增,counters.book_id)|
| `name` | str | uk_name_version 一部分 |
| `subject` | str \| null | |
| `grade` | str \| null | |
| `version` | str \| null | uk_name_version 一部分 |
| `type` | str \| null | |
| `zip_path` | str | |
| `zip_sha256` | str | **uk_book_zip_sha 唯一** |
| `zip_size` | int | |
| `status` | enum | idx_book_status |
| `total_count` | int | |
| `success_count` | int | |
| `failed_count` | int | |
| `error_msg` | str \| null | |
| `created_at` | datetime | idx_book_created |
| `updated_at` | datetime | |
| `created_by` | str \| null | |
| `is_deleted` | int (0/1) | uk_name_version 一部分 |
## book_document(教辅文档)
| 字段 | 类型 | 索引 |
|---|---|---|
| `_id` | str (16 字符 sha1) | **uk_doc_id 唯一** |
| `book_id` | int | idx_book_order |
| `original_filename` | str | |
| `original_path` | str | |
| `title` | str \| null | |
| `doc_type` | enum | |
| `order_index` | int | idx_book_order |
| `status` | enum | idx_doc_status |
| `error_msg` | str \| null | |
| `created_at` | datetime | |
| `updated_at` | datetime | |
## document_file(文档文件)
| 字段 | 类型 | 索引 |
|---|---|---|
| `_id` | int | PK(自增,counters.file_id)|
| `doc_id` | str | **uk_doc_type 联合唯一** + idx_bucket_key |
| `file_type` | enum | uk_doc_type 联合唯一 |
| `object_key` | str | idx_bucket_key |
| `object_bucket` | str | idx_bucket_key |
| `size` | int | |
| `checksum` | str \| null | |
| `url` | str \| null | |
| `meta` | object \| null | |
| `created_at` | datetime | |
## counters(自增 ID 模拟)
| _id (name) | seq |
|---|---|
| `book_id` | int |
| `file_id` | int |
## 初始化
```bash
# 自动建所有索引(幂等)
/tmp/wordparse_venv/bin/python book_mcp_server.py --init-db
```
输出:
```
✓ MongoDB 已就绪(db: book_mcp, collections: ['book', 'book_document', 'document_file'])
✓ 8 个索引创建完成
```