Skip to content

Commit 02ab69d

Browse files
committed
Use COS in production and require PGroonga
1 parent 54b6147 commit 02ab69d

13 files changed

Lines changed: 101 additions & 185 deletions

File tree

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ DeepTrans Studio is described in our CSCW '26 Companion Demo (CCF-A) paper. If y
5959
- **Multi-Engine Support**: Integration with OpenAI and custom AI models
6060
- **Terminology Extraction**: Automated domain-specific term extraction
6161
- **Quality Assessment**: AI-driven grammar, syntax, and discourse evaluation
62-
- **Translation Memory**: Vector-based semantic search using PostgreSQL + pgvector
62+
- **Translation Memory**: Vector search with pgvector and CJK keyword search with PGroonga
6363

6464
### 📚 Knowledge Management
6565

6666
- **Project Dictionaries**: Project-specific terminology databases
6767
- **Translation Memory**: Import/export translation memory in TMX, CSV, XLSX formats
68-
- **Semantic Search**: Vector similarity search powered by pgvector
68+
- **Semantic Search**: Vector similarity search powered by pgvector, with PGroonga keyword retrieval
6969

7070
### 🔄 Workflow Automation
7171

@@ -76,7 +76,7 @@ DeepTrans Studio is described in our CSCW '26 Companion Demo (CCF-A) paper. If y
7676

7777
### 🔌 Extensibility
7878

79-
- **Open Architecture**: Modular design with PostgreSQL, MinIO, Valkey integration
79+
- **Open Architecture**: Modular design with PostgreSQL, Valkey, and pluggable object storage
8080
- **API Gateway**: RESTful APIs for external integration
8181
- **Custom Agents**: Extensible AI agent framework
8282
- **Plugin System**: Support for custom translation engines and processing pipelines
@@ -95,20 +95,20 @@ graph TD
9595
Worker[Worker Service] -->|Consume Tasks| Valkey
9696
Worker -->|ORM| Postgres
9797
Worker -->|Vector Ops| Postgres
98-
Worker -->|Object Storage| MinIO[(MinIO)]
98+
Worker -->|Object Storage Interface| Storage[(MinIO / Tencent COS)]
9999
```
100100

101101
### Core Components
102102

103-
| Component | Technology | Purpose |
104-
| ------------ | ----------------------------------------------------- | ------------------------------------------------- |
105-
| **Studio** | Next.js 15, React 19, TypeScript | Frontend UI, Server Actions, Authentication |
106-
| **Worker** | Node.js, BullMQ | Background job processing, batch operations |
107-
| **Database** | PostgreSQL 18, pgvector, Prisma 6 | Relational data, vector search, and ORM |
108-
| **Cache** | Valkey | Redis-protocol cache, session state, task queues |
109-
| **Storage** | MinIO (S3-compatible) | Document and asset storage |
110-
| **Parser** | DOCX XML parser, pdf-parse, OCR fallback, text parser | Document parsing for DOCX, PDF, TXT, and Markdown |
111-
| **Gateway** | Traefik | Reverse proxy, SSL/TLS termination |
103+
| Component | Technology | Purpose |
104+
| ------------ | ----------------------------------------------------- | ----------------------------------------------------------- |
105+
| **Studio** | Next.js 15, React 19, TypeScript | Frontend UI, Server Actions, Authentication |
106+
| **Worker** | Node.js, BullMQ | Background job processing, batch operations |
107+
| **Database** | PostgreSQL 18, pgvector, PGroonga, Prisma 6 | Relational data, vector search, CJK keyword search, and ORM |
108+
| **Cache** | Valkey | Redis-protocol cache, session state, task queues |
109+
| **Storage** | StorageService interface, MinIO, Tencent COS | Document and asset storage |
110+
| **Parser** | DOCX XML parser, pdf-parse, OCR fallback, text parser | Document parsing for DOCX, PDF, TXT, and Markdown |
111+
| **Gateway** | Traefik | Reverse proxy, SSL/TLS termination |
112112

113113
## 🚀 Quick Start
114114

@@ -228,7 +228,7 @@ cp .env.example .env.production
228228
docker compose build app app_worker
229229

230230
# Deploy services
231-
docker compose up -d traefik app app_worker db valkey minio
231+
docker compose up -d traefik app app_worker db valkey
232232

233233
# Services will be available on configured domain with SSL via Traefik
234234
```
@@ -337,8 +337,9 @@ Built with modern technologies:
337337
- [Next.js](https://nextjs.org/) - React framework
338338
- [Prisma](https://www.prisma.io/) - Database ORM
339339
- [pgvector](https://github.com/pgvector/pgvector) - PostgreSQL vector search
340+
- [PGroonga](https://pgroonga.github.io/) - CJK-capable PostgreSQL full-text search
340341
- [BullMQ](https://docs.bullmq.io/) - Job queues
341-
- [MinIO](https://min.io/) - Object storage
342+
- [MinIO](https://min.io/) / Tencent COS - Object storage
342343
- [Traefik](https://traefik.io/) - Reverse proxy
343344

344345
## 📞 Support

README_ZH.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ DeepTrans Studio 已在 CSCW '26 Companion Demo(CCF-A)论文中介绍。如
5959
- **多引擎支持**:集成 OpenAI 及自定义 AI 模型
6060
- **术语提取**:自动提取领域专业术语
6161
- **质量评估**:AI 驱动的语法、句法和语篇评估
62-
- **翻译记忆**:基于 PostgreSQL + pgvector 的向量语义搜索
62+
- **翻译记忆**:基于 pgvector 的向量检索和基于 PGroonga 的 CJK 关键词检索
6363

6464
### 📚 知识管理
6565

6666
- **项目词典**:项目专属术语数据库
6767
- **翻译记忆**:支持 TMX、CSV、XLSX 格式导入导出
68-
- **语义搜索**:基于 pgvector 的向量相似度搜索
68+
- **语义搜索**:基于 pgvector 的向量相似度搜索,结合 PGroonga 关键词检索
6969

7070
### 🔄 工作流自动化
7171

@@ -76,7 +76,7 @@ DeepTrans Studio 已在 CSCW '26 Companion Demo(CCF-A)论文中介绍。如
7676

7777
### 🔌 可扩展性
7878

79-
- **开放架构**:模块化设计,集成 PostgreSQL、MinIO、Valkey
79+
- **开放架构**:模块化设计,集成 PostgreSQL、Valkey 与可插拔对象存储
8080
- **API 网关**:提供 RESTful API 用于外部集成
8181
- **自定义智能体**:可扩展的 AI 智能体框架
8282
- **插件系统**:支持自定义翻译引擎和处理流程
@@ -95,20 +95,20 @@ graph TD
9595
Worker[Worker 服务] -->|消费任务| Valkey
9696
Worker -->|ORM| Postgres
9797
Worker -->|向量操作| Postgres
98-
Worker -->|对象存储| MinIO[(MinIO)]
98+
Worker -->|对象存储接口| Storage[(MinIO / 腾讯云 COS)]
9999
```
100100

101101
### 核心组件
102102

103-
| 组件 | 技术栈 | 用途 |
104-
| ---------- | ------------------------------------------------ | --------------------------------- |
105-
| **Studio** | Next.js 15, React 19, TypeScript | 前端 UI、Server Actions、身份验证 |
106-
| **Worker** | Node.js, BullMQ | 后台任务处理、批量操作 |
107-
| **数据库** | PostgreSQL 18, pgvector, Prisma 6 | 关系型数据、向量检索与 ORM |
108-
| **缓存** | Valkey | Redis 协议缓存、任务队列 |
109-
| **存储** | MinIO (S3 兼容) | 文档和资源存储 |
110-
| **解析器** | DOCX XML 解析器、pdf-parse、OCR 兜底、文本解析器 | 解析 DOCX、PDF、TXT 与 Markdown |
111-
| **网关** | Traefik | 反向代理、SSL/TLS 终端 |
103+
| 组件 | 技术栈 | 用途 |
104+
| ---------- | ------------------------------------------------ | ------------------------------------------ |
105+
| **Studio** | Next.js 15, React 19, TypeScript | 前端 UI、Server Actions、身份验证 |
106+
| **Worker** | Node.js, BullMQ | 后台任务处理、批量操作 |
107+
| **数据库** | PostgreSQL 18, pgvector, PGroonga, Prisma 6 | 关系型数据、向量检索、CJK 关键词检索与 ORM |
108+
| **缓存** | Valkey | Redis 协议缓存、任务队列 |
109+
| **存储** | StorageService 接口、MinIO、腾讯云 COS | 文档和资源存储 |
110+
| **解析器** | DOCX XML 解析器、pdf-parse、OCR 兜底、文本解析器 | 解析 DOCX、PDF、TXT 与 Markdown |
111+
| **网关** | Traefik | 反向代理、SSL/TLS 终端 |
112112

113113
## 🚀 快速开始
114114

@@ -228,7 +228,7 @@ cp .env.example .env.production
228228
docker compose build app app_worker
229229

230230
# 部署服务
231-
docker compose up -d traefik app app_worker db valkey minio
231+
docker compose up -d traefik app app_worker db valkey
232232

233233
# 服务将在配置的域名上通过 Traefik 提供 SSL 访问
234234
```
@@ -337,8 +337,9 @@ DeepTrans Studio 使用 [next-intl](https://next-intl-docs.vercel.app/) 进行
337337
- [Next.js](https://nextjs.org/) - React 框架
338338
- [Prisma](https://www.prisma.io/) - 数据库 ORM
339339
- [pgvector](https://github.com/pgvector/pgvector) - PostgreSQL 向量检索
340+
- [PGroonga](https://pgroonga.github.io/) - 支持 CJK 的 PostgreSQL 全文检索
340341
- [BullMQ](https://docs.bullmq.io/) - 任务队列
341-
- [MinIO](https://min.io/) - 对象存储
342+
- [MinIO](https://min.io/) / 腾讯云 COS - 对象存储
342343
- [Traefik](https://traefik.io/) - 反向代理
343344

344345
## 📞 支持

docker-compose-prod.yml

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -51,45 +51,6 @@ services:
5151
- 'traefik.http.routers.traefik.entrypoints=websecure'
5252
- 'traefik.http.routers.traefik.tls=true'
5353
- 'traefik.http.routers.traefik.tls.certresolver=le'
54-
minio:
55-
image: minio/minio:latest
56-
container_name: deeptrans-minio
57-
restart: always
58-
environment:
59-
MINIO_ROOT_USER: ${MINIO_ACCESS_KEY:-minioadmin}
60-
MINIO_ROOT_PASSWORD: ${MINIO_SECRET_KEY:-minioadmin}
61-
MINIO_BUCKET_NAME: ${MINIO_BUCKET:-deeptrans}
62-
volumes:
63-
- minio-data:/data
64-
ports:
65-
- '${MINIO_PORT:-9000}:9000' # API 端口)
66-
- '${MINIO_CONSOLE_PORT:-9001}:9001' # 控制台端口
67-
command: minio server /data --console-address ":9001"
68-
healthcheck:
69-
test: ['CMD', 'mc', 'ready', 'local']
70-
interval: 30s
71-
timeout: 10s
72-
retries: 3
73-
networks:
74-
- app_local
75-
- web # 连接到web网络
76-
labels:
77-
- 'traefik.enable=true'
78-
# 1. 控制台路由 (Console) - 用于浏览器访问
79-
- 'traefik.http.routers.minio-console.rule=Host(`minio-admin.deeptrans.studio`)'
80-
- 'traefik.http.routers.minio-console.entrypoints=websecure'
81-
- 'traefik.http.routers.minio-console.tls=true'
82-
- 'traefik.http.routers.minio-console.tls.certresolver=le'
83-
- 'traefik.http.routers.minio-console.service=minio-console-svc'
84-
- 'traefik.http.services.minio-console-svc.loadbalancer.server.port=9001'
85-
86-
# 2. API 路由 (S3 API) - 用于程序和 SDK 访问
87-
- 'traefik.http.routers.minio-api.rule=Host(`minio.deeptrans.studio`)'
88-
- 'traefik.http.routers.minio-api.entrypoints=websecure'
89-
- 'traefik.http.routers.minio-api.tls=true'
90-
- 'traefik.http.routers.minio-api.tls.certresolver=le'
91-
- 'traefik.http.routers.minio-api.service=minio-api-svc'
92-
- 'traefik.http.services.minio-api-svc.loadbalancer.server.port=9000'
9354
valkey:
9455
image: valkey/valkey:8-alpine
9556
container_name: deeptrans-valkey
@@ -107,6 +68,16 @@ services:
10768
container_name: deeptrans-app
10869
env_file:
10970
- .env
71+
environment:
72+
STORAGE_TYPE: cos
73+
STORAGE_USE_SSL: 'true'
74+
COS_SECRET_ID: ${COS_SECRET_ID}
75+
COS_SECRET_KEY: ${COS_SECRET_KEY}
76+
COS_BUCKET: ${COS_BUCKET}
77+
COS_REGION: ${COS_REGION}
78+
COS_APP_ID: ${COS_APP_ID:-}
79+
COS_DOMAIN: ${COS_DOMAIN:-}
80+
COS_USE_SSL: ${COS_USE_SSL:-true}
11081
depends_on:
11182
- db
11283
- valkey
@@ -127,6 +98,16 @@ services:
12798
container_name: deeptrans-app_worker
12899
env_file:
129100
- .env
101+
environment:
102+
STORAGE_TYPE: cos
103+
STORAGE_USE_SSL: 'true'
104+
COS_SECRET_ID: ${COS_SECRET_ID}
105+
COS_SECRET_KEY: ${COS_SECRET_KEY}
106+
COS_BUCKET: ${COS_BUCKET}
107+
COS_REGION: ${COS_REGION}
108+
COS_APP_ID: ${COS_APP_ID:-}
109+
COS_DOMAIN: ${COS_DOMAIN:-}
110+
COS_USE_SSL: ${COS_USE_SSL:-true}
130111
depends_on:
131112
- db
132113
- valkey
@@ -142,6 +123,5 @@ networks:
142123

143124
volumes:
144125
postgres_data:
145-
minio-data:
146126
traefik_data:
147127
valkey-data:
Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
CREATE EXTENSION IF NOT EXISTS vector;
22
CREATE EXTENSION IF NOT EXISTS pg_trgm;
33
CREATE EXTENSION IF NOT EXISTS unaccent;
4-
5-
DO $$
6-
BEGIN
7-
CREATE EXTENSION IF NOT EXISTS pgroonga;
8-
EXCEPTION
9-
WHEN OTHERS THEN
10-
RAISE NOTICE 'pgroonga extension is not installed; continuing with pgvector and pg_trgm';
11-
END
12-
$$;
4+
CREATE EXTENSION IF NOT EXISTS pgroonga;
135

146
ALTER TABLE "TranslationMemoryEntry"
157
ADD COLUMN IF NOT EXISTS embedding vector(1536);
@@ -27,15 +19,10 @@ CREATE INDEX IF NOT EXISTS "TranslationMemoryEntry_targetText_trgm_idx"
2719
ON "TranslationMemoryEntry"
2820
USING gin ("targetText" gin_trgm_ops);
2921

30-
DO $$
31-
BEGIN
32-
IF EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'pgroonga') THEN
33-
CREATE INDEX IF NOT EXISTS "TranslationMemoryEntry_sourceText_pgroonga_idx"
34-
ON "TranslationMemoryEntry"
35-
USING pgroonga ("sourceText");
36-
CREATE INDEX IF NOT EXISTS "TranslationMemoryEntry_targetText_pgroonga_idx"
37-
ON "TranslationMemoryEntry"
38-
USING pgroonga ("targetText");
39-
END IF;
40-
END
41-
$$;
22+
CREATE INDEX IF NOT EXISTS "TranslationMemoryEntry_sourceText_pgroonga_idx"
23+
ON "TranslationMemoryEntry"
24+
USING pgroonga ("sourceText");
25+
26+
CREATE INDEX IF NOT EXISTS "TranslationMemoryEntry_targetText_pgroonga_idx"
27+
ON "TranslationMemoryEntry"
28+
USING pgroonga ("targetText");

src/actions/upload.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import { createLogger } from '@/lib/logger';
44
import { requireOwnedProject, requireUser, requireWritableProject } from '@/lib/guards';
55
import { getStorageConfigFromEnv } from '@/lib/storage/config';
66
import { createStorageService } from '@/lib/storage/factory';
7-
const logger = createLogger({
8-
type: 'actions:upload',
9-
}, {
10-
json: false,// 开启json格式输出
11-
pretty: false, // 关闭开发环境美化输出
12-
colors: true, // 仅当json:false时启用颜色输出可用
13-
includeCaller: false, // 日志不包含调用者
14-
});
7+
const logger = createLogger(
8+
{
9+
type: 'actions:upload',
10+
},
11+
{
12+
json: false, // 开启json格式输出
13+
pretty: false, // 关闭开发环境美化输出
14+
colors: true, // 仅当json:false时启用颜色输出可用
15+
includeCaller: false, // 日志不包含调用者
16+
}
17+
);
1518
// 创建存储服务实例
1619
const storageService = createStorageService(getStorageConfigFromEnv());
1720

src/app/(app)/docs/i18n/pages-en/installation-en.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"envConfig": {
2525
"title": "Configure Environment Variables",
2626
"description": "Copy or create .env.local and fill in according to your actual environment:",
27-
"note": "💡 For production environments, please change the database, Valkey, pgvector, and object storage to dedicated instances and keep credentials secure.",
27+
"note": "💡 For production environments, please use Tencent COS for object storage and change the database, Valkey, and pgvector to dedicated instances and keep credentials secure.",
2828
"example": "# Database & Cache\nDATABASE_URL=\"postgresql://postgres:123456@localhost:5432/deeptrans\"\nREDIS_URL=\"redis://valkey:6379\"\n\n# Authentication & Site Config\nAUTH_SECRET=\"Please generate a random string\"\nNEXTAUTH_URL=\"http://localhost:3000\"\nNODE_ENV=development\n\n# LLM / AI Services\nOPENAI_API_KEY=\"sk-xxxx\"\nOPENAI_BASE_URL=\"https://api.openai.com/v1\"\nOPENAI_API_MODEL=\"gpt-4o-mini\"\n\n# Object Storage: MinIO or Tencent COS\nSTORAGE_TYPE=minio\nSTORAGE_ENDPOINT=localhost\nSTORAGE_PORT=9000\nSTORAGE_USE_SSL=false\nSTORAGE_ACCESS_KEY=minioadmin\nSTORAGE_SECRET_KEY=minioadmin\nSTORAGE_BUCKET=deeptrans\n\n# Tencent COS example\n# STORAGE_TYPE=cos\n# COS_SECRET_ID=AKIDxxxxxxxx\n# COS_SECRET_KEY=xxxxxxxx\n# COS_BUCKET=deeptrans-1250000000\n# COS_REGION=ap-guangzhou\n\n# Other Services\nSTUDIO_HOST=localhost # Used for Traefik/HTTPS deployment\n\n# Optional: GitHub OAuth, SMTP, pgvector access info, etc."
2929
},
3030
"initDb": {
@@ -42,7 +42,7 @@
4242
"step1": {
4343
"title": "Start Dependency Services",
4444
"description": "Recommended to use services from Docker Compose:",
45-
"command": "docker compose up -d db valkey minio\n# If you need Traefik, append traefik"
45+
"command": "docker compose up -d db valkey minio\n# Development uses MinIO locally. Production uses Tencent COS and does not start MinIO."
4646
},
4747
"step2": {
4848
"title": "Start Next.js Application",
@@ -73,7 +73,7 @@
7373
},
7474
"step3": {
7575
"title": "Start Main Services",
76-
"command": "docker compose up -d traefik app app_worker db valkey minio",
76+
"command": "docker compose up -d traefik app app_worker db valkey",
7777
"note": "Traefik will map ports 80/443 to Studio. Prisma Studio can be started as needed."
7878
}
7979
},

src/app/(app)/docs/i18n/pages-zh/installation-zh.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"envConfig": {
2525
"title": "配置环境变量",
2626
"description": "复制或创建 .env.local 并依据实际环境填写:",
27-
"note": "💡 生产环境请将数据库、Valkey、pgvector、对象存储改为专用实例,并妥善保管密钥。",
27+
"note": "💡 生产环境使用腾讯云 COS 作为对象存储,并将数据库、Valkey、pgvector 改为专用实例,并妥善保管密钥。",
2828
"example": "# 数据库与缓存\nDATABASE_URL=\"postgresql://postgres:123456@localhost:5432/deeptrans\"\nREDIS_URL=\"redis://valkey:6379\"\n\n# 鉴权 & 站点配置\nAUTH_SECRET=\"请生成随机字符串\"\nNEXTAUTH_URL=\"http://localhost:3000\"\nNODE_ENV=development\n\n# LLM / AI 服务\nOPENAI_API_KEY=\"sk-xxxx\"\nOPENAI_BASE_URL=\"https://api.openai.com/v1\"\nOPENAI_API_MODEL=\"gpt-4o-mini\"\n\n# 对象存储:MinIO 或腾讯云 COS\nSTORAGE_TYPE=minio\nSTORAGE_ENDPOINT=localhost\nSTORAGE_PORT=9000\nSTORAGE_USE_SSL=false\nSTORAGE_ACCESS_KEY=minioadmin\nSTORAGE_SECRET_KEY=minioadmin\nSTORAGE_BUCKET=deeptrans\n\n# 腾讯云 COS 示例\n# STORAGE_TYPE=cos\n# COS_SECRET_ID=AKIDxxxxxxxx\n# COS_SECRET_KEY=xxxxxxxx\n# COS_BUCKET=deeptrans-1250000000\n# COS_REGION=ap-guangzhou\n\n# 其他服务\nSTUDIO_HOST=localhost # Traefik/HTTPS 部署时使用\n\n# 可选:GitHub OAuth、SMTP、pgvector 访问信息等"
2929
},
3030
"initDb": {
@@ -42,7 +42,7 @@
4242
"step1": {
4343
"title": "启动依赖服务",
4444
"description": "推荐使用 Docker Compose 中的服务:",
45-
"command": "docker compose up -d db valkey minio\n# 如需 Traefik,请追加 traefik"
45+
"command": "docker compose up -d db valkey minio\n# 开发环境本地使用 MinIO;生产环境使用腾讯云 COS,不启动 MinIO。"
4646
},
4747
"step2": {
4848
"title": "启动 Next.js 应用",
@@ -73,7 +73,7 @@
7373
},
7474
"step3": {
7575
"title": "启动主要服务",
76-
"command": "docker compose up -d traefik app app_worker db valkey minio",
76+
"command": "docker compose up -d traefik app app_worker db valkey",
7777
"note": "Traefik 会将 80/443 端口映射到 Studio,Prisma Studio 可按需启动。"
7878
}
7979
},

0 commit comments

Comments
 (0)