%% 系統架構圖 — 離線 AI Agent 系統
graph TB
subgraph CLIENT["🖥️ Client 端(繪圖筆電)"]
direction TB
UI["🌐 Desktop UI<br/>(Electron / Tauri / Web UI)<br/>RAM ≤ 500MB"]
AgentClient["🤖 Agent Client<br/>(Python)"]
LocalCache["💾 Local Cache<br/>(SQLite)"]
LocalSkills["🔧 Local Skills / MCP<br/>(離線可用工具)"]
LocalLLM["🧠 Local LLM (可選)<br/>(llama.cpp quantized)<br/>RAM ≤ 2GB"]
UI --> AgentClient
AgentClient --> LocalCache
AgentClient --> LocalSkills
AgentClient -.-> LocalLLM
end
subgraph NETWORK["🔒 內部網路 (TLS + API Token)"]
direction LR
REST["RESTful API<br/>HTTPS :443"]
end
subgraph SERVER["🏢 Server 端(整合部 Host)"]
direction TB
subgraph API_LAYER["API Gateway Layer"]
Gateway["⚡ FastAPI Gateway<br/>(認證/路由/Rate Limit)"]
AuthSvc["🔑 Auth Service<br/>(JWT / API Key)"]
Middleware["📋 Middleware<br/>(Logging / CORS)"]
end
subgraph SERVICE_LAYER["Service Layer"]
RAGPipeline["🔄 RAG Pipeline"]
InferenceSvc["🧠 Inference Service"]
RetrievalSvc["🔍 Retrieval Service"]
EmbeddingSvc["🧮 Embedding Service"]
DocProcessor["📄 Document Processor"]
ContextMgr["📏 Context Manager"]
SkillEngine["🔧 Skill Engine"]
Reranker["📊 Reranker<br/>(Cross-Encoder)"]
end
subgraph INFERENCE_LAYER["Inference Adapters"]
direction LR
LlamaCpp["🥇 llama.cpp<br/>(首選)"]
Foundry["🥈 Foundry Local<br/>(次選)"]
Ollama["🔄 Ollama<br/>(備援)"]
end
subgraph PROCESSING["Document Processing Pipeline"]
direction LR
PDFParser["📝 PDF Parser<br/>(PyMuPDF)"]
OCR["🔠 OCR<br/>(Tesseract)"]
Chunker["✂️ Chunking<br/>(語意/固定長度)"]
end
subgraph DATA_LAYER["Data Layer"]
PG["🐘 PostgreSQL"]
PGVector["📊 pgvector<br/>(向量索引)"]
FileStore["📁 File Storage<br/>(原始檔案)"]
end
%% API Layer 內部連結
Gateway --> AuthSvc
Gateway --> Middleware
%% Gateway to Services
Gateway --> RAGPipeline
Gateway --> DocProcessor
%% RAG Pipeline 連結
RAGPipeline --> RetrievalSvc
RAGPipeline --> InferenceSvc
RAGPipeline --> ContextMgr
RAGPipeline --> SkillEngine
RAGPipeline --> EmbeddingSvc
%% Retrieval 連結
RetrievalSvc --> Reranker
RetrievalSvc --> PGVector
%% Inference Adapters
InferenceSvc --> LlamaCpp
InferenceSvc -.-> Foundry
InferenceSvc -.-> Ollama
%% Document Processing
DocProcessor --> PDFParser
DocProcessor --> OCR
DocProcessor --> Chunker
DocProcessor --> EmbeddingSvc
PDFParser -.-> OCR
%% Data Layer
EmbeddingSvc --> PGVector
DocProcessor --> FileStore
Gateway --> PG
PG --- PGVector
end
subgraph KM["📚 KM 系統"]
KMSystem["文件存放系統"]
end
%% 跨區連結
AgentClient <-->|"REST API<br/>(HTTPS)"| REST
REST <--> Gateway
KMSystem -->|"批次匯出/匯入"| DocProcessor
%% 樣式
classDef clientStyle fill:#E8F5E9,stroke:#4CAF50,stroke-width:2px
classDef serverStyle fill:#E3F2FD,stroke:#2196F3,stroke-width:2px
classDef dataStyle fill:#FFF3E0,stroke:#FF9800,stroke-width:2px
classDef inferenceStyle fill:#F3E5F5,stroke:#9C27B0,stroke-width:2px
classDef networkStyle fill:#ECEFF1,stroke:#607D8B,stroke-width:2px
class UI,AgentClient,LocalCache,LocalSkills,LocalLLM clientStyle
class Gateway,AuthSvc,Middleware,RAGPipeline,InferenceSvc,RetrievalSvc,EmbeddingSvc,DocProcessor,ContextMgr,SkillEngine,Reranker serverStyle
class PG,PGVector,FileStore dataStyle
class LlamaCpp,Foundry,Ollama inferenceStyle
class REST networkStyle
Comments...
No Comments Yet...