chore: 以本地为准,上传全部并替换 GitHub

This commit is contained in:
卡若
2026-02-03 11:36:53 +08:00
parent 1219166526
commit b404bf546e
131 changed files with 37618 additions and 3930 deletions

View File

@@ -0,0 +1,69 @@
# 神射手 - 核心架构逻辑
> 📅 从 .apm/docs/architecture.md 与代码提取 | 2026-01-31
---
## 一、四层架构
```
客户端层 → 网关层 → 服务层 → 数据层
```
### 1.1 客户端层
- 浏览器 (localhost:3001)
- 飞书机器人
- 企业微信
- API调用方
### 1.2 网关层
- **Next.js 14**: 前端 + /api/* 接口
- **卡若AI Gateway**: /feishu/*, /wecom/*
### 1.3 服务层(核心逻辑)
| 服务 | 核心函数 | 文件 |
|:---|:---|:---|
| 用户查询 | queryFullProfile, intelligentSearch | lib/mongodb.ts |
| AI对话 | parseIntent, handleQuery | app/api/ai-chat/route.ts |
| 标签统计 | $sample 采样 | app/api/tags/route.ts |
| 流量池 | user_evaluation_score 分桶 | app/api/traffic-packages/route.ts |
| 人群圈选 | getProjectPools, getPoolUsers | app/api/crowd-pools/route.ts |
### 1.4 数据层
- MongoDB localhost:27017
- 26个KR_*数据库
- 20.13亿条记录
---
## 二、数据流向
```
数据源(KR_*) → AI标签引擎 → KR.用户估值 → 流量池分层 → 导出/发送
```
### 2.1 核心集合
- **KR.用户估值**: 统一画像、user_evaluation_score
- **KR_腾讯.QQ+手机**: QQ↔手机
- **KR_微博.微博uid+手机**: UID↔手机
- **KR_存客宝.用户资产统一视图**: 流量池、unified_tags
---
## 三、关键设计决策
| 决策 | 原因 |
|:---|:---|
| $sample 采样 | 大表聚合超时,采样后按比例估算 |
| user_evaluation_score | 实际字段非rfm_composite_score |
| 按项目分类人群 | 存客宝/点了码/微博/QQ 各自结构不同 |
| 连接池复用 | getMongoClient 全局缓存 |
---
## 四、关联文档
- [系统架构.md](./系统架构.md)
- [技术选型.md](./技术选型.md)
- [../.apm/docs/architecture.md](../../.apm/docs/architecture.md)