| name | chatbi-mvp |
| description | Use when building a ChatBI (conversational BI) MVP from scratch, need to understand the 5 core capabilities (NL2SQL, multi-turn dialogue, RAG knowledge base, data visualization, intelligent attribution), or want to reference SuperSonic's architecture to guide implementation |
ChatBI MVP Architecture
Overview
Build a ChatBI system: user asks questions in natural language โ system generates SQL โ executes โ displays interactive charts with AI insights.
Architecture: NL โ S2SQL (semantic SQL / MQL) โ Physical SQL. LLM generates S2SQL using business terms (bizName), a deterministic Translator converts to physical SQL. LLM never touches physical table/column names.
Tech stack assumed: React (frontend) + Python/FastAPI (backend). Architecture is language-agnostic.
Five Core Layers
User: "ๆ่ฟ7ๅคฉๅๅๅบๆญๆพ้ๆไนๆ ท"
โ
โผ
โโ Layer 3: RAG โโโโโโโโโโโโโโโโโ Trie + Embedding recall
โ "ๆญๆพ้" โ views (metric) โ Identify schema elements
โ "ๅๅบ" โ category (dim) โ in user query
โ "ๆ่ฟ7ๅคฉ" โ DateConf{-7d} โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ
โผ
โโ Layer 1: NL โ S2SQL โ SQL โโโ 5-stage pipeline
โ MAPPING โ PARSING โ โ LLM generates S2SQL (bizName)
โ CORRECTING โ TRANSLATING โ Translator โ physical SQL
โ โ EXECUTE โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโดโโโโโโโโ
โผ โผ
โโ Layer 2 โโโโ โโ Layer 5 โโโโโโโโโโโ
โ Multi-turn โ โ Attribution โ
โ Context save โ โ LLM summary + YoY โ
โ + LLM rewriteโ โ + drill-down recs โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โโโโโโโโโฌโโโโโโโโ
โผ
โโ Layer 4: Visualization โโโโโโโ
โ Auto chart type โ ECharts โ
โ User can toggle chart/table โ
โ Drill-down โ re-query โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
File Index
This skill is split into focused files. Read in order, or jump to what you need.
Core Architecture (read first)
| File | Contents | When to read |
|---|
data-models.md | All shared POJOs: SemanticSchema, SchemaMapInfo, SemanticParseInfo, QueryResult | Always start here โ these connect every layer |
nl2sql-pipeline.md | Layer 1 in detail: 5-stage pipeline, prompt template, self-consistency, corrector chain, S2SQLโphysical translator | Core of the system |
wiring.md | How all layers connect: full request flow, plugin registration, DB tables | When you need to see the big picture |
Supporting Layers
| File | Contents | When to read |
|---|
layers-2-3-5.md | Multi-turn dialogue (Layer 2), RAG knowledge base (Layer 3), Attribution analysis (Layer 5) | After understanding Layer 1 |
visualization.md | Chart auto-classification, ECharts configs, chart type toggle, interaction patterns (Layer 4) | Frontend implementation |
Implementation Guides
| File | Contents | When to read |
|---|
data-generation.md | How to generate demo data with Faker + Pandas + SQLite, semantic model YAML, few-shot exemplars | Before you start coding |
frontend-interaction.md | Complete frontend state machine, component tree, API calls, drill-down/metric-switch/date-filter flows | Frontend implementation |
bilibili-example.md | Full end-to-end: B็ซ creator analytics, from data generation to chart display, trace one query | When you want a concrete example |
ui-design-system.md | CSS variables, color palette, typography, component recipes, shadows, ECharts theme | When building UI |
Planning
| File | Contents | When to read |
|---|
mvp-plan.md | 4-week MVP scope, SuperSonic source code reference, common pitfalls, Python+React tech stack recommendations | Project planning |
Getting Started
First time: Read files in this order:
data-models.md โ understand the data structures
nl2sql-pipeline.md โ understand the core engine
bilibili-example.md โ see a concrete example end-to-end
wiring.md โ see how everything connects
Starting to code:
5. data-generation.md โ generate your demo data
6. mvp-plan.md โ follow the 4-week plan
7. ui-design-system.md โ copy CSS variables into your project
Implementing specific layers:
layers-2-3-5.md โ for multi-turn, RAG, or attribution
visualization.md โ for charts
frontend-interaction.md โ for frontend state machine and components
Core Principles
- Semantic layer isolation: LLM generates S2SQL (bizName), NEVER physical SQL. The Translator is deterministic.
- Plugin chain architecture: Each layer is a chain of plugins registered in config, executed sequentially. Add/remove plugins without touching core code.
- Dual strategy everywhere: Rule-based (fast, deterministic) first โ LLM-based (flexible) fallback. Applies to parsing, correction, and mapping.
- Full context persistence: Save the entire
SemanticParseInfo (not just query text) after each turn. Include history SQL in multi-turn rewrite prompt.
- User can always override: Chart type auto-selected but user can toggle. Filters auto-detected but user can adjust.
Reference Implementation
SuperSonic is the reference architecture. See mvp-plan.md for a source code file map to key classes.