Skip to content

Examples

Every example is in this repository: open it, then read its source on GitHub.

Playground: a chat that builds dashboards

Example What it shows Source
Playground What generative BI looks like with BI Components: recorded conversations on the left, the dashboards they produced on the right, with the HTML and the system prompt behind them. Not connected to a model; everything after the model is real: the sandboxed frame, queries answered by a DuckDB engine on the server, row-level security for the viewer, and a hostile dashboard being stopped. Served by FastAPI: a static page and two endpoints. GitHub
Playground, on Streamlit The same playground, served by Streamlit instead: the same interface as one full-page component, the same engine and the same answers. For teams already building with Streamlit. GitHub

The two are interchangeable servers for one interface: an application needs only one. See the playground's README.

In a static page

No backend: DuckDB-WASM runs in the browser. <source-table> loads the data into DuckDB-WASM and every component uses table="...".

Example What it shows Source
Sales Dashboard Local CSV, score cards, bar / line / pie charts, <data-table measures="...">, date and dimension filters, cross-filtering with click and Ctrl / Cmd + click. GitHub
GitHub Stars Data fetched from an API by a script, then pushed into a source table. GitHub
Conference-Hall Proposals A nested JSON API flattened with a SQL view. GitHub

Embedded in an application

For dashboards written by someone else (a model, another user). The dashboard lives in <iframe sandbox="allow-scripts"> with no network access, and the application around it (the Host) answers its queries.

Example What it shows Source
In a web page, with a semantic layer Semantic mode (no table attribute). Generated dashboards including custom ECharts charts and a hostile page, light / dark switch without reload, user profiles with row-level security, ALLOW_TABLE_MODE toggle, live postMessage console showing score card batching. GitHub
In a web page, with direct queries Table mode from the iframe; the Host validates each QuerySpec, compiles it to SQL, runs it in its own DuckDB-WASM and shows the executed SQL. GitHub
In a Streamlit app (basic) The same sandboxed dashboard as one element of an ordinary Streamlit page, among native widgets: a select box for the viewer, a toggle for the theme, tabs. Queries are answered in Python by DuckDB, with row-level security. Start here to add dashboards to a Streamlit app. GitHub

Files of the semantic layer example:

  • host.html, host.js: the Host (controls, HostBridge, security rules).
  • presets.js: the dashboards given to the iframe.
  • mock_semantic_backend.js: JavaScript simulation of a measures engine (query({ metrics, date_range, dimensions, ... })) on fake data: 50 optical stores over 24 months.

Run them locally

Serve the repository root with any static server:

python3 -m http.server 8000

Then open http://localhost:8000/docs/examples/sales-dashboard/, http://localhost:8000/docs/examples/sandbox-semantic-layer/host.html or http://localhost:8000/docs/examples/sandbox-direct-queries/host.html.

The Markdown examples are pages of the documentation site (mkdocs serve at the root of the repository). The playground and the Streamlit example are Python applications: see their READMEs.

data/orders.csv is generated by node docs/examples/data/generate_orders.mjs. The pages load ECharts and DuckDB-WASM from the jsDelivr CDN, so the browser needs internet access. The sandboxed iframes themselves have no network access: their Host inlines the libraries (add ?libraries=jsdelivr to the semantic layer example's URL to let the iframe load them from the CDN instead).