# man0648042308-tech/bank-qa-triple-store architecture

> Architecture diagram of the GitHub repository man0648042308-tech/bank-qa-triple-store, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/man0648042308-tech/bank-qa-triple-store
- Repository: https://github.com/man0648042308-tech/bank-qa-triple-store

## Overview

这是一个教学型银行智能问答应用，另含独立的 Elasticsearch 商品复合查询练习。主流程由 CLI 或可选 FastAPI 接收问题，经问答流水线读取客户画像、分类意图、检查缓存；缓存未命中时并行检索 Elasticsearch 与 Neo4j 候选，RRF 融合后进行产品筛选和硬性资格校验，再生成并缓存回答。README 也记录了三库部署、索引初始化及练习五能力；未采样的实现只按文档说明呈现，连线证据限于已展示源码或 README。

Main entry points: [`src/day37_bank_qa/pipeline.py`](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/pipeline.py) (问答流水线), [`src/day37_bank_qa/main.py`](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/main.py) (CLI入口), [`src/day37_bank_qa/elasticsearch_retriever.py`](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/elasticsearch_retriever.py) (文本检索器), [`src/day37_bank_qa/neo4j_repository.py`](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/neo4j_repository.py) (Neo4j仓储与检索)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["应用入口"]
  node_cli["CLI入口<br/>[main.py]"]
  node_api["FastAPI接口<br/>[api.py]"]
end

subgraph group_qa["问答编排"]
  node_pipeline["问答流水线<br/>[pipeline.py]"]
  node_intent["意图分类<br/>[query_intent.py]"]
  node_cache["缓存适配<br/>[cache.py]"]
  node_rules["资格规则<br/>[business_rules.py]"]
  node_answer["回答生成"]
  node_rrf["RRF融合<br/>[rrf.py]"]
  node_models["问答数据模型<br/>[models.py]"]
end

subgraph group_data["数据与检索"]
  node_es_retriever["文本检索器"]
  node_neo_repo["Neo4j仓储与检索"]
  node_fixtures["离线示例数据<br/>[sample_data.py]"]
  node_bank_index["银行知识索引初始化"]
  node_settings["服务配置<br/>[settings.py]"]
end

subgraph group_stores["外部存储"]
  node_es[("Elasticsearch")]
  node_redis[("Redis")]
  node_neo4j[("Neo4j")]
end

subgraph group_exercise["商品搜索练习"]
  node_exercise_cli["练习命令入口<br/>[run_exercise05.py]"]
  node_query_builder["DSL查询构造<br/>[query_builder.py]"]
  node_product_search["商品搜索适配器<br/>[search_products.py]"]
  node_product_index["商品索引初始化"]
end

node_user(("提问者"))
node_llm(("可选语言模型"))

node_user -->|"提交问题"| node_cli
node_user -->|"提交请求"| node_api
node_cli -->|"调用问答"| node_pipeline
node_api -->|"调用问答"| node_pipeline
node_cli -->|"读取配置"| node_settings
node_cli -->|"组装在线仓储"| node_neo_repo
node_cli -->|"组装在线检索"| node_es_retriever
node_cli -->|"组装Redis缓存"| node_cache
node_pipeline -->|"读取画像与候选"| node_neo_repo
node_pipeline -->|"分类问题"| node_intent
node_pipeline -->|"查写答案缓存"| node_cache
node_pipeline -->|"检索文本候选"| node_es_retriever
node_pipeline -->|"融合双路结果"| node_rrf
node_pipeline -->|"校验推荐资格"| node_rules
node_pipeline -->|"生成回答"| node_answer
node_pipeline -->|"交换结构化结果"| node_models
node_es_retriever -->|"查询索引"| node_es
node_neo_repo -->|"执行图查询"| node_neo4j
node_cache -->|"读写限时键"| node_redis
node_answer -.->|"可选润色"| node_llm
node_fixtures -->|"提供离线候选"| node_es_retriever
node_fixtures -->|"提供离线画像"| node_neo_repo
node_bank_index -->|"初始化知识索引"| node_es
node_user -->|"提交搜索条件"| node_exercise_cli
node_exercise_cli -->|"执行商品搜索"| node_product_search
node_product_search -->|"构造查询DSL"| node_query_builder
node_product_search -->|"请求商品结果"| node_es
node_product_index -->|"初始化商品索引"| node_es

click node_cli "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/main.py"
click node_api "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/api.py"
click node_pipeline "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/pipeline.py"
click node_intent "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/query_intent.py"
click node_cache "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/cache.py"
click node_rules "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/business_rules.py"
click node_answer "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/answer_generator.py"
click node_rrf "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/rrf.py"
click node_models "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/models.py"
click node_es_retriever "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/elasticsearch_retriever.py"
click node_neo_repo "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/neo4j_repository.py"
click node_fixtures "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/sample_data.py"
click node_bank_index "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/prepare_bank_index.py"
click node_settings "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/settings.py"
click node_exercise_cli "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/exercise05/run_exercise05.py"
click node_query_builder "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/exercise05/query_builder.py"
click node_product_search "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/exercise05/search_products.py"
click node_product_index "https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/exercise05/prepare_product_index.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_api toneBlue
class node_pipeline,node_intent,node_cache,node_rules,node_answer,node_rrf,node_models toneAmber
class node_es_retriever,node_neo_repo,node_fixtures,node_bank_index,node_settings toneMint
class node_es,node_redis,node_neo4j toneRose
class node_exercise_cli,node_query_builder,node_product_search,node_product_index,node_user,node_llm toneIndigo
```

## Components

### 应用入口

- [CLI入口](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/main.py): `src/day37_bank_qa/main.py`
- [FastAPI接口](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/api.py): `src/day37_bank_qa/api.py`

### 问答编排

- [问答流水线](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/pipeline.py): `src/day37_bank_qa/pipeline.py`
- [意图分类](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/query_intent.py): `src/day37_bank_qa/query_intent.py`
- [缓存适配](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/cache.py): `src/day37_bank_qa/cache.py`
- [资格规则](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/business_rules.py): `src/day37_bank_qa/business_rules.py`
- [回答生成](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/answer_generator.py): `src/day37_bank_qa/answer_generator.py`
- [RRF融合](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/rrf.py): `src/day37_bank_qa/rrf.py`
- [问答数据模型](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/models.py): `src/day37_bank_qa/models.py`

### 数据与检索

- [文本检索器](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/elasticsearch_retriever.py): `src/day37_bank_qa/elasticsearch_retriever.py`
- [Neo4j仓储与检索](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/neo4j_repository.py): `src/day37_bank_qa/neo4j_repository.py`
- [离线示例数据](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/sample_data.py): `src/day37_bank_qa/sample_data.py`
- [银行知识索引初始化](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/prepare_bank_index.py): `src/day37_bank_qa/prepare_bank_index.py`
- [服务配置](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/src/day37_bank_qa/settings.py): `src/day37_bank_qa/settings.py`

### 外部存储

- **Elasticsearch**
- **Redis**
- **Neo4j**

### 商品搜索练习

- [练习命令入口](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/exercise05/run_exercise05.py): `exercise05/run_exercise05.py`
- [DSL查询构造](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/exercise05/query_builder.py): `exercise05/query_builder.py`
- [商品搜索适配器](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/exercise05/search_products.py): `exercise05/search_products.py`
- [商品索引初始化](https://github.com/man0648042308-tech/bank-qa-triple-store/blob/main/exercise05/prepare_product_index.py): `exercise05/prepare_product_index.py`

### Other components

- **提问者**
- **可选语言模型**

## Connections

- 提问者 → CLI入口: 提交问题 (evidence: `README.md`)
- 提问者 → FastAPI接口: 提交请求 (evidence: `README.md`)
- CLI入口 → 问答流水线: 调用问答 (evidence: `src/day37_bank_qa/main.py`)
- FastAPI接口 → 问答流水线: 调用问答 (evidence: `src/day37_bank_qa/api.py`)
- CLI入口 → 服务配置: 读取配置 (evidence: `src/day37_bank_qa/main.py`)
- CLI入口 → Neo4j仓储与检索: 组装在线仓储 (evidence: `src/day37_bank_qa/main.py`)
- CLI入口 → 文本检索器: 组装在线检索 (evidence: `src/day37_bank_qa/main.py`)
- CLI入口 → 缓存适配: 组装Redis缓存 (evidence: `src/day37_bank_qa/main.py`)
- 问答流水线 → Neo4j仓储与检索: 读取画像与候选 (evidence: `src/day37_bank_qa/pipeline.py`)
- 问答流水线 → 意图分类: 分类问题 (evidence: `src/day37_bank_qa/pipeline.py`)
- 问答流水线 → 缓存适配: 查写答案缓存 (evidence: `src/day37_bank_qa/pipeline.py`)
- 问答流水线 → 文本检索器: 检索文本候选 (evidence: `src/day37_bank_qa/pipeline.py`)
- 问答流水线 → RRF融合: 融合双路结果 (evidence: `src/day37_bank_qa/pipeline.py`)
- 问答流水线 → 资格规则: 校验推荐资格 (evidence: `src/day37_bank_qa/pipeline.py`)
- 问答流水线 → 回答生成: 生成回答 (evidence: `src/day37_bank_qa/pipeline.py`)
- 问答流水线 → 问答数据模型: 交换结构化结果 (evidence: `src/day37_bank_qa/pipeline.py`)
- 文本检索器 → Elasticsearch: 查询索引 (evidence: `src/day37_bank_qa/elasticsearch_retriever.py`)
- Neo4j仓储与检索 → Neo4j: 执行图查询 (evidence: `src/day37_bank_qa/neo4j_repository.py`)
- 缓存适配 → Redis: 读写限时键 (evidence: `src/day37_bank_qa/cache.py`)
- 回答生成 → 可选语言模型: 可选润色 (evidence: `src/day37_bank_qa/answer_generator.py`)
- 离线示例数据 → 文本检索器: 提供离线候选 (evidence: `src/day37_bank_qa/elasticsearch_retriever.py`)
- 离线示例数据 → Neo4j仓储与检索: 提供离线画像 (evidence: `src/day37_bank_qa/neo4j_repository.py`)
- 银行知识索引初始化 → Elasticsearch: 初始化知识索引 (evidence: `README.md`)
- 提问者 → 练习命令入口: 提交搜索条件 (evidence: `README.md`)
- 练习命令入口 → 商品搜索适配器: 执行商品搜索 (evidence: `exercise05/run_exercise05.py`)
- 商品搜索适配器 → DSL查询构造: 构造查询DSL (evidence: `exercise05/search_products.py`)
- 商品搜索适配器 → Elasticsearch: 请求商品结果 (evidence: `exercise05/search_products.py`)
- 商品索引初始化 → Elasticsearch: 初始化商品索引 (evidence: `README.md`)
