# https://github.com/devflowinc/trieve 项目说明书

生成时间：2026-06-24 17:15:47 UTC

## 目录

- [Platform Overview and System Architecture](#page-1)
- [Rust Server, REST API, Handlers, and Workers](#page-2)
- [Client SDKs, Frontend Apps, and Integrations](#page-3)
- [Deployment, Infrastructure, and Companion Microservices](#page-4)

<a id='page-1'></a>

## Platform Overview and System Architecture

### 相关页面

相关主题：[Rust Server, REST API, Handlers, and Workers](#page-2), [Client SDKs, Frontend Apps, and Integrations](#page-3), [Deployment, Infrastructure, and Companion Microservices](#page-4)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [README.md](https://github.com/devflowinc/trieve/blob/main/README.md)
- [website/README.md](https://github.com/devflowinc/trieve/blob/main/website/README.md)
- [website/package.json](https://github.com/devflowinc/trieve/blob/main/website/package.json)
- [website/src/content/products/trieve-api/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/products/trieve-api/index.yaml)
- [website/src/content/singles/homepage/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/singles/homepage/index.yaml)
- [website/src/content/singles/resources-megamenu/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/singles/resources-megamenu/index.yaml)
- [website/src/lib/keystatic/collections/pages.ts](https://github.com/devflowinc/trieve/blob/main/website/src/lib/keystatic/collections/pages.ts)
- [clients/mcp-server/package.json](https://github.com/devflowinc/trieve/blob/main/clients/mcp-server/package.json)
- [clients/n8n-nodes-trieve/README.md](https://github.com/devflowinc/trieve/blob/main/clients/n8n-nodes-trieve/README.md)
- [clients/docusaurus-theme-search/package.json](https://github.com/devflowinc/trieve/blob/main/clients/docusaurus-theme-search/package.json)
- [frontends/chat/src/utils/apiTypes.ts](https://github.com/devflowinc/trieve/blob/main/frontends/chat/src/utils/apiTypes.ts)
- [frontends/chat/package.json](https://github.com/devflowinc/trieve/blob/main/frontends/chat/package.json)
</details>

# 平台概览与系统架构

## 平台定位与核心能力

Trieve 是一个面向 AI 体验的端到端基础设施平台，专注于将混合检索、托管式 RAG（检索增强生成）以及推荐系统统一在同一套 API 表面之下。根据仓库顶层 README 的描述，Trieve 同时提供基于 Qdrant 的语义稠密向量搜索、基于 SPLADE 的稀疏神经搜索以及 BGE 交叉编码器重排序能力，构成一个 72 端点的统一 REST 接口。

资料来源：[README.md:1-50]()

平台关键能力可以归纳为以下几点：

- **混合检索**：将 BM25 / SPLADE 稀疏检索与稠密向量嵌入结合，并通过 BGE 重排序提升最终相关性。
- **托管式 RAG**：集成 OpenRouter 以支持任意 LLM，并提供基于主题的记忆管理与自定义上下文两种模式。
- **可调优的相关性运营**：支持时间衰减、过滤、子句高亮、tag 提升与权重乘子等信号，无需重新索引。
- **分组与子块管理**：可在 chunk（块）或 group（分组）粒度上提供相似度推荐与去重检索。

资料来源：[website/src/content/products/trieve-api/index.yaml:20-45]()

## 系统组件与模块划分

仓库采用 monorepo 形式组织，包含后端服务、客户端 SDK、多个前端应用以及官方站点。下图描述了主要模块之间的层次关系。

```mermaid
graph TB
    subgraph "客户端集成层"
        MCP[mcp-server<br/>Model Context Protocol]
        N8N[n8n-nodes-trieve<br/>工作流节点]
        DOC[docusaurus-theme-search<br/>文档搜索主题]
        SDK1[trieve-ts-sdk]
        SDK2[trieve-py-client]
    end
    subgraph "前端应用"
        CHAT[chat<br/>SolidJS 聊天 UI]
    end
    subgraph "服务端"
        API[Trieve Server<br/>72 个 REST 端点]
        QDRANT[(Qdrant<br/>向量存储)]
        LLM[LLM / Embedding<br/>OpenRouter + BYO]
    end
    subgraph "官方站点"
        WEB[website<br/>Astro + Keystatic CMS]
    end
    CHAT --> API
    MCP --> API
    N8N --> API
    DOC --> API
    SDK1 --> API
    SDK2 --> API
    API --> QDRANT
    API --> LLM
    WEB -.文档主题.-> DOC
    WEB -.TS SDK.-> SDK1
```

### 后端服务与 API 表面

后端通过统一的 REST 接口对外暴露检索、RAG、推荐、消息与文件等能力。具体而言，平台将功能拆分到若干独立但相互协作的资源上：message（带 topic 记忆管理的对话）、chunk（块索引与检索）、group（分组与文件级聚合）、dataset（数据集）、file（文件上传与处理）等。聊天前端所使用的数据契约可以在共享类型文件中找到，包括 `ChunkMetadata`、`FileDTO` 和 `NotificationDTO` 等。

资料来源：[frontends/chat/src/utils/apiTypes.ts:1-90]()

### 客户端 SDK 与集成生态

平台为不同宿主环境提供多个官方客户端，它们共同复用同一套后端能力：

- **TypeScript SDK**：作为前端与文档生态的基础依赖，被 `website` 与 `frontends/chat` 等多个子项目直接引用。
- **Python SDK**：覆盖 Python 后端与数据科学场景。
- **MCP Server**：实现 Model Context Protocol，让 LLM 工具可直接调用 Trieve 的检索能力（package 关键词包含 `mcp`、`ai`、`search`、`model-context-protocol`）。
- **n8n 节点**：在自动化工作流中支持 chunk 搜索与 tool_call 等操作，示例函数名 `is_important` 等被用于结构化决策流程。
- **Docusaurus 搜索主题**：作为文档站点的可插拔搜索组件，兼容 React 17/18/19。

资料来源：[clients/mcp-server/package.json:1-25]()、[clients/n8n-nodes-trieve/README.md:1-40]()、[clients/docusaurus-theme-search/package.json:1-20]()

### 前端应用

`frontends/chat` 是基于 SolidJS 的聊天前端，使用 `solid-markdown` 与 `rehype-sanitize` 处理消息流渲染，并通过 `trieve-ts-sdk` 与服务端通信。其 `apiTypes.ts` 中定义的共享类型既作为前端的状态载体，也作为前后端契约的来源，确保跨端数据形态一致。

资料来源：[frontends/chat/package.json:1-25]()、[frontends/chat/src/utils/apiTypes.ts:30-90]()

### 官方站点与内容管理

`website` 使用 Astro + Tailwind CSS + TypeScript 构建，并通过 Keystatic CMS 以 YAML/内容集合的形式管理产品页、博客、首页与资源菜单等内容。`pages.ts` 中将 SEO metadata、pageHeader 与可复用的内容块组合成可发布页面，而 RSS 订阅源则通过 `rss.xml.js` 自动从博客集合渲染。

资料来源：[website/README.md:1-25]()、[website/src/lib/keystatic/collections/pages.ts:1-25]()、[website/src/pages/rss.xml.js:1-20]()

## 部署与交付模式

README 强调 Trieve 既可作为托管服务使用，也支持在自有 VPC 或本地环境中自托管，提供了 AWS、GCP、Kubernetes 与 docker compose 等多种自托管路径。`trieve-helm-0.2.2` 是剥离数据库依赖的纯部署 Helm Chart，配合 Glasskube 包装可以更灵活地管理外部数据库组件。

资料来源：[README.md:20-50]()、[website/src/content/singles/resources-megamenu/index.yaml:1-25]()

## 相关社区议题

- **#3157**：搜索组件目前仅输出 ES Module，社区希望增加 CommonJS 输出以兼容更广泛的运行环境。
- **#2957**：`create_chunk` 处理器对 `tracking_id` 重复的情况未做去重，导致返回数量与实际写入数量不一致。
- **#2623**：缺少批量删除 groups 的接口，社区呼吁通过 `tracking_ids` 或 `group_ids` 一次完成以减少 RTT。
- **#2758**：PDF-to-Markdown Demo UI 仍在补全，目前以 GPT-4o 等视觉 LLM 作为转换后端。
- **#2181**：希望从纯 Helm 迁移到 Glasskube，以更灵活地管理 Trieve 的不同自定义发布与数据库组件。

## 另请参阅

- [Trieve API 产品页配置](website/src/content/products/trieve-api/index.yaml)
- [Keystatic Pages 集合定义](website/src/lib/keystatic/collections/pages.ts)
- [MCP Server 包元信息](clients/mcp-server/package.json)
- [n8n 节点使用说明](clients/n8n-nodes-trieve/README.md)
- [聊天前端 API 类型](frontends/chat/src/utils/apiTypes.ts)

---

<a id='page-2'></a>

## Rust Server, REST API, Handlers, and Workers

### 相关页面

相关主题：[Platform Overview and System Architecture](#page-1), [Client SDKs, Frontend Apps, and Integrations](#page-3), [Deployment, Infrastructure, and Companion Microservices](#page-4)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [server/src/main.rs](https://github.com/devflowinc/trieve/blob/main/server/src/main.rs)
- [server/src/lib.rs](https://github.com/devflowinc/trieve/blob/main/server/src/lib.rs)
- [server/src/handlers/mod.rs](https://github.com/devflowinc/trieve/blob/main/server/src/handlers/mod.rs)
- [server/src/handlers/chunk_handler.rs](https://github.com/devflowinc/trieve/blob/main/server/src/handlers/chunk_handler.rs)
- [server/src/handlers/group_handler.rs](https://github.com/devflowinc/trieve/blob/main/server/src/handlers/group_handler.rs)
- [server/src/handlers/search_operator.rs](https://github.com/devflowinc/trieve/blob/main/server/src/handlers/search_operator.rs)
- [README.md](https://github.com/devflowinc/trieve/blob/main/README.md)
</details>

# Rust Server、REST API、处理器与工作者

## 概述

Trieve 的服务端由 Rust 实现，是一个统一的检索增强生成（RAG）基础设施。它通过一套 REST 接口同时提供密集向量检索、稀疏神经检索（SPLADE）、混合重排序、推荐、消息对话以及文件分组等能力。README 将其定位为「all-in-one RAG infrastructure」式的单一可执行服务（资料来源：[README.md]()）。

服务端代码集中在 `server/` 目录，采用典型的 Rust 二进制 + 库拆分模式：`main.rs` 作为启动入口，`lib.rs` 承载可被复用与测试的核心模块，HTTP 处理函数则按资源域组织在 `handlers/` 子目录下（资料来源：[server/src/main.rs](), [server/src/lib.rs]()）。

## 架构与入口

`server/src/main.rs` 负责初始化配置、连接 PostgreSQL/Qdrant/Redis 等基础设施并启动 HTTP 监听；`server/src/lib.rs` 则是模块树的根节点，把路由、处理器、运算符（operator）与后台任务装配为可运行的 Rust web 应用（资料来源：[server/src/main.rs](), [server/src/lib.rs]()）。

整体分层可以用下图描述：

```mermaid
flowchart TB
  Client[HTTP 客户端] -->|REST| Router[Router]
  Router --> Handlers[handlers/*]
  Handlers --> Operators[operators/*]
  Operators --> DB[(Postgres + Qdrant + Redis)]
  Handlers --> Workers[后台任务]
  Workers --> DB
```

每一层都对应 `server/src` 下的同名子目录，处理器模块通过 `server/src/handlers/mod.rs` 集中导出（资料来源：[server/src/handlers/mod.rs]()）。

## 处理器与搜索运算符

`server/src/handlers/` 下的处理器按资源域划分：

- `chunk_handler.rs`：实现 chunk 的创建、获取、删除与批量导入。README 中提到的 `create_chunk_handler` 即来自此处（资料来源：[server/src/handlers/chunk_handler.rs](), [README.md]()）。
- `group_handler.rs`：把多个 chunk 聚合为同一文件，并按 `tracking_id` / `group_id` 暴露查询与删除接口（资料来源：[server/src/handlers/group_handler.rs]()）。
- `search_operator.rs`：负责 `search` 与 `recommend` 端点的核心逻辑，将 BM25 / SPLADE 稀疏检索、密集向量检索、BGE Cross-Encoder 重排序、元数据过滤、促销调权与子句高亮串成一次调用（资料来源：[server/src/handlers/search_operator.rs](), [README.md]()）。

## 工作者、已知问题与社区关注点

### 异步后台任务

除同步处理器外，服务端还包括若干异步 worker，用于处理文件上传、PDF 解析、Webhook 投递、消息记忆清理等离线任务。Worker 与 Handler 共享同一份数据访问层，但通过队列或定时调度触发，避免阻塞请求线程（资料来源：[server/src/lib.rs]()）。

### 社区关注的改进点

- **CJS 构建支持**：search-component 仍只产出 ESM，社区希望补充 CommonJS 输出（社区 Issue #3157）。
- **create_chunk 去重**：`chunk_handler` 需要在返回前按 `tracking_id` 去重，让客户端准确获知实际入库数量（社区 Issue #2957，资料来源：[server/src/handlers/chunk_handler.rs]()）。
- **批量删除 group**：当前需要多次 RTT，社区希望合并为单次请求（社区 Issue #2623，资料来源：[server/src/handlers/group_handler.rs]()）。
- **Glasskube 打包**：社区正在跟踪把 Helm chart 迁向 Glasskube 包的进度（社区 Issue #2181）。

## See Also

- [README.md](https://github.com/devflowinc/trieve/blob/main/README.md)
- [Trieve API Reference](https://api.trieve.ai/redoc)
- [Typescript SDK](https://ts-sdk.trieve.ai/)

---

<a id='page-3'></a>

## Client SDKs, Frontend Apps, and Integrations

### 相关页面

相关主题：[Platform Overview and System Architecture](#page-1), [Rust Server, REST API, Handlers, and Workers](#page-2), [Deployment, Infrastructure, and Companion Microservices](#page-4)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [README.md](https://github.com/devflowinc/trieve/blob/main/README.md)
- [clients/mcp-server/package.json](https://github.com/devflowinc/trieve/blob/main/clients/mcp-server/package.json)
- [clients/n8n-nodes-trieve/README.md](https://github.com/devflowinc/trieve/blob/main/clients/n8n-nodes-trieve/README.md)
- [clients/trieve-shopify-extension/README.md](https://github.com/devflowinc/trieve/blob/main/clients/trieve-shopify-extension/README.md)
- [clients/docusaurus-theme-search/package.json](https://github.com/devflowinc/trieve/blob/main/clients/docusaurus-theme-search/package.json)
- [frontends/shared/package.json](https://github.com/devflowinc/trieve/blob/main/frontends/shared/package.json)
- [frontends/chat/package.json](https://github.com/devflowinc/trieve/blob/main/frontends/chat/package.json)
- [frontends/search/package.json](https://github.com/devflowinc/trieve/blob/main/frontends/search/package.json)
- [website/README.md](https://github.com/devflowinc/trieve/blob/main/website/README.md)
- [website/package.json](https://github.com/devflowinc/trieve/blob/main/website/package.json)
- [website/src/pages/rss.xml.js](https://github.com/devflowinc/trieve/blob/main/website/src/pages/rss.xml.js)
- [website/src/content/integrations/shopify/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/integrations/shopify/index.yaml)
- [website/src/content/integrations/judge-me/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/integrations/judge-me/index.yaml)
- [website/src/content/products/trieve-api/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/products/trieve-api/index.yaml)
</details>

# 客户端 SDK、前端应用与集成生态

Trieve 是一个面向 AI 搜索与 RAG（Retrieval-Augmented Generation，检索增强生成）的全栈平台。除了核心的 `server` 之外，仓库还维护着一整套**客户端 SDK、参考前端应用以及第三方平台集成**，用于让不同技术栈的开发者都能以最小的成本接入 Trieve 的 72 端点 API。本页对这一生态系统进行系统性梳理。

## 生态总览

Trieve 的客户端生态可以分为三层：**协议层 SDK**、**参考前端** 与 **第三方集成**。三者共同面向「开发者快速试用」和「生产环境嵌入」两种使用场景。

```mermaid
graph TB
  subgraph "协议层 SDK"
    A[TypeScript SDK<br/>trieve-ts-sdk]
    B[Python SDK<br/>trieve-py-client]
    C[MCP Server<br/>Model Context Protocol]
  end
  subgraph "参考前端 (Solid.js)"
    D[frontends/search<br/>搜索组件]
    E[frontends/chat<br/>聊天 UI]
    F[frontends/shared<br/>通用逻辑]
  end
  subgraph "第三方集成"
    G[n8n-nodes-trieve]
    H[trieve-shopify-extension]
    I[docusaurus-theme-search]
    J[Judge.me 集成]
  end
  A --> K[Trieve API<br/>72 端点]
  B --> K
  C --> K
  D --> K
  E --> K
  H --> K
  I --> K
  G --> K
```

资料来源：[README.md](https://github.com/devflowinc/trieve/blob/main/README.md)、[website/src/content/products/trieve-api/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/products/trieve-api/index.yaml)

## 官方 SDK 与协议适配器

### TypeScript SDK

`trieve-ts-sdk` 是 Trieve 的旗舰 SDK，被几乎所有官方前端与集成直接依赖。`frontends/chat/package.json`、`frontends/search/package.json` 以及 `frontends/shared/package.json` 均通过 `"trieve-ts-sdk": "*"` 进行本地 workspace 引用，而 `website/package.json` 则固定到 `"trieve-ts-sdk": "^0.0.115"` 的发布版本，用于在 Astro 站点中拉取博客与产品内容。

资料来源：[frontends/chat/package.json](https://github.com/devflowinc/trieve/blob/main/frontends/chat/package.json)、[frontends/search/package.json](https://github.com/devflowinc/trieve/blob/main/frontends/search/package.json)、[website/package.json](https://github.com/devflowinc/trieve/blob/main/website/package.json)

### Python SDK

README 顶部明确列出了 PyPI 上的 Python SDK 入口：[Python SDK](https://pypi.org/project/trieve-py-client/)，与 TypeScript SDK 一起作为 Trieve API 的双语言一等公民。

资料来源：[README.md](https://github.com/devflowinc/trieve/blob/main/README.md)

### MCP Server

`clients/mcp-server` 目录以 `model-context-protocol` 作为关键字暴露给 AI Agent，使具备 MCP 兼容能力的客户端（如 Claude Desktop）能够直接以工具调用的方式使用 Trieve 的搜索与 RAG 功能。其 `package.json` 中声明了 `"keywords": ["trieve", "mcp", "ai", "search", "model-context-protocol"]`，并沿用与主仓库一致的 MIT 许可证。

资料来源：[clients/mcp-server/package.json](https://github.com/devflowinc/trieve/blob/main/clients/mcp-server/package.json)

## 参考前端应用

`frontends/` 目录下包含三个相互协作的 Solid.js 工作区：

| 应用 | 依赖的核心 SDK 与库 | 主要职责 |
| :--- | :--- | :--- |
| `frontends/search` | `solid-js`、`solid-headless`、`trieve-ts-sdk` | 嵌入式搜索组件与搜索页面，对应社区 Issue #3157 中提到的 `search-component` 构建管线 |
| `frontends/chat` | `@solidjs/router`、`solid-markdown`、`trieve-ts-sdk` | 聊天与 RAG 会话界面，支持 Markdown 渲染与清理 |
| `frontends/shared` | `tailwind-merge`、`solid-js` | 跨 `search` 与 `chat` 复用的 UI 工具与类型 |

`frontends/shared` 通过 `"shared": "*"` 被另外两个前端应用 workspace 依赖，避免逻辑重复。

资料来源：[frontends/shared/package.json](https://github.com/devflowinc/trieve/blob/main/frontends/shared/package.json)、[frontends/chat/package.json](https://github.com/devflowinc/trieve/blob/main/frontends/chat/package.json)、[frontends/search/package.json](https://github.com/devflowinc/trieve/blob/main/frontends/search/package.json)

社区正在讨论的相关改进包括：Issue #3157 希望为 `search-component` 增加 CommonJS 构建产物，以便在仅支持 CJS 的旧项目中直接引用；Issue #2758 则希望补齐基于 Vision LLM 的 `pdf2md` 演示 UI。这些工作都集中在 `clients/search-component` 与 `frontends` 这两条产品线上。

资料来源：[README.md](https://github.com/devflowinc/trieve/blob/main/README.md)（社区 Issue 摘要）

## 第三方平台集成

### 工作流与无代码：`n8n-nodes-trieve`

`clients/n8n-nodes-trieve/README.md` 描述了如何在本地 `~/.n8n/custom/` 目录下创建符号链接，使 n8n 启动时自动加载该节点，并提供了 `tool_call` 等操作的示例 payload，用于让 LLM 在 n8n 工作流中通过 Trieve 提取结构化字段。

资料来源：[clients/n8n-nodes-trieve/README.md](https://github.com/devflowinc/trieve/blob/main/clients/n8n-nodes-trieve/README.md)

### 电商：`trieve-shopify-extension`

基于 Remix 框架构建的 Shopify 应用模板，集成 Shopify App Remix、App Bridge 与 Polaris 三件套。该扩展同时支持 Judge.me 评论授权回调（`/auth/judgeme/callback`），将评论数据作为知识源喂给 Trieve 的 RAG 管线。`website/src/content/integrations/shopify/index.yaml` 将其营销定位为「实时推荐」「主题友好样式」「SOC 2 Type II 合规」等卖点。

资料来源：[clients/trieve-shopify-extension/README.md](https://github.com/devflowinc/trieve/blob/main/clients/trieve-shopify-extension/README.md)、[website/src/content/integrations/shopify/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/integrations/shopify/index.yaml)

### 文档站：`docusaurus-theme-search`

`clients/docusaurus-theme-search/package.json` 声明了与 Docusaurus 2/3、React 17/18/19（包含 RC）的 `peerDependencies`，并使用 `esbuild` 完成主题的构建与热更新（Nodemon 监听）。

资料来源：[clients/docusaurus-theme-search/package.json](https://github.com/devflowinc/trieve/blob/main/clients/docusaurus-theme-search/package.json)

### 评测与社评：Judge.me

`website/src/content/integrations/judge-me/index.yaml` 描述了 Trieve 如何在 AI 回复中嵌入 Judge.me 的真实顾客评价，用于「特性高亮」「情感感知回复」与「评论摘要」等场景。

资料来源：[website/src/content/integrations/judge-me/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/integrations/judge-me/index.yaml)

## 营销与内容站点

`website/` 是 Trieve 的官方站点，基于 Astro + Tailwind CSS + Keystatic CMS 构建，使用 Markdown 作为内容载体，并通过 `website/src/pages/rss.xml.js` 暴露博客 RSS 源。其依赖中包含了 `markdown-it`、`sanitize-html` 与 `marked`，用于在 RSS 与博客渲染中对内容进行解析与清洗。

资料来源：[website/README.md](https://github.com/devflowinc/trieve/blob/main/website/README.md)、[website/src/pages/rss.xml.js](https://github.com/devflowinc/trieve/blob/main/website/src/pages/rss.xml.js)

## See Also

- [Trieve API 产品概述](https://docs.trieve.ai/api-reference)（来源：[website/src/content/products/trieve-api/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/products/trieve-api/index.yaml)）
- [README.md 项目总览](https://github.com/devflowinc/trieve/blob/main/README.md)
- 社区讨论：搜索组件 CJS 构建支持（Issue #3157）、`pdf2md` 演示 UI（Issue #2758）、Glasskube 打包追踪（Issue #2181）

---

<a id='page-4'></a>

## Deployment, Infrastructure, and Companion Microservices

### 相关页面

相关主题：[Platform Overview and System Architecture](#page-1), [Rust Server, REST API, Handlers, and Workers](#page-2), [Client SDKs, Frontend Apps, and Integrations](#page-3)

<details>
<summary>相关源码文件</summary>

以下源码文件用于生成本页说明：

- [README.md](https://github.com/devflowinc/trieve/blob/main/README.md)
- [clients/mcp-server/package.json](https://github.com/devflowinc/trieve/blob/main/clients/mcp-server/package.json)
- [clients/mcp-server/README.md](https://github.com/devflowinc/trieve/blob/main/clients/mcp-server/README.md)
- [clients/n8n-nodes-trieve/README.md](https://github.com/devflowinc/trieve/blob/main/clients/n8n-nodes-trieve/README.md)
- [clients/docusaurus-theme-search/package.json](https://github.com/devflowinc/trieve/blob/main/clients/docusaurus-theme-search/package.json)
- [website/README.md](https://github.com/devflowinc/trieve/blob/main/website/README.md)
- [website/package.json](https://github.com/devflowinc/trieve/blob/main/website/package.json)
- [website/src/pages/rss.xml.js](https://github.com/devflowinc/trieve/blob/main/website/src/pages/rss.xml.js)
- [website/src/content/products/trieve-api/index.yaml](https://github.com/devflowinc/trieve/blob/main/website/src/content/products/trieve-api/index.yaml)
- [frontends/chat/package.json](https://github.com/devflowinc/trieve/blob/main/frontends/chat/package.json)
- [frontends/chat/src/utils/apiTypes.ts](https://github.com/devflowinc/trieve/blob/main/frontends/chat/src/utils/apiTypes.ts)
</details>

# Deployment, Infrastructure, and Companion Microservices

## 概述

Trieve 是一个面向 AI 搜索与对话式发现的一体化平台，除了核心检索服务之外，还提供一系列配套的客户端 SDK、独立的微服务以及多个前端应用。部署形态既覆盖在自有 VPC 或本地环境的自托管，也包括 Helm Chart 等 Kubernetes 编排方式。README 中明确指出"We have full self-hosting guides for AWS, GCP, Kubernetes generally, and docker compose available on our documentation page"，说明基础设施层覆盖主流云厂商与编排平台 资料来源：[README.md:5-7]()。

整个仓库的代码组织呈"核心服务 + 多个 `clients/*` 配套包 + 多个 `frontends/*` 前端 + 基础设施配置"的形态，配套包之间相互独立，但都依赖同一个 Trieve API 后端。

## 核心基础设施与依赖

Trieve 的检索能力由一组关键基础设施组件支撑：

- **向量数据库**：使用 Qdrant 提供稠密向量搜索能力，README 描述其为"Integrates with OpenAI or Jina embedding models and Qdrant to provide semantic vector search" 资料来源：[README.md:9-11]()。
- **稀疏向量索引**：采用 `naver/efficient-splade-VI-BT-large-query` 对每个上传的 chunk 进行向量化，实现容错性强的神经稀疏检索 资料来源：[README.md:13-14]()。
- **Cross-encoder 重排序**：在混合搜索路径下使用 `BAAI/bge-reranker-large` 进一步优化最终排序 资料来源：[README.md:24-25]()。
- **大模型路由**：通过 OpenRouter 集成任意 LLM，并为希望自带密钥的用户保留 BYO 模型接口 资料来源：[README.md:22-24]()。

部署层面，社区已发布 `trieve-helm-0.2.2` 等 Helm Chart。社区讨论 #2181 跟踪了从 Helm 迁移到 Glasskube 的工作，目标是将数据库依赖从 Chart 中剥离并以外部 Glasskube 包形式管理。

## 配套微服务与客户端

### MCP 服务器（`clients/mcp-server`）

`clients/mcp-server` 是独立的 Node 包，提供符合 Model Context Protocol 规范的服务器实现，使 AI 代理可通过标准化接口访问 Trieve 数据集，关键词包括 `trieve`、`mcp`、`ai`、`search`、`model-context-protocol` 资料来源：[clients/mcp-server/package.json:1-15]()。

- 安装既支持通过 Smithery 一键接入 Claude Desktop（`npx -y @smithery/cli install trieve-mcp-server --client claude`），也支持手动 `npm install trieve-mcp-server` 资料来源：[clients/mcp-server/README.md:11-23]()。
- 配置项包括 `TRIEVE_API_KEY`、`TRIEVE_ORGANIZATION_ID` 以及可选的 `TRIEVE_DATASET_ID`；命令行参数 `--api-key`、`--org-id`、`--dataset-id` 可覆盖环境变量 资料来源：[clients/mcp-server/README.md:25-44]()。
- 主要能力是跨数据集执行语义搜索并返回数据集元信息，类型安全由 TypeScript 保证。

### n8n 工作流节点（`clients/n8n-nodes-trieve`）

`clients/n8n-nodes-trieve` 将 Trieve 的检索与工具调用能力暴露为 n8n 节点，包含两类核心操作：

- **Chunk Search**：可选 Fulltext、Hybrid 或 Semantic 三种搜索类型，支持分页参数与 JSON 过滤器，结果中包含相关性分数与高亮信息 资料来源：[clients/n8n-nodes-trieve/README.md:30-50]()。
- **Tool Call**：允许在工作流中执行用户自定义函数，参数支持 `boolean` 与 `number` 类型，并提供 `function_name`、`function_description`、`parameters` 等配置字段 资料来源：[clients/n8n-nodes-trieve/README.md:55-90]()。

本地开发通过软链接 `~/.n8n/custom/n8n-nodes-trieve` 与 `npm run build` 让节点出现在 n8n 侧边栏中 资料来源：[clients/n8n-nodes-trieve/README.md:18-28]()。

### Docusaurus 搜索主题（`clients/docusaurus-theme-search`）

该包是面向静态文档站点的搜索插件，`peerDependencies` 声明兼容 Docusaurus 2.x 与 3.x，以及 React 17、18 与 19 RC 资料来源：[clients/docusaurus-theme-search/package.json:1-15]()。它依赖 `json-to-markdown`、`parse5` 等工具进行内容索引与解析，让 Docusaurus 站点可以复用 Trieve 的检索能力。

## 前端应用

### 官方网站（`website/`）

`website` 目录基于 Astro 5 + Tailwind CSS 4 + TypeScript + Keystatic CMS 构建，并直接依赖 `trieve-ts-sdk`（`^0.0.115`）资料来源：[website/package.json:14-30]()。

- 内容组织遵循标准 Astro 结构，包含 `pages/`、`components/`、`content/`、`layouts/`、`lib/` 等目录 资料来源：[website/README.md:11-30]()。
- 通过 `website/src/pages/rss.xml.js` 输出博客 RSS，使用 `markdown-it` 与 `sanitize-html` 处理 Markdown 内容并扩展 `img` 标签白名单 资料来源：[website/src/pages/rss.xml.js:1-20]()。
- 产品页（如 Trieve API）通过 Keystatic YAML 文件描述 `hero`、`killerFeatures`、`metadata` 等字段，使营销内容可以在不修改代码的情况下更新 资料来源：[website/src/content/products/trieve-api/index.yaml:1-30]()。

### Chat 前端（`frontends/chat/`）

`frontends/chat` 使用 Solid.js 与 `trieve-ts-sdk`，并引入 Terracotta、`solid-markdown`、`tailwind-gradient-mask-image` 等组件渲染对话界面 资料来源：[frontends/chat/package.json:1-20]()。前端通过统一的 TypeScript 类型（`ChunkMetadata`、`FileDTO`、`NotificationDTO` 等）与后端交互，类型守卫（如 `isChunkMetadata`）通过 `indirectHasOwnProperty` 在运行时验证字段，保证跨网络边界的健壮性 资料来源：[frontends/chat/src/utils/apiTypes.ts:40-80]()。

## 部署与配套组件一览

| 组件类型 | 名称 | 主要职责 | 关键技术栈 |
| --- | --- | --- | --- |
| 核心检索 | Trieve Server | 混合搜索 / RAG / 推荐 | Rust + Qdrant + SPLADE + BGE |
| 部署包 | trieve-helm | Kubernetes 编排 | Helm Chart（v0.2.2） |
| 代理接口 | trieve-mcp-server | MCP 标准 AI 代理接入 | Node + TypeScript |
| 工作流 | n8n-nodes-trieve | 低代码自动化 | n8n 节点 SDK |
| 文档插件 | docusaurus-theme-search | 静态文档检索 | esbuild + parse5 |
| 官方网站 | website | 营销与文档门户 | Astro 5 + Keystatic |
| 对话界面 | frontends/chat | RAG 聊天演示 | Solid.js + TS SDK |

社区正在跟踪的事项还包括：为 `search-component` 增加 CommonJS 构建产物以覆盖更广的引入方式（#3157），以及在 `create_chunk` 处理器中按 `tracking_id` 去重以提升返回值准确性（#2957）。这些改进会进一步影响前端 SDK 的打包形态与后端 API 的语义。

## See Also

- [README.md](https://github.com/devflowinc/trieve/blob/main/README.md) — 项目特性总览与自托管指南入口
- [clients/mcp-server/README.md](https://github.com/devflowinc/trieve/blob/main/clients/mcp-server/README.md) — MCP 服务器部署与配置
- [clients/n8n-nodes-trieve/README.md](https://github.com/devflowinc/trieve/blob/main/clients/n8n-nodes-trieve/README.md) — n8n 节点使用说明
- [website/README.md](https://github.com/devflowinc/trieve/blob/main/website/README.md) — 官方网站项目结构

---

<!-- evidence_pipeline_checked: true -->
<!-- evidence_injected: true -->

---

## Doramagic 踩坑日志

项目：devflowinc/trieve

摘要：发现 8 个潜在踩坑项，其中 0 个为 high/blocking；最高优先级：能力坑 - 能力判断依赖假设。

## 1. 能力坑 · 能力判断依赖假设

- 严重度：medium
- 证据强度：source_linked
- 发现：README/documentation is current enough for a first validation pass.
- 对用户的影响：假设不成立时，用户拿不到承诺的能力。
- 证据：capability.assumptions | https://github.com/devflowinc/trieve | README/documentation is current enough for a first validation pass.

## 2. 维护坑 · 来源证据：bugfix: add `?api-version` parameter to all chat message requests for Azure OpenAI

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个维护/版本相关的待验证问题：bugfix: add `?api-version` parameter to all chat message requests for Azure OpenAI
- 对用户的影响：可能增加新用户试用和生产接入成本。
- 证据：community_evidence:github | https://github.com/devflowinc/trieve/issues/4017 | 来源类型 github_issue 暴露的待验证使用条件。

## 3. 维护坑 · 维护活跃度未知

- 严重度：medium
- 证据强度：source_linked
- 发现：未记录 last_activity_observed。
- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。
- 证据：evidence.maintainer_signals | https://github.com/devflowinc/trieve | last_activity_observed missing

- 严重度：medium
- 证据强度：source_linked
- 发现：no_demo
- 证据：downstream_validation.risk_items | https://github.com/devflowinc/trieve | no_demo; severity=medium

## 5. 安全/权限坑 · 存在评分风险

- 严重度：medium
- 证据强度：source_linked
- 发现：no_demo
- 对用户的影响：风险会影响是否适合普通用户安装。
- 证据：risks.scoring_risks | https://github.com/devflowinc/trieve | no_demo; severity=medium

## 6. 安全/权限坑 · 来源证据：feature(server): setup billing for edit_image route

- 严重度：medium
- 证据强度：source_linked
- 发现：GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：feature(server): setup billing for edit_image route
- 对用户的影响：可能影响授权、密钥配置或安全边界。
- 证据：community_evidence:github | https://github.com/devflowinc/trieve/issues/3975 | 来源类型 github_issue 暴露的待验证使用条件。

## 7. 维护坑 · issue/PR 响应质量未知

- 严重度：low
- 证据强度：source_linked
- 发现：issue_or_pr_quality=unknown。
- 对用户的影响：用户无法判断遇到问题后是否有人维护。
- 证据：evidence.maintainer_signals | https://github.com/devflowinc/trieve | issue_or_pr_quality=unknown

## 8. 维护坑 · 发布节奏不明确

- 严重度：low
- 证据强度：source_linked
- 发现：release_recency=unknown。
- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。
- 证据：evidence.maintainer_signals | https://github.com/devflowinc/trieve | release_recency=unknown

<!-- canonical_name: devflowinc/trieve; human_manual_source: deepwiki_human_wiki -->
