# 架构

> PentAGI 运行的服务、它们之间的通信方式以及可选组件。

PentAGI 由一组 Docker 服务组成。核心技术栈足以运行 [flows](https://pentagi.com/zh-cn/docs/glossary/#flow)；[knowledge graph](https://pentagi.com/zh-cn/docs/glossary/#knowledge-graph) 和可观测性技术栈为可选附加组件。

## [系统上下文](https://pentagi.com/zh-cn/docs/concepts/architecture/#system-context)

```mermaid
flowchart LR
  accTitle: System context of PentAGI with its users, targets, LLM providers, search engines, monitoring and the update server
  user["Security engineer"] -->|HTTPS| pentagi["PentAGI"]
  user -->|monitors| langfuse["Langfuse"]
  user -->|monitors| grafana["Grafana"]
  pentagi -->|tests| target["Target systems"]
  pentagi -->|queries| llm["LLM providers"]
  pentagi -->|searches| search["Search engines"]
  pentagi -->|reports| langfuse
  pentagi -->|reports| grafana
  pentagi -->|checks for updates| update["update.pentagi.com"]
```

PentAGI 还会在启动后两分钟内以及之后每三小时检查 `update.pentagi.com` 以获取更新的构建版本，并在请求中发送安装摘要；[更新检查](https://pentagi.com/zh-cn/docs/configuration/security/#update-check) 列出了其中包含的内容以及如何关闭它。

## [服务](https://pentagi.com/zh-cn/docs/concepts/architecture/#services)

| 分组              | 服务                                                                                                                             | Compose 文件                         |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------- |
| 核心              | `pentagi`（包含 REST 和 GraphQL 的 Go 后端、React UI）、`pgvector`（带 pgvector 的 PostgreSQL）、`pgexporter`（PostgreSQL 指标）、`scraper`（隔离浏览器） | `docker-compose.yml`               |
| Knowledge graph | `graphiti`、`neo4j`                                                                                                             | `docker-compose-graphiti.yml`      |
| LLM 可观测性        | `langfuse-web`、`langfuse-worker`、`clickhouse`、`redis`、`minio`、`postgres`                                                       | `docker-compose-langfuse.yml`      |
| 系统可观测性          | `grafana`、`otel`、`victoriametrics`、`jaeger`、`clickstore`、`loki`、`node-exporter`、`cadvisor`                                     | `docker-compose-observability.yml` |

[Tools](https://pentagi.com/zh-cn/docs/glossary/#tool) 绝不会在 `pentagi` 容器本身内部运行：每个 flow 都会获得其专属的 [sandbox](https://pentagi.com/zh-cn/docs/glossary/#sandbox) 容器，该容器基于为 flow 的目标所选定的镜像（如 Kali Linux）构建。

## [容器](https://pentagi.com/zh-cn/docs/concepts/architecture/#containers)

```mermaid
graph TB
  accTitle: Containers of the core stack and the optional knowledge graph
  subgraph Core
    UI[Web UI] -->|HTTP/WS| API[Backend API]
    API --> DB[(PostgreSQL + pgvector)]
    API --> Agents[Agents]
    Agents --> Sandbox[Sandboxed tools]
    Agents --> Scraper[Isolated browser]
  end
  subgraph Knowledge graph
    Graphiti --> Neo4j[(Neo4j)]
  end
  Agents --> Graphiti
  API -->|telemetry| OTEL[OpenTelemetry]
  API -->|LLM traces| Langfuse
```

* **后端 API** — Go 语言实现，提供 REST 和 GraphQL 接口，并支持 Bearer Token 访问以实现自动化。
* **Vector store** — 带 pgvector 的 PostgreSQL，用于保存每条命令、输出和嵌入向量。
* **Agents** — 负责规划与执行工作的多智能体系统；请参阅 [Agents](https://pentagi.com/zh-cn/docs/concepts/agents/)。
* **Sandbox** — 与宿主机隔离的 tool 容器；在生产环境中，它们可以部署在独立的 [worker node](https://pentagi.com/zh-cn/docs/deployment/worker-node/) 上。