Dashboard domain model and pipeline
DAC treats a dashboard as a declarative description of a data view. It loads that description with its project context, checks that the definition is usable, turns widget data needs into work for a query backend, and delivers the result as an interactive view, a static site, or an external export.
Dashboard lifecycle
Dashboard pipeline
The dashboard pipeline moves from authored content to a validated model and then to one or more presentation paths. The same dashboard model is reused by the local server, static build, and Google Slides export.
flowchart LR
A[Dashboard YAML or TSX] --> B[Load project context]
B --> C[Dashboard model]
C --> D[Schema and domain validation]
D --> E[Normalize and validate filters]
E --> F[Resolve filters and widget jobs]
F --> G[Execute SQL or use inline data]
G --> H[Widget result data]
H --> I[Interactive server view]
H --> J[Static dashboard]
H --> K[Google Slides export]
The definition and query stages are shared across delivery paths. Filter normalization makes request values fit the dashboard contract before templates or semantic expressions use them. The final stage chooses how to lay out the widgets and where to send the result.
References: pkg/…/model.go• L27-49 pkg/…/loader.go• L15-57 pkg/…/filter_values.go• L12-17 pkg/…/api.go• L254-345 pkg/…/render.go• L33-178 pkg/…/export.go• L46-146
Dashboard model
The Dashboard model is the common in-memory contract for all supported authoring forms. It holds identity and description data, connection and semantic-model settings, filters, named queries, notes, and an ordered set of rows. Select filters can define options from static values, SQL results, or semantic dimensions and metrics. A note is a top-level annotation definition that can be matched to dashboard rows or data points through named dimensions.
A row is a layout group. A widget is the unit that either presents data or adds page content. Data-bearing widgets can use a named query, inline SQL, semantic query fields, or static inline data. Chart, table, pivot-table, and image settings then describe how result columns become visual roles, grouped values, formatted cells, or image content; non-data widgets do not need query work. Interactive charts and tables can map result fields to dashboard filters so a user selection can provide filter input to related work. Display formats can be authored as legacy strings or structured numeric formats. Filter option metrics use the same format contract for values returned by SQL or semantic models. When a semantic metric supplies a valid display format, loading can carry that default into compatible widget encodings and table columns without replacing an explicit widget format. Table columns can form consecutive named groups with a first-column summary that controls the group state. Group metadata survives YAML, JSON, and TSX conversion, including explicit expanded or unfrozen values. A semantic plain table can request a grand total as a boolean or as an option with a display label. Tabs are a layout container whose child tabs are complete widgets. Tabs do not inherit fields from the container and cannot contain another tabs widget.
References: pkg/…/model.go• L27-195 pkg/…/model.go• L241-268 pkg/…/model.go• L369-405 pkg/…/model.go• L547-592 pkg/…/model.go• L1048-1057 pkg/…/format.go• L13-19 pkg/…/format.go• L155-257 pkg/…/validator.go• L291-405
Authoring forms
YAML provides a declarative dashboard file. A .dashboard.tsx file provides a programmatic form that can build rows, tabs, and widgets from code, use local modules, include SQL files, and run load-time queries when a query backend is available. TSX also supports widget-tab containers whose child widgets become separate tab views.
Both forms end as the same Dashboard model. TSX is evaluated into a component tree and then normalized into dashboard, row, filter, query, and widget values. The conversion preserves optional values such as explicit false settings, table-group state, structured formats, filter option metric definitions, chart encodings, and table grand-total settings. A load without a backend uses empty results so the structure can still be inspected and validated.
References: pkg/…/loader.go• L40-54 pkg/…/jsloader.go• L23-57 pkg/…/jsloader.go• L98-232 pkg/…/jsloader.go• L382-456 pkg/…/jsloader.go• L509-615 pkg/…/jsloader.go• L1009-1081 pkg/…/jsloader.go• L1103-1105 pkg/…/loader_test.go• L69-110 pkg/…/loader_test.go• L366-434 pkg/…/grandtotal_test.go• L43-50
Project context
Project discovery
DAC resolves a project from the supplied dashboard path. It identifies the dashboard directory and then looks for sibling semantic and themes directories so that a dashboard is loaded with the content that can affect its queries and presentation.
The loader reads YAML files and files that follow the .dashboard.tsx name pattern. It skips directories and hidden entries. A full load discovers all dashboards, while a name-based load can locate one dashboard and then fully load only that file.
References: pkg/…/project.go• L15-53 pkg/…/loader.go• L15-91 pkg/…/jsloader.go• L26-31 pkg/…/jsloader.go• L1103-1105
Semantic model context
Semantic models are shared project definitions that give dashboards named dimensions, metrics, segments, and relationships instead of forcing each widget to describe raw SQL. The dashboard keeps the resolved model set as context, which lets a widget, named query, or semantic filter option select a model and lets the query stage use related models when needed.
The loader keeps invalid semantic models distinct from models that are not present. A dashboard can load without using a bad model, but validation or query planning reports an error when a dashboard reference needs that model.
References: pkg/…/project.go• L10-12 pkg/…/project.go• L60-74 pkg/…/model.go• L529-553 pkg/…/semantic_query.go• L20-73 pkg/…/loader_test.go• L162-244
Definition validity
Validation contract
Validation protects the later stages from definitions that cannot produce a meaningful view. YAML first uses the versioned dashboard schema for its shape; the standalone definition check also validates each supplied semantic model before it attaches valid models to the dashboard and runs domain validation.
The domain checks cover dashboard identity and layout, widget types and required fields, query sources, inline data shape and exclusivity, filter types and date defaults, filter option sources and metric formats, semantic model references and named queries, chart encodings, table and pivot rules, image fields, and formatting settings. It also checks note IDs, note dimensions, and widget note references. Note dimensions use the supported date, date-range, number, boolean, select, or text types. A direct semantic widget uses notes from its selected model, while a named semantic query uses the query's model context and falls back to the dashboard model when that query does not name one. Tabs are checked as complete child widgets: each tab needs its own fields, tab names must be unique, and nesting is not allowed. Table groups are checked as consecutive blocks. Group state can only be set on the first column, and grouped columns cannot be hidden. Structured display formats accept a controlled set of numeric types, currency codes, decimal counts, and per-field maps. Conditional table and pivot formatting must use supported conditions and style layers. Chart-specific combinations such as dual axes, stacking, reference annotations, and heatmap color scales are checked as well. Vega-Lite definitions must use DAC-managed result data rather than embedded or remote data. Cross-filter mappings are checked against supported interactive widgets and declared filters. A dashboard set is valid only when every loaded dashboard passes.
Grand-total settings add a semantic-table gate. An enabled total must use a plain table with semantic metrics, and the semantic engine must be able to produce the related total work. SQL tables, inline-data tables, pivot tables, and tables without metrics cannot request one.
The standalone definition check reports supplied model errors in stable key order. It rejects a model whose declared name does not match its supplied name and also applies semantic-engine checks before the dashboard can use that model. Semantic filter options and named queries use the same model checks as widgets, including related model references.
References: pkg/…/format.go• L88-147 pkg/…/loader.go• L117-136 pkg/…/validator.go• L39-218 pkg/…/validator.go• L227-263 pkg/…/validator.go• L291-465 pkg/…/validator.go• L511-900 pkg/…/validator.go• L938-1204 pkg/…/validator.go• L1311-1349 schemas/…/schema.json• L1-53 pkg/…/loader_test.go• L246-364 pkg/…/loader_test.go• L469-532 pkg/…/validator_test.go• L1430-1580 pkg/…/grandtotal_test.go• L53-89
Validation gates
The local server validates discovered dashboard definitions before it starts serving them. Static build and Slides export perform the same all-dashboard validation before they execute data work, so an invalid definition fails before an artifact is presented as complete.
This gate is separate from data execution. A structurally valid dashboard can still show a query error when its connection or SQL fails at run time.
References: pkg/…/server.go• L95-141 pkg/…/render.go• L36-57 pkg/…/export.go• L47-59 pkg/…/api.go• L323-345
Data work
Widget data sources
DAC converts each data-bearing widget into a WidgetJob. The job contains the widget identity, the SQL and connection when execution is needed, or the inline data when the dashboard already carries its result.
The source choice follows a clear split:
- A semantic widget or semantic named query is compiled from a project model.
- A semantic filter option can use a model dimension and optional metric to load option values.
- A named non-semantic query supplies reusable SQL.
- Inline SQL supplies a widget-specific query.
- Inline data skips the backend and uses the declared columns and rows directly.
Connection selection falls back from a widget or named query to the dashboard connection. Metric-based widgets use the semantic job path. Non-data widgets and tabs containers produce no job; each data-bearing tab is resolved and processed as its own widget.
References: pkg/…/api.go• L17-30 pkg/…/api.go• L254-303 pkg/…/model.go• L100-123 pkg/…/model.go• L566-592 pkg/…/validator.go• L424-487 pkg/…/validator.go• L468-509 pkg/…/semantic_query.go• L156-171
Filter context
Filters provide the shared input for a dashboard run. DAC starts with filter defaults, resolves supported date expressions and date-range presets, normalizes date values and selected scalar defaults into stable request values, then validates the merged values before any query or template uses them.
The filter contract is closed by default. Unknown filter names and unexpected value shapes fail validation. Date values use YYYY-MM-DD; date ranges require ordered start and end values; numbers must be finite; text and selections must use the expected string form. A select filter can also restrict values to its declared options, while a multi-select filter accepts an array of selections. Cleared single-value inputs remain empty so templates can test for no value. Frontend echoes of YAML numbers and dates are normalized before this validation, but non-default values keep their declared type rules.
The resulting values are available to templated SQL and semantic expressions. The template context also supports the signed-in viewer identity when the runtime supplies it, while local runs use the local user-email setting when present.
References: pkg/…/model.go• L425-517 pkg/…/filter_values.go• L12-29 pkg/…/filter_values.go• L32-210 pkg/…/filter_values_test.go• L9-115 pkg/…/api.go• L169-176 pkg/…/template.go• L13-40
Semantic query compilation
Semantic work turns model-level intent into SQL. DAC renders filter values into the model expressions and query, gives the complete rendered model set to the semantic engine, and receives SQL plus any column-name mapping needed by joined dimensions. Semantic filter options use the same model selection path so their option values and metric metadata follow the dashboard's semantic contract.
This keeps dashboard-facing names stable even when the query engine changes qualified dimension names in its result. Raw SQL follows the same template step but does not pass through semantic compilation.
References: pkg/…/semantic_query.go• L21-109 pkg/…/semantic_query.go• L112-171 pkg/…/semantic.go• L12-50 pkg/…/semantic.go• L53-81 pkg/…/semantic.go• L84-176
Query execution
The query backend is the boundary between DAC and a configured data source. It returns a tabular result with column names, optional types, and positional rows. The standard backend delegates query execution to the Bruin CLI and converts its JSON response to this shared result shape.
The server, static builder, and Slides exporter execute jobs concurrently with a bounded level of parallel work. The local server adds a short-lived cache keyed by connection and query, and file changes clear that cache so a changed project does not keep stale results.
References: pkg/…/backend.go• L5-14 pkg/…/result.go• L3-21 pkg/…/bruin.go• L11-16 pkg/…/bruin.go• L42-64 pkg/…/cache.go• L11-70 pkg/…/api.go• L182-202 pkg/…/render.go• L98-122
Result contract
Each job returns a WidgetQueryResult with columns, rows, the rendered query when one ran, and an error string when that widget failed. A result error stays attached to its widget instead of hiding the status of other widgets in the same run.
The canonical widget ID uses its row and widget positions. The ID lets batch, streaming, and per-widget server requests associate result data with the correct dashboard element.
References: pkg/…/api.go• L136-145 pkg/…/api.go• L306-350 pkg/…/api.go• L353-435 pkg/…/api.go• L437-482
Delivery paths
Interactive view
The local server exposes dashboard definitions and data through HTTP. It can list dashboard summaries, return one dashboard, resolve all widget jobs for selected filters, stream results as they finish, or run one widget on demand.
The server watches dashboard, semantic, and theme directories. A change broadcasts a full-reload event and invalidates the query cache, which keeps the browser view aligned with the project files.
References: pkg/…/server.go• L144-171 pkg/…/api.go• L70-129 pkg/…/model.go• L61-65 pkg/…/validator.go• L332-381 pkg/…/watcher.go• L13-25 pkg/…/watcher.go• L58-82
Static view
The static build selects one validated dashboard and packages its definition, dashboard summaries, filter state, and widget results into a frontend payload. The result is a self-contained site that can render without a live query server.
The build also places the selected theme and its design tokens in the payload. It copies the frontend entry page and the assets that page directly references into the output directory.
References: pkg/…/render.go• L21-35 pkg/…/render.go• L83-101 pkg/…/render.go• L124-178 cmd/build.go• L12-64
External export
The Slides export uses the same load, validation, filter, job, and result stages as the other paths. It then creates a presentation with a title slide and content slides that represent dashboard rows.
Metrics, charts, tables, images, and text become slide elements. Chart data is rendered as an image for the presentation, while missing or failed widget data can fall back to a placeholder rather than stopping the whole presentation.
References: pkg/…/export.go• L36-76 pkg/…/export.go• L93-146 pkg/…/export.go• L183-228 pkg/…/export.go• L270-313 pkg/…/export.go• L316-389 cmd/export.go• L22-71
Presentation context
Themes and templates
Themes define visual tokens for dashboard presentation. DAC provides built-in light and dark themes and can load user themes from the project; a user theme can extend a built-in theme and replace selected tokens.
Templates have a wider role in the pipeline. A selected theme is sent to the frontend or build payload, while Jinja templates render SQL and semantic expressions with filter and viewer context before data work begins.
References: pkg/…/theme.go• L11-38 pkg/…/registry.go• L10-23 pkg/…/registry.go• L26-83 pkg/…/server.go• L103-129 pkg/…/api.go• L224-238 pkg/…/semantic.go• L179-225
Related pages
The domain page gives the system view. These pages cover the main parts in more detail:
| Page | Focus |
|---|---|
| Dashboard definition lifecycle | Project discovery, YAML and TSX loading, module support, validation, filters, layout, and widget encodings |
| Dashboard queries and semantic modeling | Semantic model resolution, query generation, backend access, caching, and result data |
| Dashboard rendering and export | Interactive rendering, static builds, slide output, and chart support |
| Dashboard theming and templating | Theme loading, token inheritance, and template evaluation |
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the dashboard model, the YAML schema, and the TSX-to-model conversion aligned when a definition field or widget type changes.
- Keep filter option source rules aligned across YAML and TSX decoding, semantic job resolution, structured metric formats, validation, and option-value consumers.
- Keep the standalone definition validation order aligned with dashboard schema checks, semantic-model schema checks, model-name matching, semantic-engine checks, and dashboard domain checks.
- Keep inline data rules aligned across model detection, validation, job creation, and each result consumer.
- Keep tabs-container rules aligned across YAML loading, TSX conversion, semantic post-processing, validation, and job creation. Do not add silent field inheritance.
- Keep table-group order, first-column state, and explicit false values aligned across YAML and JSON serialization, TSX conversion, validation, and table rendering.
- Keep structured display-format rules aligned across YAML and TSX loading, model-format inheritance, filter option metrics, widget validation, and frontend or export formatting.
- Keep widget source resolution aligned with semantic job creation so a new source cannot pass validation but produce no job.
- Keep grand-total options aligned across schema decoding, YAML and TSX conversion, semantic table validation, total-query planning, and table result consumers.
- Keep cross-filter field and filter mappings aligned across model decoding, widget validation, interactive result handling, and filter request construction.
- Keep filter default, normalization, and validation rules aligned with the request payload, Jinja context, and semantic query filter shapes.
- Keep date expressions and date-range presets aligned between default loading, client echoes, normalization, and validation.
- Keep semantic output-column renames aligned with widget field names for joined dimensions.
- Keep
WidgetQueryResultand canonical widget IDs stable across batch, stream, per-widget, static, and export consumers. - Keep chart, table, pivot, and image validation aligned with the renderer when a new encoding, chart mode, table rule, or data source is added.
- Keep dashboard note IDs, note dimensions, widget note references, and semantic-model note references aligned across model serialization, validation, and annotation consumers.
- Keep Vega-Lite specs bound to the DAC dataset contract so query results remain the only external data path.
- Keep theme names and token payloads aligned between the server configuration response and the static build payload.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A dashboard has no name, rows, or valid widget source | Validation stops server startup, static build, or export | Versioned schema and ValidateAll run before delivery |
| A supplied semantic model fails its schema, has a name-key mismatch, or fails semantic-engine checks | Standalone definition validation returns model errors before the dashboard can use that model | ValidateDefinition validates supplied models in stable order before attaching them to the dashboard |
| A select filter mixes model options with SQL or static values, or names a missing dimension or metric | Filter option loading cannot produce a valid choice set | Filter option validation selects one source and validates its semantic job or SQL field |
| A filter option metric uses an invalid structured format | The option value can display with an unsupported or ambiguous number style | Format decoding and validateDisplayFormat reject unknown fields, currencies, or precision values |
| A request contains an unknown filter, a wrong value shape, an invalid date range, or a non-finite number | Query and template work does not start with unsafe or ambiguous filter input | NormalizeFilterValues canonicalizes supported client echoes and ValidateFilterValues fails closed |
| Inline data has duplicate or empty columns, mismatched row lengths, or a query source | The widget cannot provide a reliable tabular result | Inline-data validation checks its shape and rejects mixed sources |
| A tabs container carries chart, query, or other child-widget fields | The definition is rejected instead of silently ignoring or inheriting those fields | Tabs validation permits only container fields and validates each child as a full widget |
| A tab has no name, shares a name with another tab, or contains another tabs widget | The tab view cannot provide a stable, unambiguous set of child views | Validation requires unique names and rejects nesting |
| A cross-filter mapping names an unknown filter, repeats a result field, or targets a date range from an unsupported chart field | User selections cannot produce a valid filter request, or the mapping can silently select the wrong input | Cross-filter validation limits widget types, filter names, and date-axis mappings |
| A grouped table column has no group, is hidden, or sets frozen or collapsed state after the first column in its block | The table cannot present a stable group summary and state | Table-group validation limits groups to consecutive plain-table columns and state to the first member |
| Group state is lost during JSON or TSX conversion | A table can change its initial state or an invalid later-column setting can appear valid | Pointer-backed state is preserved through conversion and round-trip validation checks it |
| A semantic metric supplies an invalid display format or a widget uses an invalid structured format | The view can show the wrong number style or reject a definition with unclear formatting rules | Model defaults are inherited only after format checks; authored formats are validated as strings or supported objects |
| An enabled grand total uses SQL, inline data, a pivot table, or no semantic metrics | Validation rejects the table before total work can be planned | Grand-total validation requires a plain semantic table with at least one metric and a valid total query |
| A grand-total setting has an unsupported type or a non-string label | The table definition cannot state a stable total option | Model decoding and domain validation accept only a boolean or {label} option |
| A semantic widget or named semantic query names a missing or invalid model | Job resolution or semantic compilation fails before query execution | Project loading records semantic model state and validation resolves the selected model context |
| An inline semantic tab omits its encodings | The tab can pass through loading without the fields needed by its chart | Post-processing derives encodings from the tab's own semantic dimension and metrics |
| A widget references an empty, duplicate, or unknown note ID | The annotation cannot be matched to the intended dashboard data | Validation checks dashboard notes and permits only known dashboard or selected semantic-model note IDs |
| An image widget has no source column or uses an unsupported fit mode | The widget cannot render its image content | Image validation requires a query or inline result and a valid src and fit |
| A chart uses an unsupported encoding combination, such as overlapping dual-axis fields or stacking with a second axis | The definition is rejected instead of silently producing a misleading chart | Domain validation checks chart type, axis, source, and style rules |
| A pivot table has an invalid axis, value, aggregation, or format rule | The table cannot be reshaped into a reliable grid | Pivot validation checks axis uniqueness, value aggregations, and format layers |
| A Vega-Lite spec uses remote or embedded data instead of the DAC dataset | The chart cannot use an approved widget result source | Validation requires the named dac data source and rejects external URLs and reserved datasets |
| A query backend cannot run SQL | The affected widget carries an error and has no usable rows | Backend errors are stored in WidgetQueryResult per job |
| A project file changes while cached data is present | The next view could otherwise use stale query results | The watcher invalidates the local query cache |
| A joined semantic dimension changes its output name | A widget cannot find the requested result column | Semantic compilation returns column renames for dashboard-facing names |
Key files
| File | Why to read it |
|---|---|
| pkg/…/model.go | Defines the shared dashboard, query, row, widget, filter, note, chart, table, pivot, image, tabs, grouped-column, grand-total, and data concepts |
| pkg/…/format.go | Defines structured display formats and how semantic metric defaults reach widget encodings and table columns |
| pkg/…/loader.go | Shows how dashboard files are discovered, loaded, given project context, and normalized |
| pkg/…/jsloader.go | Shows how programmatic TSX authoring becomes the shared dashboard model |
| pkg/…/project.go | Shows how dashboard, semantic, and theme directories form project context |
| pkg/…/definition_validation.go | Shows the standalone boundary for checking a dashboard with supplied raw semantic models |
| pkg/…/validator.go | Defines the domain validity gate before data work and delivery, including semantic table total rules |
| pkg/…/filter_values.go | Defines the boundary that normalizes client filter values and rejects invalid request input |
| pkg/…/loader_test.go | Demonstrates project loading, semantic encoding defaults, format inheritance, and authoring-form parity |
| pkg/…/definition_validation_test.go | Demonstrates schema-first checks, supplied model checks, stable errors, and join dependencies |
| pkg/…/validator_test.go | Summarizes the validation contract for sources, inline data, tabs, charts, tables, pivots, notes, filters, and filter option metrics |
| pkg/…/grandtotal_test.go | Demonstrates grand-total round trips, TSX and tab support, semantic-only validation, and metric dependencies |
| pkg/…/column_groups_test.go | Demonstrates grouped table-column state across YAML, JSON, TSX, tabs, and validation |
| pkg/…/filter_values_test.go | Demonstrates filter normalization and validation for dates, ranges, numbers, text, selections, and client echoes |
| pkg/…/resolved_tab_test.go | Demonstrates that tabs are standalone widgets and receive semantic encodings during post-processing |
| pkg/…/note_test.go | Shows how note dimensions and empty dimension lists remain stable across YAML and JSON forms |
| pkg/…/semantic_query.go | Maps dashboard semantic intent, including filter option intent, to a semantic query job |
| pkg/…/api.go | Connects filters and widget definitions to jobs, results, and server data APIs |
| pkg/…/semantic.go | Connects filter context and semantic models to generated SQL |
| pkg/…/render.go | Shows how validated data becomes a self-contained static dashboard |
| pkg/…/export.go | Shows how the shared dashboard pipeline becomes a Google Slides presentation |
| pkg/…/backend.go | Defines the boundary between dashboard data work and query providers |
| pkg/…/registry.go | Shows built-in theme registration and user-theme inheritance |