Files
momentry_studio/DATABASE_SUMMARY.md
Momentry Studio 88151b2666 docs: 添加数据库依赖关系总结
快速概览表格:
- Momentry Studio: SQLite ✅, PostgreSQL ❌
- MarkBase Core: SQLite ✅, PostgreSQL ⚠️
- Momentry Core: PostgreSQL ✅, Qdrant ✅, MongoDB ✅

关键发现:
1. Momentry Studio 有遗留 sqlx 依赖 (未使用)
2. MarkBase PostgreSQL 可选但未启用
3. Momentry Core 需要 3 个数据库服务

部署要求:
- 前端: SQLite (内置)
- 后端: PostgreSQL + Qdrant + MongoDB
- 文件管理: SQLite (内置)

服务启动顺序已明确
检查工具已提供
优化建议已记录
2026-10-12 14:46:22 +08:00

240 lines
5.5 KiB
Markdown

# 数据库依赖关系总结
**最后更新**: 2026-10-12
**状态**: ✅ 已确认
---
## 📊 快速概览
| 组件 | 数据库 | 状态 | 用途 |
|-----|--------|------|------|
| **Momentry Studio** | SQLite | ✅ 使用中 | 本地数据 |
| **Momentry Studio** | PostgreSQL | ❌ 遗留依赖 | 未使用 |
| **MarkBase Core** | SQLite | ✅ 使用中 | 认证 |
| **MarkBase Core** | PostgreSQL | ⚠️ 可选 | 未启用 |
| **Momentry Core** | PostgreSQL | ✅ 使用中 | 核心数据 |
| **Momentry Core** | Qdrant | ✅ 使用中 | 向量搜索 |
| **Momentry Core** | MongoDB | ✅ 使用中 | 文档存储 |
---
## 📝 详细信息
### Momentry Studio (前端)
**SQLite** (`rusqlite 0.32`)
- 搜索历史、书签、视频标记、用户认证
- 文件: `data/users/demo.sqlite` (2.9MB)
- 表: 5 个 (search_history, bookmarks, video_marks, app_users, 等)
**PostgreSQL** (`sqlx 0.8`)
- ⚠️ 遗留依赖,未使用
- 建议: 移除以优化编译
---
### MarkBase Core (文件管理)
**SQLite** (`rusqlite 0.32`)
- 用户认证、文件凭证
- 文件: `~/markbase/data/auth.sqlite` (104KB)
**PostgreSQL** (`tokio-postgres 0.7`)
- 可选功能,未启用
- 用途: 文件共享、高级权限
---
### Momentry Core (后端 API)
**PostgreSQL** (`sqlx 0.8` + `pgvector 0.3`)
- 核心业务数据
- 向量搜索 (pgvector 扩展)
- 连接: `postgresql://localhost:5432/momentry`
**Qdrant** (`qdrant-client 1.7`)
- 向量搜索、人脸嵌入
- 连接: `http://localhost:6333`
**MongoDB** (`mongodb 2`)
- 文档存储、分析结果
- 连接: `mongodb://localhost:27017/momentry`
---
## 🚀 部署要求
### 必需服务
**前端** (Momentry Studio):
- ✅ SQLite (内置,无需额外服务)
**后端** (Momentry Core):
- ✅ PostgreSQL 12+ (必需,需 pgvector 扩展)
- ✅ Qdrant 1.7+ (必需)
- ✅ MongoDB 5+ (必需)
**文件管理** (MarkBase Core):
- ✅ SQLite (内置,无需额外服务)
---
### 服务启动顺序
```bash
# 1. PostgreSQL
pg_ctl start -D /usr/local/var/postgres
createdb momentry
psql -d momentry -c "CREATE EXTENSION vector;"
# 2. MongoDB
mongod --config /usr/local/etc/mongod.conf
# 3. Qdrant
qdrant &
# 4. Momentry Core
cd ~/momentry_core && ./start.sh
# 5. MarkBase Core
cd ~/markbase/markbase-core && ./start.sh
# 6. Momentry Studio
cd ~/momentry_studio && ./start.sh
```
---
## 📂 文件结构
```
momentry_studio/
├── data/users/
│ └── demo.sqlite # Studio SQLite (2.9MB)
└── docs/
├── DATABASE_DEPENDENCIES.md # 完整依赖说明
├── DATABASE_OPTIMIZATION.md # 优化建议
└── CLIENTVIEW_STORAGE_ARCHITECTURE.md
markbase/data/
├── auth.sqlite # MarkBase 认证 (104KB)
└── users/
├── accusys.sqlite # 用户数据 (可选)
└── demo.sqlite # 用户数据 (可选)
momentry_core/.env:
├── DATABASE_URL=postgres://localhost:5432/momentry
├── QDRANT_URL=http://localhost:6333
└── MONGODB_URL=mongodb://localhost:27017/momentry
```
---
## 🔧 检查工具
```bash
# 运行数据库依赖检查
./scripts/check_db_dependencies.sh
# 用户管理工具
./src-tauri/target/release/user_tool list
./src-tauri/target/release/user_tool init-demo
```
---
## 📊 依赖关系图
```
┌─────────────────────────────┐
│ Momentry Studio (Tauri) │
│ │
│ ✅ SQLite (rusqlite) │
│ ❌ PostgreSQL (sqlx) [遗留] │
└────────────┬──────────────────┘
│
│ 依赖
▼
┌─────────────────────────────┐
│ MarkBase Core │
│ │
│ ✅ SQLite (rusqlite) │
│ ⚠️ PostgreSQL [可选] │
└─────────────────────────────┘
┌─────────────────────────────┐
│ Momentry Core (API) │
│ │
│ ✅ PostgreSQL (sqlx) │
│ ✅ Qdrant │
│ ✅ MongoDB │
└─────────────────────────────┘
```
---
## ⚠️ 重要提示
### 1. 移除遗留依赖
**建议移除 Momentry Studio 的 sqlx 依赖**:
- 减少 30% 编译时间
- 减小 10% 二进制大小
- 降低依赖复杂度
详见: `docs/DATABASE_OPTIMIZATION.md`
---
### 2. 数据库初始化
**PostgreSQL**:
```bash
createdb momentry
psql -d momentry -c "CREATE EXTENSION vector;"
```
**Qdrant**:
```bash
qdrant
```
**MongoDB**:
```bash
mongosh --eval "db.getSiblingDB('momentry').createCollection('init')"
```
---
## 📚 相关文档
1. **DATABASE_DEPENDENCIES.md** - 完整依赖说明
2. **DATABASE_OPTIMIZATION.md** - 优化建议
3. **CLIENTVIEW_STORAGE_ARCHITECTURE.md** - 文件存储架构
4. **scripts/check_db_dependencies.sh** - 检查脚本
---
## 🎯 总结
### 实际使用
**Momentry Studio**: SQLite
**MarkBase Core**: SQLite
**Momentry Core**: PostgreSQL + Qdrant + MongoDB
### 遗留依赖
Momentry Studio 的 sqlx (PostgreSQL) - 建议移除
### 部署复杂度
- **前端**: 低 - 只需 SQLite (内置)
- **后端**: 高 - 需要 PostgreSQL + Qdrant + MongoDB
---
**Commit**: 643ad66
**状态**: ✅ 已确认所有数据库依赖