New Dashboard¶
Scaffold a data dashboard that reads from an existing database and presents it cleanly. Defaults to Streamlit; uses Shiny for Python when you want reactive, finer-grained UI control.
Trigger: /new-dashboard
How It Works¶
- Choose framework (Streamlit or Shiny), data source (Turso, DuckDB/MotherDuck, SQLite, Parquet), and the tables/metrics to show.
- Scaffold
app.py, a cacheddata.pyaccess layer, acomponents/directory, config, and.env.example. - Wire up pre-commit — generate
.pre-commit-config.yaml(same hook set as New Project) and runpre-commit installbefore the first commit. - Isolate data access — all queries live in
data.pybehind cached functions; the UI never opens a connection inline. - Env-driven connection — local file for dev, cloud DB when the env var is set.
- Layout — title, filter sidebar, headline metrics, then honest high-density charts.
- Run/deploy note in the README; hand off shipping to Deploy Streamlit.
Cached, Isolated Data Access¶
Bad: query in the render path
Good: cached function, env-driven
Streamlit vs Shiny¶
| Choose | When |
|---|---|
| Streamlit | Fast build, simple top-to-bottom apps |
| Shiny for Python | Reactive dependencies, modules, tighter layout control |
Notes¶
- Cache aggressively but set a TTL on live data, or the dashboard silently shows stale numbers.
- Keep all SQL in
data.py— mixing queries into UI code makes the app untestable and slow. - Never commit the Turso/MotherDuck token; use secrets or environment variables.
- Defer chart styling to Data Visualization; defer deployment to Deploy Streamlit.