Turn sql.md (multiple SQL blocks in markdown) into a runnable BI prototype:
- SQL parsing
- semantic inference
- DSL filter extraction (P0)
- chart recommendation
- dashboard spec generation
- backend + frontend service integration
- Skill pipeline:
skills/sql-to-bi-builder/scripts/* - Backend service:
- full mode: FastAPI + DuckDB + Polars + Pandas (
services/backend/app.py) - lite mode: stdlib HTTP fallback (
services/backend/app_lite.py)
- full mode: FastAPI + DuckDB + Polars + Pandas (
- Frontend service:
- full mode: React + Vite + ECharts (
services/frontend) - lite mode: static HTML/JS + ECharts CDN (
services/frontend-lite)
- full mode: React + Vite + ECharts (
- Test fixtures:
- SQL markdown:
testdata/sql/demo.sql.md - DuckDB init SQL:
testdata/duckdb/init.sql - Demo DB file:
testdata/duckdb/sql2bi_demo.duckdb
- SQL markdown:
Use Python 3.12 for local development and integration testing.
Recommended setup with uv:
uv python pin 3.12
uv venv --python 3.12 .venv
source .venv/bin/activate
uv pip install -r requirements-dev.txt
uv pip install -r services/backend/requirements.txtIf uv is unavailable, use built-in venv:
python3.12 -m venv .venv312
source .venv312/bin/activate
python -m pip install -r requirements-dev.txt
python -m pip install -r services/backend/requirements.txtDefault ports:
- backend:
127.0.0.1:18000 - frontend:
127.0.0.1:15173 - skill-agent (LangChain + SSE):
127.0.0.1:18100
Start:
bash services/start_backend.sh
bash services/start_frontend.sh
bash services/start_skill_agent.shBehavior:
- If backend Python deps are installed, backend runs in full mode.
- Otherwise backend falls back to lite mode automatically.
- If frontend
node_modulesexists, frontend runs React/Vite mode. - Otherwise frontend falls back to static lite mode automatically.
Run the skill pipeline (requires Python 3.12 runtime):
python3.12 skills/sql-to-bi-builder/scripts/run_pipeline.py \
--input /abs/path/sql.md \
--out /abs/path/out \
--with-servicesGenerated files:
query_catalog.jsonsemantic_catalog.json(includesdsl_filters)chart_plan.jsondashboard.json(includes page-levelglobal_filters)ui/static scaffoldservices/generated service bundle
GET /api/healthGET /api/v1/datasourcesGET /api/v1/datasources/{id}POST /api/v1/datasourcesPUT /api/v1/datasources/{id}DELETE /api/v1/datasources/{id}POST /api/v1/datasources/{id}/testPOST /api/v1/import/sql-mdwith body:{"sql_md_path": "/abs/path/to/sql.md"}
GET /api/v1/dashboard/currentGET /api/v1/filtersGET /api/v1/queries/{query_id}/data?include_filters=true&field=valueGET /api/v1/queries/{query_id}/export.csv?include_filters=true&field=valuePOST /api/v1/reports/query/{query_id}with body:{"theme":"growth-acquisition","version":"v20260311.001","filters":{"country":"CN"},"include_csv":true,"chart_png_data_url":"data:image/png;base64,..."}
Query data API now executes stored SQL against configured datasource (read-only only), and persists audit artifacts to:
audit/<session_id>/sql.mdaudit/<session_id>/sql/<query_id>.sqlaudit/<session_id>/sql_audit_report.json
Report generation API persists versioned report artifacts to:
reports/<theme>/<version>/report.mdreports/<theme>/<version>/report.jsonreports/<theme>/<version>/analysis_trace.mdreports/<theme>/<version>/evidence_index.jsonreports/<theme>/<version>/metadata.json- optional exports under
reports/<theme>/<version>/exports/andreports/<theme>/<version>/charts/
Example import:
curl -X POST http://127.0.0.1:18000/api/v1/import/sql-md \
-H 'Content-Type: application/json' \
-d '{"sql_md_path":"/Users/lyg/software/sql2bi/testdata/sql/demo.sql.md"}'Current backend integration tests cover:
sql.mdimport -> query execution -> session SQL audit files persistence- read-only SQL guard (DDL is blocked)
- CSV export + versioned report artifact persistence
- end-to-end path:
sql.md -> pipeline -> backend API -> frontend-lite DOM render
Run with Python 3.12 environment:
python -m unittest tests/integration/test_backend_audit_integration.pyFor frontend render e2e test, install JS test dependency first:
npm --prefix tests/e2e install
python -m unittest tests/integration/test_sqlmd_to_frontend_e2e.pySkill-agent stream integration test:
python -m pip install -r services/skill_agent/requirements.txt
python -m unittest tests/integration/test_skill_agent_stream.pyRun:
python -m pip install -r services/skill_agent/requirements.txt
bash services/start_skill_agent.shStream call example (text/event-stream / SSE):
curl -N -X POST "http://127.0.0.1:18100/api/v1/skills/stream" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{
"prompt":"请先构建 BI dashboard,再给出业务分析计划",
"skills":["sql-to-bi-builder","starrocks-mcp-analyst"],
"sql_md_path":"/Users/lyg/software/sql2bi/sample.sql.md"
}'Install repo hooks:
bash scripts/install-git-hooks.shHooks:
pre-commit: conflict markers, shell/python syntax, requirement pin checkspre-push: smoke pipeline run onsample.sql.md
This repo now includes a static project intro site in website/:
website/index.htmlwebsite/styles.csswebsite/main.js
Local preview:
python3 -m http.server 8080 --directory websiteThen open:
http://127.0.0.1:8080
This repo includes workflow:
.github/workflows/deploy-website-pages.yml
Behavior:
- Trigger on push to
mainwhenwebsite/**changes - Upload
website/as Pages artifact - Deploy automatically to GitHub Pages
One-time setup:
- In repository settings, open Pages.
- Set Build and deployment / Source to GitHub Actions.
- Push changes to
website/onmain(or run workflow manually via Actions tab).
- Connect your repository to Cloudflare Pages.
- Set build command as empty, output directory as
website. - Deploy and bind your domain if needed (free SSL included).