# 架构

OpenHuman 基于 GNU GPL3 开源。本页展示系统的高层结构；深层开发架构位于 [深层架构参考](https://github.com/tinyhumansai/openhuman/blob/main/gitbooks/developing/architecture.md) 中，见仓库。

## 结构

OpenHuman 是一款 **React + Tauri v2 桌面应用** ，带有一个 **Rust 核心** 负责重活的核心。

```
┌──────────────────────────────────────────────────┐
│ Tauri 外壳（app/src-tauri/） │
│ • 窗口管理、操作系统集成、副车生命周期 │
│ • 用于集成提供方的 CEF 子 WebView │
└──────────────────────────────────────────────────┘
 │ JSON-RPC（HTTP）↕
┌──────────────────────────────────────────────────┐
│ Rust 核心（`openhuman` 二进制，`src/`） │
│ • Memory Tree 管道 │
│ • 集成适配器 + 自动抓取调度器 │
│ • 提供方路由器（模型路由） │
│ • TokenJuice 压缩 │
│ • 原生工具（搜索、抓取、文件系统、git，…） │
│ • 语音（STT 输入，TTS 输出，Meet 代理） │
└──────────────────────────────────────────────────┘
 │
┌──────────────────────────────────────────────────┐
│ React 前端（app/src/） │
│ • 界面、导航 │
│ • 通过 `coreRpcClient` 与核心通信 │
│ • 没有业务逻辑——仅负责展示 │
└──────────────────────────────────────────────────┘
```

**逻辑所在位置：**

* **Rust 核心**。所有业务逻辑。Memory Tree、集成、模型路由、工具、语音。权威来源。
* **Tauri 外壳**。窗口管理、进程生命周期、IPC。是交付载体，而不是功能所在之处。
* **React 前端**。UI 与编排。通过 JSON-RPC 调用核心。

## 数据流

1. **连接**。通过 OAuth 接入一个 [集成](/openhuman/zh/gong-neng/integrations.md)。后端存储令牌；核心永远不会以明文看到它。
2. **自动获取**。每二十分钟， [调度器](/openhuman/zh/gong-neng/obsidian-wiki/auto-fetch.md) 会遍历每个活跃连接，并请求每个原生提供方进行同步。
3. **规范化**。提供方输出（例如一封邮件页面、一个 GitHub diff、一个 Slack 频道导出）会被标准化为带来源标记的 Markdown。
4. **分块**。Markdown 会被拆分为 ≤3k token 的确定性分块。
5. **存储**。分块会落入 SQLite（`<workspace>/memory_tree/chunks.db`）以及 `.md` 文件中，位于 `<workspace>/wiki/`.
6. **评分**。后台工作线程运行嵌入、实体提取、热度评分。
7. **总结**。从分块池构建并刷新来源 / 主题 / 全局摘要树。
8. **检索**。当你提出问题时，代理会查询 Memory Tree（搜索 / 逐层下钻 / 主题 / 全局 / 抓取）。
9. **压缩**。工具输出和大型源数据会先经过 [TokenJuice](/openhuman/zh/gong-neng/token-compression.md) ，再进入 LLM 上下文。
10. **路由**。 [路由器](/openhuman/zh/gong-neng/model-routing.md) 会根据任务提示选择合适的提供方 + 模型。

## 隐私边界

保留在你的机器上：

* Memory Tree 的 SQLite 数据库。
* Obsidian Markdown 知识库。
* 音频采集缓冲区以及任何本地模型状态。

通过 OpenHuman 后端（在一个订阅下）处理：

* LLM 调用（模型提供方）。
* 网页搜索代理。
* 集成 OAuth 和工具代理转发。
* TTS 流式传输。

参见 [隐私与安全](/openhuman/zh/gong-neng/privacy-and-security.md) 以获得完整视图。

## 开源

* **仓库：** [github.com/tinyhumansai/openhuman](https://github.com/tinyhumansai/openhuman)。GNU GPL3。
* **欢迎提交 Issue 和 PR** 。该项目仍处于早期 Beta 阶段。
* 对于贡献者，权威开发者指南是 [深层架构参考](https://github.com/tinyhumansai/openhuman/blob/main/gitbooks/developing/architecture.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tinyhumans.gitbook.io/openhuman/zh/kai-fa/architecture.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
