Files
design-hub/readme.md
T
2026-10-27 19:23:31 +00:00

382 lines
17 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# aibi.chat 网站说明
## 一、 项目背景与定位
本项目定位为一款 全栈大数据+ AI 的实践项目。其核心目的不在于交付某商业场景的端到端产品,而在于覆盖并浅度实践当前大数据领域的大部分主流核心的技术栈。
## 二、 系统整体架构图
### 2.1 技术逻辑与生态全景图
```mermaid
flowchart TB
%% 隐藏的根节点用于整体布局排版
Root[全栈技术生态图谱] --> Lang
Root --> Collect
Root --> Compute
Root --> Storage
Root --> AI
Root --> Gov
Root --> Infra
style Root fill:none,stroke:none,color:transparent
subgraph Lang ["1. 开发语言与框架"]
direction TB
Python("Python<br/>(核心逻辑 / 爬虫 / API 交互)")
PySpark("PySpark<br/>(Structured Streaming 微批处理)")
Java("Java / Scala<br/>(Flink DataStream / CEP 风控算子)")
SQL("SQL<br/>(Flink SQL / Doris OLAP 分析)")
end
subgraph Collect ["2. 数据采集与接入层"]
direction TB
RPA("影刀 RPA<br/>(无头浏览器 / 模拟人机交互)")
Requests("Python Requests<br/>(API 轮询 / 平台接口调用)")
WSS("WebSocket<br/>(加密货币高频交易流接入)")
Flask("Flask + SSE<br/>(Webhook 中转与流式打字机输出)")
end
subgraph Compute ["3. 流批计算与调度编排"]
direction TB
Flink("Apache Flink<br/>(实时流计算 / 5分钟滑动窗口聚合)")
CEP("Flink CEP<br/>(复杂事件处理 / 巨鲸砸盘模式匹配)")
Spark("Apache Spark<br/>(分布式 ETL / ODS 贴源层清洗)")
Dolphin("Apache DolphinScheduler<br/>(VM 集群分布式高可用调度)")
Airflow("Apache Airflow<br/>(DAG 任务编排与定时触发)")
end
subgraph Storage ["4. 湖仓一体与存储底座"]
direction TB
Kafka("Apache Kafka + Zookeeper<br/>(超高吞吐消息总线 / 削峰填谷)")
Paimon("Apache Paimon<br/>(支持 Append-Only 的流批一体数据湖)")
MinIO("MinIO Distributed<br/>(S3兼容的分布式对象存储集群)")
Doris("Apache Doris<br/>(毫秒级响应的极速实时数仓)")
RDBMS("MySQL / PostgreSQL<br/>(关系型存储与 Airflow/Dify 元数据库)")
end
subgraph AI ["5. AI 智能与大模型基建"]
direction TB
Dify("Dify / OpenWebUI<br/>(LLM Agent 工作流编排与对话前端)")
LLM("DeepSeek / Moonshot API<br/>(大语言模型原生推理能力)")
LocalAI("Ollama<br/>(本地开源大模型部署底座)")
VectorDB("Qdrant / Weaviate<br/>(高维向量存储与 KNN 召回)")
Infinity("Infinity (bge-m3)<br/>(本地化高性能文本 Embedding 引擎)")
end
subgraph Gov ["6. 资产治理与商业智能"]
direction TB
DataHub("DataHub (Acryl)<br/>(企业级元数据采集与血缘治理平台)")
Gitea("Gitea<br/>(代码仓库与 Markdown 智能资产说明书)")
DataEase("DataEase / SQLBot<br/>(可视化监控大屏与 Text-to-SQL 问数)")
end
subgraph Infra ["7. 部署底座与高匿网络"]
direction TB
Docker("WSL 2 / Docker Compose<br/>(本地高密度算力容器化隔离)")
VM("VM 虚拟机集群 (ub1/ub2/ub3)<br/>(物理级高可用容灾节点)")
FRP("frp (frps/frpc)<br/>(内网穿透与外网服务暴露)")
Proxy("v2ray / mihomo<br/>(跨境专线代理 / 智能分流与海外 IP 池)")
end
%% 样式美化 (无背景填充,适配深浅色模式)
style Lang fill:none,stroke:#2196f3,stroke-width:2px,stroke-dasharray: 5 5
style Collect fill:none,stroke:#00bcd4,stroke-width:2px,stroke-dasharray: 5 5
style Compute fill:none,stroke:#4caf50,stroke-width:2px,stroke-dasharray: 5 5
style Storage fill:none,stroke:#ff9800,stroke-width:2px,stroke-dasharray: 5 5
style AI fill:none,stroke:#9c27b0,stroke-width:2px,stroke-dasharray: 5 5
style Gov fill:none,stroke:#f44336,stroke-width:2px,stroke-dasharray: 5 5
style Infra fill:none,stroke:#607d8b,stroke-width:2px,stroke-dasharray: 5 5
```
### 2.2 物理部署与集群拓扑图
```mermaid
flowchart TD
%% ================= 1. WSL 计算集群 =================
subgraph WSL_Docker ["1. WSL 2 / Docker 边缘计算集群 "]
direction TB
subgraph AI_Stack ["AI 大模型与知识库层"]
Dify["Dify / OpenWebUI<br/>(大模型编排前端)"]
LLM["Ollama / Infinity<br/>(本地大模型与向量 Embedding)"]
VectorDB[("Qdrant / Weaviate<br/>(向量数据库)")]
Dify <--> LLM & VectorDB
end
subgraph Data_Fabric ["数据资产治理与 BI 展现层"]
DataHub["DataHub<br/>(元数据治理平台)"]
DataEase["DataEase / PowerBI / SQLBot<br/>(智能问数与 BI)"]
end
subgraph BigData_Base ["基础数据底座"]
Kafka["Kafka + Zookeeper<br/>(消息流总线)"]
Spark["Spark 集群<br/>(Master / Worker)"]
RDBMS[("MySQL<br/>(关系型数据库群)")]
end
end
%% ================= 2. 虚拟机高可用集群 =================
subgraph VirtualMachine_HA_Cluster ["2. VM (虚拟机) 核心算力集群 (ub1, ub2, ub3 分布式高可用)"]
direction TB
ZK["Zookeeper 集群<br/>(分布式协调与 Leader 选举)"]
Flink["Apache Flink 集群<br/>(Standalone 实时流计算)"]
MinIO[("MinIO 分布式集群<br/>(数据湖对象存储底座)")]
Dolphin["Apache DolphinScheduler<br/>(Master/Worker 任务调度编排)"]
ZK <--> Flink & Dolphin
Dolphin -.->|"任务调度执行"| Flink
Flink -.->|"流批数据落盘"| MinIO
end
%% ================= 跨集群交互 =================
Dolphin -.->|"跨集群调度"| Spark
Flink -.->|"实时消费"| Kafka
DataEase -.->|"报表查询"| RDBMS
%% 样式美化 (去除 fill 填充以自适应 Gitea 深/浅色主题,防文字泛白)
style WSL_Docker fill:none,stroke:#9c27b0,stroke-width:2px,stroke-dasharray: 5 5
style VirtualMachine_HA_Cluster fill:none,stroke:#4caf50,stroke-width:2px,stroke-dasharray: 5 5
style AI_Stack fill:none,stroke:#ff9800,stroke-width:1px
style Data_Fabric fill:none,stroke:#00bcd4,stroke-width:1px
style BigData_Base fill:none,stroke:#fbc02d,stroke-width:1px
```
### 2.3 网络路由与出入站拓扑图
```mermaid
flowchart TD
%% ================= 1. 公网入站穿透链路 =================
subgraph Inbound_Network ["1. 公网入站穿透链路 (Inbound)"]
User(("外部访问用户")) --> Domain["自定义域名 (aibi.chat)"]
Domain --> In_HK["香港云服务器<br/>(Nginx)"]
In_HK -- "FRP 内网穿透隧道" --> Local_FRPC["本地局域网 frpc"]
Local_FRPC --> Gateway["本地 API 网关 / Nginx"]
end
%% ================= 2. 专属出海与反爬链路 =================
subgraph Outbound_Network ["2. 专属出海与反爬代理链路 (Outbound)"]
DevTools(["Claude / Gemini<br/>(AI 开发终端)"]) --> V2Ray["本地 v2ray 客户端 / 网关"]
ShadowBot(["影刀 RPA 节点<br/>(社媒无头采集)"]) --> V2Ray
Jupyter(["Jupyter / Python 脚本<br/>(API 轮询抓取)"]) --> V2Ray
V2Ray -->|"透明代理 / 流量加密"| Out_Tencent["阿里云高速中转专线"]
Out_Tencent --> Out_HK["香港云服务器"]
Out_HK --> Mihomo["mihomo<br/>(核心路由分流)"]
Mihomo -->|"动态调度"| IPPool["海外高匿 IP 池 / 住宅代理"]
IPPool --> AI_APIs(("OpenAI / Anthropic<br/>原生大模型 API"))
IPPool --> TargetSites(("海外社媒 / 加密行情源"))
end
Gateway -.->|"流量分发"| Local_Services(("本地私有云集群<br/>(WSL + VM)"))
Local_Services -.->|"出站抓取请求"| Outbound_Network
%% 样式美化
style Inbound_Network fill:#e3f2fd,stroke:#2196f3,stroke-width:2px
style Outbound_Network fill:#fff8e1,stroke:#ffc107,stroke-width:2px
style Gateway fill:#eceff1,stroke:#607d8b,stroke-width:2px
```
## 三、 核心业务数据流图
### 3.1 小红书自动采集与口碑分析链路
```mermaid
flowchart TD
subgraph Client["1. 交互与编排层"]
A[用户输入: 如'华为手机口碑'] --> B[OpenWebUI 管道/界面]
B --> C[Dify 工作流]
C -->|"POST /api/dify_trigger<br>生成 task_id 与 search_query"| D[Flask 中转服务]
end
subgraph Trigger["2. 采集与调度层"]
D -->|1. 写入任务信息| E["/mnt/f/csv/xhs.csv"]
D -.->|"2. 挂起等待完成信号<br>Timeout 150s"| D_WAIT[线程队列等待]
E -->|文件监听触发| F[影刀 RPA 机器人]
F -->|无头/模拟抓取小红书| G["多维笔记数据<br>正文/点赞/收藏/评论"]
end
subgraph Pipeline["3. 实时流处理与向量存储"]
G -->|POST /report 数据上报| D
D -->|生产消息| H[(Kafka: xhs_raw_data)]
H --> I[Flink 流处理管道]
I -->|文本向量化| J[Infinity: bge-m3]
J -->|向量与 Payload 元数据| K[(Qdrant 向量库: xhs_notes)]
I -->|处理完毕触发| L["POST /flink_finish/task_id"]
L -->|唤醒队列| D_WAIT
end
subgraph Rerank["4. 粗排检索与混合重排算法"]
D_WAIT -->|3. Query 向量化| J
J -->|检索 Top 20| K
K -->|返回粗召回结果| M[重排算子]
M -->|"综合加权: alpha*向量分 + (1-alpha)*对数互动分"| N[精选 Top N 高质量笔记]
end
subgraph Synthesis["5. 研报生成与呈现"]
N -->|返回提取正文与溯源 ID| C
C -->|上下文增强 Prompt| O[DeepSeek / LLM]
O -->|"SSE 流式输出 Markdown 研报<br>竞品对比/口碑分析/追踪折叠"| B
B --> P[最终呈现在用户界面]
end
```
```mermaid
flowchart TD
%% ================= 1. 公网入站穿透链路 =================
subgraph Inbound_Network ["1. 公网入站穿透链路 (Inbound)"]
User(("外部访问用户")) --> Domain["自定义域名 (aibi.chat)"]
Domain --> In_HK["香港云服务器<br/>(Nginx)"]
In_HK -- "FRP 内网穿透隧道" --> Local_FRPC["本地局域网 frpc"]
Local_FRPC --> Gateway["本地 API 网关 / Nginx"]
end
%% ================= 2. 专属出海与反爬链路 =================
subgraph Outbound_Network ["2. 专属出海与反爬代理链路 (Outbound)"]
DevTools(["Claude / Gemini<br/>(AI 开发终端)"]) --> V2Ray["本地 v2ray 客户端 / 网关"]
ShadowBot(["影刀 RPA 节点<br/>(社媒无头采集)"]) --> V2Ray
Jupyter(["Jupyter / Python 脚本<br/>(API 轮询抓取)"]) --> V2Ray
V2Ray -->|"透明代理 / 流量加密"| Out_Tencent["阿里云高速中转专线"]
Out_Tencent --> Out_HK["香港云服务器"]
Out_HK --> Mihomo["mihomo<br/>(核心路由分流)"]
Mihomo -->|"动态调度"| IPPool["海外高匿 IP 池 / 住宅代理"]
IPPool --> AI_APIs(("OpenAI / Anthropic<br/>原生大模型 API"))
IPPool --> TargetSites(("海外社媒 / 加密行情源"))
end
Gateway -.->|"流量分发"| Local_Services(("本地私有云集群<br/>(WSL + VM)"))
Local_Services -.->|"出站抓取请求"| Outbound_Network
%% 样式美化
style Inbound_Network fill:#e3f2fd,stroke:#2196f3,stroke-width:2px
style Outbound_Network fill:#fff8e1,stroke:#ffc107,stroke-width:2px
style Gateway fill:#eceff1,stroke:#607d8b,stroke-width:2px
```
### 3.2 自动化元数据治理与标注链路
```mermaid
flowchart TD
%% 阶段 1:预处理
subgraph Phase1["1. 准备与预处理阶段"]
A([开始: 用户输入 schemas_name]) --> B[查询业务域]
B --> C["JSON转数组<br>(提取表名列表)"]
C --> D[仓库查询MD]
end
%% 阶段 2:迭代 1 (生成表描述 Markdown)
subgraph Phase2["2. 迭代一:表级文档生成与存储"]
D --> E{遍历表名数组}
E -->|获取单个表| F[元数据查询]
F --> G[数据采样]
G --> H[检索业务域知识库]
H --> I["表MD生成<br>(LLM: Moonshot)"]
I --> J["存入仓库<br>(推送至 Gitea)"]
J --> E
end
%% 阶段 3:DataHub 状态校验
subgraph Phase3["3. 标注状态校验与过滤"]
E -.->|迭代一结束| K["代码执行 <br>(检查 DataHub 标注状态)"]
end
%% 阶段 4:迭代 2 (生成资产标签并同步 DataHub)
subgraph Phase4["4. 迭代二:智能打标与同步"]
K --> L{遍历未标注表}
L -->|获取缺失标注的表| M["拉取表MD<br>(从 Gitea 读取)"]
M --> N["生成表标签<br>(LLM: Moonshot)"]
N --> O["表标签写入<br>(同步至 DataHub)"]
O --> P["生成字段标签<br>(LLM: Moonshot)"]
P --> Q["字段标签写入<br>(同步至 DataHub)"]
Q --> L
end
L -.->|迭代二结束| R([当前阶段完成])
%% 阶段 5:未来规划 (待开发)
subgraph Phase5["5. 未来扩展:数据编织与智能问数 (规划中)"]
R -.-> S{{"跨源联邦查询引擎<br>(Trino / Presto)"}}
S -.-> T{{"AI+BI 智能问数前端<br>(SQLBot / OpenWebUI)"}}
end
%% 样式美化 (当前已完成部分)
style A fill:#e1f5fe,stroke:#03a9f4,stroke-width:2px
style R fill:#e8f5e9,stroke:#4caf50,stroke-width:2px
style E fill:#fff3e0,stroke:#ff9800,stroke-width:2px
style L fill:#fff3e0,stroke:#ff9800,stroke-width:2px
%% 样式美化 (未来待开发部分 - 灰色虚线)
style Phase5 stroke-dasharray: 5 5, stroke:#9e9e9e
style S fill:#f5f5f5,stroke:#9e9e9e,stroke-dasharray: 5 5,color:#757575
style T fill:#f5f5f5,stroke:#9e9e9e,stroke-dasharray: 5 5,color:#757575
```
### 3.3 加密货币实时监控与湖仓一体链路
```mermaid
flowchart TD
%% 阶段 1:数据采集层
subgraph Ingestion ["1. 数据采集层 (Data Ingestion)"]
A["Python 定时爬虫<br/>(CoinGecko API)"] -->|"定时轮询(每60秒)"| B[(Kafka: crypto_market)]
C["Binance 交易流接入<br/>(模拟/真实 WebSocket)"] -->|高并发逐笔交易| D[(Kafka: binance_trades)]
end
%% 阶段 2:准实时 ODS 层 (Airflow + Spark)
subgraph BatchODS ["2. 准实时 ODS 层 (Spark Structured Streaming)"]
Airflow(["Airflow 任务调度<br/>(crypto_realtime_pipeline)"]) -->|触发提交作业| SparkETL["PySpark ETL 作业<br/>(spark-submit)"]
B -->|订阅大盘行情流| SparkETL
SparkETL -->|"Schema解析映射<br/>追加 etl_time 字段"| SparkJDBC["JDBC foreachBatch<br/>微批写入 (Append)"]
SparkJDBC --> MySQL[("MySQL ODS 层<br/>(crypto_db.coin_market_data)")]
end
%% 阶段 3:实时计算与湖仓一体 (Flink + Paimon)
subgraph FlinkProcessing ["3. 实时计算与数据湖层 (Stream & Lakehouse)"]
D --> E[数据反序列化与 Watermark 分配]
%% 核心业务 1 & 2:实时数仓链路
E -->|按币种 KeyBy| F{Flink CEP 风控引擎}
F -->|"规则: 价格大跌 + 巨鲸砸盘"| G["Whale Dump 预警生成"]
E -->|"5分钟滑动窗口<br/>(步长10秒)"| H["资金净流入 (Net Flow) 聚合计算"]
H --> I[定时触发 Process 排序]
I --> J["Top N 资产榜单生成"]
%% 核心业务 3:实时入湖链路
D -->|消费高频交易流| FlinkSQL["Flink SQL 作业<br/>(PaimonIngestionJob)"]
FlinkSQL -->|"Append-Only 分区写入<br/>(Checkpoint 触发提交)"| Paimon[("Apache Paimon 数据湖<br/>(底层存储: MinIO / S3)")]
end
%% 阶段 4:实时数仓层 (Doris)
subgraph DorisDW ["4. 实时数仓层 (Apache Doris)"]
G -->|"Flink Doris Sink<br/>(Stream Load)"| K[("Doris: whale_alerts<br/>巨鲸预警表")]
J -->|"Flink Doris Sink<br/>(Stream Load)"| L[("Doris: binance_topn_assets<br/>热门资产榜单表")]
MySQL -.->|后续规划: 联邦查询/同步| M[("Doris: crypto_market<br/>大盘行情表")]
end
%% 阶段 5:BI 报表层 (待开发)
subgraph BI ["5. BI 报表与可视化层"]
K -.->|秒级实时告警展示| N(["DataEase 实时监控大屏"])
L -.->|热点资产轮播| N
K -.->|多维历史风控钻取| O(["PowerBI 深度风控分析报表"])
L -.->|趋势与相关性分析| O
M -.->|宏观市场数据联动| O
Paimon -.->|海量交易明细离线探查| O
end
%% 样式美化
style A fill:#e1f5fe,stroke:#03a9f4,stroke-width:2px
style C fill:#e1f5fe,stroke:#03a9f4,stroke-width:2px
style B fill:#fff3e0,stroke:#ff9800,stroke-width:2px
style D fill:#fff3e0,stroke:#ff9800,stroke-width:2px
style Airflow fill:#f3e5f5,stroke:#ce93d8,stroke-width:2px
style SparkETL fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style SparkJDBC fill:#fff9c4,stroke:#fbc02d,stroke-width:2px
style MySQL fill:#e3f2fd,stroke:#1e88e5,stroke-width:2px
style F fill:#e8f5e9,stroke:#4caf50,stroke-width:2px
style H fill:#e8f5e9,stroke:#4caf50,stroke-width:2px
style FlinkSQL fill:#e8f5e9,stroke:#4caf50,stroke-width:2px
style Paimon fill:#e0f7fa,stroke:#00bcd4,stroke-width:2px
style K fill:#ede7f6,stroke:#673ab7,stroke-width:2px
style L fill:#ede7f6,stroke:#673ab7,stroke-width:2px
%% 规划中模块使用灰色虚线
style BI stroke-dasharray: 5 5, stroke:#9e9e9e
style N fill:#f5f5f5,stroke:#9e9e9e,stroke-dasharray: 5 5,color:#757575
style O fill:#f5f5f5,stroke:#9e9e9e,stroke-dasharray: 5 5,color:#757575
```