Skip to content
Projects

About

越界问数 Hanyue Insight|企业级金融 ChatBI、数据中台治理(血缘/SQL沙箱/脱敏)与混合 RAG 知识图谱平台 (FastAPI + React + MySQL + Milvus + MCP)

Web & App Development

How these counts are measured

11 stars3 Forks +1 in 24h

Measured star growth

in 24h
+1
in 7 days
Collecting history
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README_EN.md

Original

Hanyue Insight · 越界问数

Enterprise Financial ChatBI · Data Governance Platform (Lineage / SQL Sandbox / Masking) · Hybrid RAG & Knowledge Graph

Live Demo FastAPI React MySQL Milvus Benchmark License

简体中文 | English


Hanyue Insight Demo Showcase

Try it live right now: https://hanyue.icu/ Register a free viewer account in seconds to explore Semantic ChatBI, Financial Knowledge Graph, MySQL Data Lineage, and Governance Dashboards (0-Token FAQ fast-path enabled for public visitors).


Why Hanyue Insight?

Most open-source Text-to-SQL or RAG demos stop at a single prompt box — they hallucinate SQL joins, leak PII columns, burn LLM tokens on repeated queries, and lack enterprise governance & evaluation loops.

Hanyue Insight unifies structured financial data (MySQL 8.0 DW) and unstructured financial filings (annual reports, research PDFs, regulations) inside one production-hardened engineering workspace:

Pillar What It Solves Key Engineering Highlights
1. Semantic ChatBI (Zero-Hallucination SQL) Eliminates arbitrary LLM SQL errors & injection risks Structured Semantic Planner (Metric + Dimension + Filter) → Deterministic SQL Compiler → Read-only START TRANSACTION READ ONLY + 5s timeout + 0-Token FAQ fast-path (~67ms)
2. Financial Hybrid RAG & Knowledge Graph Combines private filings with live web context LangGraph SSE orchestration, BGE dense vectors + HyDE dual-path recall, on-demand MCP Web Search 3-way fusion + RRF + Rerank (with >=2 MCP web floor), and 0-Token 4-layer Knowledge Graph (Group → Unit → Entity → Cross-Doc Concept) with Milvus chunk drill-down
3. Data Governance & Lineage Star Map Turns black-box queries into auditable enterprise assets Interactive ECharts force graph mapping RBAC Groups → MySQL Physical Tables → Semantic Metrics, YAML metric hot-deployment & rollback, scheduled 12-case benchmark suite, and query clustering flywheel
4. Read-Only SQL Sandbox & Dynamic Masking Keeps sensitive banking PII columns safe at runtime Read-only SQL Sandbox (SELECT / WITH only) with real-time MySQL EXPLAIN Health Score (0–100), toggleable PII column masking (counterparty_name, account_no, id_card), Redis session RBAC + captcha, and audit logs

Architecture & Orchestration

1. System Architecture

flowchart LR
    U["Browser SPA<br/>React 18 + TS + ECharts 5"] -->|REST & SSE| API["FastAPI Gateway<br/>Auth / RBAC / Rate Limit"]

    subgraph CHATBI["Structured ChatBI Engine"]
        API --> PLAN["Semantic Planner<br/>0-Token FAQ + LLM Router"]
        PLAN --> COMP["Deterministic SQL Compiler"]
        COMP --> DW[("MySQL 8.0 DW<br/>Read-Only + 5s Guard")]
    end

    subgraph GOV["Enterprise Data Governance"]
        API --> GOVSVC["Governance Engine<br/>Lineage / SQL Sandbox / EXPLAIN / Masking / Scheduler"]
        GOVSVC --> GOVDB[("MySQL finance_gov<br/>Metadata + Audit + Eval")]
        API --> REDIS[("Redis 7<br/>Sessions + Captcha + Throttle")]
    end

    subgraph RAG["Financial Knowledge Hub & KG"]
        API --> BRIDGE["Knowledge Bridge<br/>SSE Stream + 0-Token KG"]
        BRIDGE --> LG["LangGraph RAG Sidecar<br/>BGE + HyDE + MCP Search + RRF + Rerank"]
        LG --> MILVUS[("Milvus<br/>Chunks + Entities")]
    end

2. LangGraph Hybrid RAG + MCP Web Search State Flow

flowchart TD
    Q["Financial Document Query (SSE)"] --> ROUTE{"Auth & Cache Router"}
    ROUTE -->|"Guest / FAQ Cache Hit"| FAQ["0-Token Instant Answer<br/>Pre-verified Citations"]
    ROUTE -->|"Admin Live Inference"| ENT["Node 1: Entity Recognition & Rewrite"]
    ENT --> PAR_V["Node 2a: BGE Dense Vector Recall<br/>(Milvus Chunks + Entities)"]
    ENT --> PAR_H["Node 2b: HyDE Hypothetical Doc Recall"]
    ENT -->|"enable_web_search = true"| PAR_M["Node 2c: MCP Live Web Search<br/>(Auto-retry with cleaned original query)"]
    PAR_V --> RRF["Node 3: Multi-way RRF Fusion"]
    PAR_H --> RRF
    PAR_M --> RRF
    RRF --> RERANK["Node 4: Cross-Encoder Rerank + MCP Floor<br/>(Guarantees >=2 relevant web docs when enabled)"]
    RERANK --> GEN["Node 5: Streamed Answer + Cited Cards<br/>with Relevance Scores & Clickable URLs"]

Reproducible Benchmarks & Guardrail Evaluation

The repository ships with a standalone golden dataset eval/golden_queries.json, runner eval/run_benchmark.py, and unit tests tests/test_security_and_compiler.py — 100% reproducible offline in <1s without external API keys or private databases (full report in eval/BENCHMARK_REPORT.md):

Suite Coverage Pass Rate Measured Latency & Engineering Outcome
Golden Financial Semantic Suite (eval/) 10 core credit/risk/wealth metrics + 2 out-of-scope clarification guards 12 / 12 (100.0%) 0.12 ms avg offline plan + dual MySQL/SQLite compile; ~67 ms live MySQL FAQ end-to-end
SQL Sandbox Security Guardrails Valid SELECT/CTE vs DROP/DELETE/UPDATE/INSERT/Multi-stmt/SLEEP/OUTFILE/LOAD_FILE/mysql.user 12 / 12 (100.0%) 100% destructive/injection queries blocked pre-execution + START TRANSACTION READ ONLY
Dynamic PII Column Masking Phone, ID Card, Bank Card, Name, Email, Account No 6 / 6 (100.0%) Zero raw PII leaks across all 6 financial field types
MySQL Governance Dialect Adapter INSERT OR IGNORE + scalar MAX(a,b) → INSERT IGNORE + GREATEST(a,b) 1 / 1 (100.0%) All 4 scheduled governance jobs execute cleanly on MySQL 8.0
Live End-to-End Regression Auth, ChatBI, 8 Governance Modules, Dual/MCP 3-way RAG, KG 41 / 41 (100.0%) MCP OFF = 5 local chunks; MCP ON = guaranteed 3 local + 2 web docs with live URLs
# 1. Run reproducible offline benchmark & regenerate eval/BENCHMARK_REPORT.md
python eval/run_benchmark.py

# 2. Run SQL guardrail, compiler & PII masking unit tests (also works with pytest)
python -m unittest discover -s tests -v

Feature Gallery

1. Semantic ChatBI Workspace (~67ms Verified Metric Query)

Semantic ChatBI Workspace

2. Financial Knowledge Graph (Milvus Entities + Cross-Doc Concepts)

Financial Knowledge Graph

3. Data Governance Lineage & Topology

Data Lineage Topology

4. Read-Only SQL Sandbox + Dynamic PII Masking + MySQL EXPLAIN

SQL Sandbox and EXPLAIN Analyzer

Quick Start (Docker Compose)

Synthetic Demo Data (One-Command Setup): Run python scripts/seed_demo_data.py to generate 29 synthetic banking tables (~3,000 privacy-safe rows) covering all 38 semantic metrics and 5 SQL Sandbox presets in backend/data/demo_finance.sqlite3 (or add --export-mysql backend/data/demo_finance_mysql.sql for MySQL 8.0).

git clone https://github.com/SwampertR/hanyue-insight.git
cd hanyue-insight
cp .env.example .env
# Edit .env with your DB passwords and OpenAI-compatible LLM credentials
docker compose up -d --build

# Create your first admin account
docker exec -it hanyue-backend python -m app.auth create-admin admin
  • Web Workspace: http://localhost:3000
  • Backend API & Swagger: http://localhost:8010/docs
  • Health Check: http://localhost:8010/health

License

Released under the MIT License.

Explore related projects

Loading…