产品架构
本文是 NeoMind 主项目(camthink-ai/NeoMind)的技术架构深度参考。读完后你应能定位任何功能在哪一层、哪个 crate,并理解进程与并发边界。
面向用户/决策者的非技术架构(产品由哪些部分组成、数据如何流动)见 产品介绍 — 什么是 NeoMind。
分层视图
┌────────────────────────────────────────────── ────────────────┐
│ Desktop App / Web UI │
│ React 18 + TypeScript │
├──────────────────────────────────────────────────────────────┤
│ Tauri 2.x / Browser │
└────────────────────────┬─────────────────────────────────────┘
│ REST / WebSocket / SSE
▼
┌──────────────────────────────────────────────────────────────┐
│ API Gateway │
│ Axum Web Server │
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │
│ │ Auth │ │Devices │ │Automate│ │Messages│ │Extension│ │
│ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ │
└────────────────────────┬─────────────────────────────────────┘
│ Event Bus
┌──────────────┼──────────────┬────────────────┐
▼ ▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────────┐
│ Agent │ │ Devices │ │ Rules │ │ Extensions │
│ (LLM) │ │ (MQTT) │ │ (JSON) │ │ (Process) │
└────┬─────┘ └────┬─────┘ └────┬─────┘ └─────┬──────┘
│ │ │ │
└──────────────┴──────┬───────┴────────────────┘
▼
┌──────────────────┐
│ redb Storage │
│ (time-series) │
└──────────────────┘
Crate 布局
NeoMind 是一个 Rust workspace。每个 crate 有清晰单一的责任:
| Crate | 职责 |
|---|---|
| neomind-core | 核心 trait 与类型:EventBus、DataSourceId、LLM trait、能力探测 |
| neomind-api | Axum Web 服务器,HTTP / WebSocket / SSE handler,Swagger 在 /api/docs |
| neomind-agent | AI Agent:LLM 后端、工具调用、记忆系统、技能系统、调度器 |
| neomind-devices | 设备管理:MQTT / Webhook 适配器、设备注册、命令队列、草稿审批 |
| neomind-storage | redb 嵌入式存储:所有 *.redb 表的 schema 与访问层 |
| neomind-messages | 消息通知:7 个渠道(webhook/email/telegram/wecom/dingtalk/slack/feishu)+ 应用内 |
| neomind-rules | JSON 规则引擎:解析、执行、事件触发 |
| neomind-extension-sdk | 扩展 SDK:neomind_export! 宏、capability、ML 模型生命周期(公开 API) |
| neomind-extension-runner | 扩展进程宿主:隔离沙箱、FFI 桥、崩溃循环保护 |
| neomind-data-push | 数据推送:把遥测数据转发到外部 Webhook / MQTT |
| neomind-cli | 命令行入口(neomind 二进制) |
| neomind-cli-ops | CLI 命令实现:每个领域(device/rule/agent/...)一个模块,进程内分发 |
Tauri crate 在 workspace 外