Introducing a new way to review your PRs.

Read the announcement

bruin-data / dac

DaC is a dashboard-as-code tool. Build interactive dashboards using YAML and JSX. Built-in semantic layer. Get your agents to build standardized, reviewable dashboards.

View on GitHub

20 documents · Updated Nov 23, 2026

docs / frontend-dashboard-experience

Frontend dashboard experience

The frontend turns dashboard definitions and query results into a browsable web experience. It loads server display settings, lets a user find and open a dashboard, applies shareable filters, and presents widget data as it arrives. The same experience supports live API calls and a baked static payload for embedded or exported dashboards.

Application bootstrapping

The frontend starts at frontend/…/main.tsx and mounts the React app at the page root. App places the app under a shared query cache and selects the route model for the current delivery mode.

The frontend has three route modes:

ModeInitial destinationData source
Normal server modeDashboard listRelative /api/v1 requests
Embedded modeThe dashboard named by the host, when suppliedThe host-provided API base
Static modeThe dashboard included in the baked payloadIn-page dashboard and widget data

The server configuration selects the visual template before dashboard content renders. A template supplies page layouts and widget presentation, so the dashboard flow stays separate from visual style. See server and frontend for the boundary between the host server and this application.

Route selection

The route layer maps / to either the dashboard list or an initial dashboard redirect. It maps /d/:name to a dashboard view and keeps /admin outside the dashboard template flow. Static and embedded modes use hash-based routes because the host does not provide normal server-side route handling.

The initial redirect avoids an extra list screen when the host already knows which dashboard to show. In normal mode, a single available dashboard also redirects from the list to its view.

flowchart TD
    A[Browser or host loads app] --> B[Load display configuration]
    B --> C{Delivery mode}
    C -->|Static payload| D[Open baked dashboard]
    C -->|Embedded API| E{Initial dashboard supplied?}
    E -->|Yes| F[Open requested dashboard]
    E -->|No| G[Open dashboard list]
    C -->|Normal server| G
    G --> H[Select dashboard]
    H --> I[Open dashboard view]

References: frontend/…/main.tsx• L1-10 frontend/…/App.tsx• L12-47 frontend/…/App.tsx• L50-86

API client usage

The API client is the browser-facing gateway for configuration, dashboard definitions, raw source files, filter options, and widget data. frontend/…/client.ts chooses the relative server API or the host-supplied base and also reads the static payload when one is present.

The UI uses the DataClient contract for dashboard lists, dashboard definitions, widget data, and filter options. DataClientProvider supplies the active client to the component tree, while the default HTTP client connects that contract to the browser API. This boundary lets the data-fetching hooks use the same UI flow with different data sources.

The client presents one data contract to the rest of the UI even when data comes from different sources:

  • Static mode reads configuration, dashboard metadata, filter values, and widget results from window.__DAC_STATIC__.
  • Server mode reads configuration and dashboard metadata with JSON requests.
  • Filter controls can request option values from the server using the current dependent filters.
  • Dashboard data can arrive as one batch for export or as a stream for progressive on-screen rendering. These whole-dashboard paths remain direct API-client operations, while DataClient owns the per-widget path used by normal dashboard rendering.
  • A widget can be queried on its own when the view needs independent loading.

All non-success HTTP responses become errors for the calling hook or component. The streaming path reports each valid widget result as it arrives and supports cancellation when the dashboard or filter set changes. API details and server-side endpoints belong in local server API and live reload.

Data delivery

The dashboard view uses one request per data widget through useWidgetQuery. This gives each widget its own loading state and lets the query cache reuse results for the same dashboard, widget, filter values, and data client. The client also exposes batch and streaming paths for operations that need the whole dashboard result set or progressive rendering.

sequenceDiagram
    participant V as Dashboard view
    participant H as Data hook
    participant C as API client
    participant S as Server or static payload
    V->>H: Dashboard, widget, and filters
    H->>C: Request widget data
    alt Static mode
        C-->>H: Baked widget result
    else Server mode
        C->>S: POST widget query
        S-->>C: Widget result
        C-->>H: Widget result
    end
    H-->>V: Cached data or loading/error state

References: frontend/…/client.ts• L5-19 frontend/…/client.ts• L23-97 frontend/…/client.ts• L103-195 frontend/…/dataClient.ts• L5-44 frontend/…/DataClientProvider.tsx• L4-11 frontend/…/useWidgetQuery.ts• L10-22

Dashboard listing

The list screen gives a user a compact way to find a dashboard before opening it. It loads dashboard summaries through useDashboardList, shows loading and request errors, and passes the result to the active template's list layout.

The default list layout supports name, description, and connection search. Each result links to an encoded dashboard name and shows summary counts when the server provides them. An empty result explains that a dashboard definition must be created. If the server enables administration, the list also exposes the admin entry point.

References: frontend/…/DashboardList.tsx• L8-59 frontend/…/DashboardListLayout.tsx• L5-17 frontend/…/DashboardListLayout.tsx• L19-35 frontend/…/DashboardListLayout.tsx• L63-137

Dashboard viewing

The dashboard view combines one dashboard definition with filter controls and visual regions. It first loads the dashboard metadata. It then renders non-data widgets directly and gives data widgets the active filter set. A widget frame keeps loading, error, query, and export actions next to the widget content while the active template chooses the visual layout.

Rows without a tab stay visible. Rows with a tab are grouped by their first-seen tab name, and the selected tab controls which group is shown. Filters can be global or scoped to the selected tab. A tabs widget switches between complete child widgets and keeps each child data request separate.

Chart widgets turn query rows into the chart named by the dashboard. They support the built-in chart family and a Vega-Lite view that uses the widget result as its data. The chart surface keeps dashboard styles, labels, reference guides, and value formatting consistent across those views.

Table widgets add interactive result views without changing the query contract. A plain table can sort rows, resize columns, freeze selected columns during horizontal scrolling, copy cell values, and collapse consecutive column groups to a summary column. A pivot table reshapes the result and keeps its subtotal and total structure. Both forms can apply number display and conditional cell formatting defined by the dashboard.

Grand-total tables add a labeled, sticky total row and limit the table's scroll area to the configured height. Numeric height values that arrive as strings are treated as numbers so the height limit remains active.

Table columns can also present query values as images or compact sparklines. A sparkline is a small trend view built from structured x/y points, with a hover readout for the selected point. Image values pass through one URL policy before the table, image widget, or chart renderer displays them. Unsupported or failed images show a safe fallback instead of loading the value.

Charts and tables can also act as filter sources. A valid dimension click updates the matching dashboard filter, while a date-axis drag creates a date range when the chart supports it. The view keeps the source widget's query scope when needed, and it prevents clicks on stale or loading data from changing state.

The view also supports CSV, PNG, and PDF export. CSV export requests a complete data set and includes only data-bearing widgets with usable rows. Image and PDF export capture the rendered dashboard area. The export surface is described in frontend widgets and export.

Interactive menus and tooltips use shared popover behavior. Filter date menus, export menus, and column-group tooltips render through the dashboard root so fixed overlays are not clipped by local layout containers. The popover closes on outside clicks or Escape and follows its trigger while the page scrolls. It records trigger and popover geometry so callers can align or clamp the overlay. A top placement falls back below the trigger when there is not enough room.

References: frontend/…/DashboardView.tsx• L47-165 frontend/…/DashboardView.tsx• L168-287 frontend/…/DashboardView.tsx• L357-525 frontend/…/DashboardWidget.tsx• L39-69 frontend/…/TableWidget.tsx• L60-191 frontend/…/TableWidget.tsx• L727-879 frontend/…/TableWidget.tsx• L1088-1110 frontend/…/columnGroups.ts• L11-47 frontend/…/ColumnGroupToggle.tsx• L12-46 frontend/…/ExportMenuButton.tsx• L36-105 frontend/…/usePopover.ts• L9-62 frontend/…/DashboardLayout.tsx• L6-45 frontend/…/WidgetFrame.tsx• L19-149 frontend/…/dashboard.ts• L52-200

Cross-filter interactions

Cross-filter interactions connect widget dimensions to the dashboard filter state. A widget uses explicit field-to-filter bindings when supplied, or matches result fields to filters by name, so the same action works across supported charts and tables.

When a user selects a mark or row, the interaction adds, toggles, or restores the related filter value. The source widget can keep the pre-click scope for multi-select actions, while other widgets query with the new state. During a refresh, only safe select values are previewed from old rows; date ranges and changes that widen the result wait for fresh data.

References: frontend/…/useCrossFilter.ts• L5-79 frontend/…/useCrossFilter.ts• L82-134 frontend/…/crossFilter.ts• L39-43 frontend/…/crossFilter.ts• L91-137 frontend/…/crossFilter.ts• L217-241 frontend/…/DashboardWidget.tsx• L39-69

Data-fetching hooks

The hooks divide dashboard metadata from dashboard results. React Query manages configuration and dashboard metadata as cached queries. Widget data uses the same cache model for independent widget requests, while the dashboard data hook provides a progressive stream model for flows that need accumulated results. All query-backed hooks use the active DataClient, so the UI does not depend directly on one transport.

The shared query client treats configuration as stable for the session and keeps ordinary query results briefly fresh. Dashboard and widget queries keep previous data while a new request is pending, which prevents a filter or navigation change from making the whole view blank during the transition. Query keys include the active client identity so separate data sources cannot reuse each other's cached results.

Dashboard metadata lifecycle

useDashboardList loads dashboard summaries through the active data client. useDashboard loads one named dashboard only when a name is available and keeps the previous definition visible while a new one loads. These queries supply the list and view with metadata before result requests begin.

References: frontend/…/useDashboard.ts• L4-19 frontend/…/dataClient.ts• L5-44

Widget query lifecycle

When a data widget has a dashboard name and widget ID, useWidgetQuery requests the widget with the current filters. A change to the dashboard, widget, filters, or active data client causes React Query to obtain the matching result. The hook keeps the prior result visible while the new result loads. Static widgets such as text and divider skip data requests because their content is already part of the dashboard definition.

References: frontend/…/useWidgetQuery.ts• L5-22 frontend/…/DashboardView.tsx• L37-93

Filter option lifecycle

useFilterOptions loads options for select filters whose values come from a query or a model dimension. It tracks only the filters named by a query-based option source, so a dependent option list refreshes when its inputs change. Model-dimension options do not add control values to the dependency set because the server applies filter defaults for that source. Each option query has its own loading and error state, which lets widget data continue while a control waits for options.

Static payloads keep their supplied options and do not make option requests. A shared URL can still show a selected value before live options finish loading, so the filter control keeps selected values visible while the list is incomplete.

References: frontend/…/useFilterOptions.ts• L5-31 frontend/…/useFilterOptions.ts• L33-49 frontend/…/useFilterOptions.ts• L53-63 frontend/…/FilterBar.tsx• L440-549

Stream lifecycle

useDashboardData is the progressive result hook. It clears the old result set, opens a cancellable stream, adds each widget result to the accumulated map, and ends in either a complete or error state. A new dashboard, filter set, or live-reload event cancels the old stream before starting another one.

flowchart LR
    A[Dashboard and filters] --> B[Start or restart stream]
    B --> C[Receive widget result]
    C --> D[Add result to accumulated data]
    D --> C
    C --> E[Stream complete]
    B --> F[Request error]
    B --> G[Dashboard or filter change]
    G --> H[Abort old stream]
    H --> B

References: frontend/…/App.tsx• L17-24 frontend/…/useDashboard.ts• L4-17 frontend/…/useDashboardData.ts• L41-102 frontend/…/DashboardView.tsx• L36-73

Filter state

Filter state links the dashboard definition, the controls, the URL, and each data request. The view starts with dashboard defaults, applies valid URL values over those defaults, and then keeps user changes in local state until it projects them back into the URL.

This split gives filters two useful properties: a shared link can restore a view, and a user can change several controls without losing a change from a batched update. A URL change that did not come from the view clears local overrides so the URL becomes the source for the next filter state.

The filter bar presents controls based on filter type:

  • Date and number filters use typed input values.
  • Single-select filters accept one offered value.
  • Query-driven select filters load values separately and show a control-level loading or error state.
  • Multi-select filters preserve each selected value as a repeated URL parameter.
  • Date ranges accept configured presets or a two-month calendar range.
  • Text filters keep free-form text.

The bar can use the dashboard's column settings to place controls in a responsive grid. Tab-scoped filters appear only with their tab. URL parsing rejects invalid dates, invalid numbers, and select values that are not offered by the dashboard. Date-range presets resolve to concrete start and end dates before they reach the query layer.

References: frontend/…/DashboardView.tsx• L17-31 frontend/…/DashboardView.tsx• L199-287 frontend/…/DashboardView.tsx• L357-377 frontend/…/filterParams.ts• L10-67 frontend/…/FilterBar.tsx• L11-32 frontend/…/FilterBar.tsx• L158-177 frontend/…/FilterBar.tsx• L192-265 frontend/…/FilterBar.tsx• L274-425

YAML inspection

The source panel lets a user inspect the definition behind the rendered dashboard. Opening it requests the raw dashboard source for the current name, displays a loading or error state while the request runs, and highlights YAML or TSX according to the dashboard file type.

The highlighter loads only the language support needed for source inspection. It keeps the highlighting engine out of the main bundle and caches the shared highlighter for later openings. The panel is available in server-backed views and is hidden in static mode. It supports copying the source and resizing the side panel. Its open state and width persist while the single-page app remains loaded, but they reset on a full page refresh.

References: frontend/…/YamlPanel.tsx• L6-14 frontend/…/YamlPanel.tsx• L33-50 frontend/…/YamlPanel.tsx• L52-99 frontend/…/useShikiHighlight.ts• L4-27 frontend/…/useShikiHighlight.ts• L30-47 frontend/…/client.ts• L57-64 frontend/…/DashboardView.tsx• L39-43 frontend/…/DashboardView.tsx• L394-409 frontend/…/DashboardView.tsx• L517-525

Frontend live reload

Live reload keeps a development dashboard view aligned with dashboard files that change on the server. The frontend listens to the server event stream only when it has a live API and treats a full_reload event as a signal that cached dashboard state is no longer current.

The top-level live-reload hook invalidates React Query entries. The dashboard data hook also shares a module-level reload signal and restarts active widget streams. This combination refreshes dashboard definitions, filter option queries, and data while preserving the user's current route and filter URL.

Vite supplies the local development loop. Its development server proxies /api requests to the Go server on port 8321; a production build creates assets that the Go binary can embed. See local server API and live reload for the server event source and server and frontend for the broader runtime model.

References: frontend/…/useLiveReload.ts• L7-32 frontend/…/useDashboardData.ts• L17-39 frontend/…/useDashboardData.ts• L94-100 frontend/…/useFilterOptions.ts• L14-30 frontend/vite.config.ts• L8-16 frontend/README.md• L5-22

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the static payload shape aligned with every API client path that reads configuration, dashboard metadata, filter options, and widget results.
  • Keep route changes compatible with hash routing because embedded and static hosts do not rely on server-side route fallback.
  • Keep the DataClient contract aligned with every provider and query hook. Include client identity in query keys when multiple clients can share a query cache.
  • Keep filter URL encoding and decoding symmetric. Multi-select values must remain repeated parameters so values that contain commas stay intact.
  • Keep query keys tied to all inputs that affect widget results and dynamic filter options. Otherwise the UI can show cached data or options from the wrong request.
  • Keep live-reload handling consistent between metadata queries, filter option queries, and active data streams so a file change cannot leave one part of the view stale.
  • Keep model-dimension option sources independent from control values when the server applies defaults. Query-based option sources must still include every referenced filter dependency.
  • Keep the dashboard file type in the dashboard contract so source inspection uses the correct syntax highlighter.
  • Keep cross-filter bindings aligned with result fields and filter types. Explicit mappings must use the same names that the widget data exposes.
  • Keep source-widget scope rules aligned with cross-filter updates so a multi-select click does not lose the context that produced the click.
  • Keep tab names, tab-scoped filters, child widget IDs, and export section IDs aligned when changing tab behavior.
  • Keep table group, summary, hidden, and frozen-column rules aligned between the dashboard type contract and the rendered table. Group changes must preserve the source-column mapping used by values and formats.
  • Keep grand-total height handling compatible with both numeric and numeric-string dashboard values so the table scroll limit remains valid.
  • Keep the shared image URL policy in sync across image widgets, image table columns, and Vega-Lite image marks. A new image source must not bypass the policy.
  • Keep sparkline column encodings aligned with the accepted point shape and limits. A change to the contract must preserve both table rendering and hover values.
  • Keep popover portal targets, trigger geometry, and position updates aligned with every new fixed overlay so menus and tooltips remain attached to their trigger and visible above dashboard layout containers.

Important failure modes

TriggerConsequenceGuard
The API base or static payload mode is set incorrectlyRequests go to the wrong host or the view cannot find its baked dataResolve the delivery mode before choosing the router and API source
Two data clients share a query cache without client identity in the keyOne data source can display another source's dashboard or widget resultInclude the active data client identity in client-backed query keys
A dashboard name is not URL-encodedNames with reserved URL characters cannot be listed or opened reliablyEncode names in links and API paths
A query-driven option request omits a dependencyA select menu shows values for an older filter stateExtract the option query's referenced filters and include their active values in its query identity
A model-dimension option source incorrectly uses control values as dependenciesAn option list refreshes for unrelated control changes or sends the wrong dependency setKeep dimension-backed option dependencies empty and let the server apply filter defaults
A filter URL contains an invalid valueThe view may apply a value the dashboard does not supportValidate dates, numbers, and select options before applying URL state
A new filter or dashboard change does not enter the query keyThe widget can show results for an older filter setInclude dashboard, widget, and filter state in the data request identity
A stream remains open after navigation or a filter changeOld results can update the new view or waste server workAbort the previous stream during restart and cleanup
A live-reload event invalidates queries but not active streamsMetadata can refresh while widget results remain staleRe-fetch metadata and restart active streams from the same reload event
A cross-filter binding names a field that is not in the resultA click does not change the intended filter or highlights the wrong valuesMatch bindings to result fields and reject unusable mark values
A cross-filter click is accepted while data is stale or loadingA selection can be based on rows that no longer represent the active queryGate selections on ready data and preview only safe select dimensions
A popover is positioned in a local layout container or is not repositioned after scrollMenus and tooltips can be clipped or detach from their triggerPortal overlays to the dashboard root and update their position while open
Raw source loading failsThe dashboard remains usable but the inspection panel shows no sourceKeep the panel error state separate from dashboard rendering
A tab child uses the base widget IDData can appear in the wrong tab or an export section can be emptyKeep child query and export IDs unique to the tab name
A pivot table uses ordinary row sorting or loses its structural row orderSubtotals and totals can no longer line up with their value columnsPreserve pivot order and disable ordinary table sorting for pivot results
A column group hides its summary or loses its source orderUsers cannot read the group summary or table values map to the wrong columnKeep the first group member as the summary and derive hidden columns from the declared order
A numeric grand-total height remains a string when the scroll limit is appliedThe browser can ignore the intended table height limitNormalize numeric strings before applying the grand-total scroll limit
Query data contains a relative, same-origin, non-HTTPS, or malformed image URLThe image is not shown instead of loading untrusted content or sending credentials to the dashboard serverRoute every query image through the shared image URL policy
A sparkline value is malformed or exceeds the supported point limitsThe cell shows no usable trend dataKeep the dashboard column encoding tied to valid x/y points and the parser limits
A Vega-Lite spec asks for external dataThe chart cannot render that viewLoad chart data through the widget query and keep external data sources out of the spec

Key files

FileWhy to read it
frontend/…/App.tsxShows application providers, mode selection, routes, and initial dashboard behavior.
frontend/…/client.tsDefines the browser data boundary and the live, static, batch, option, and streaming paths.
frontend/…/dataClient.tsDefines the data source contract used by dashboard and widget hooks and isolates query caches by client.
frontend/…/DataClientProvider.tsxShows how the active data source is supplied to the frontend tree.
frontend/…/DashboardList.tsxConnects dashboard summary loading to the list experience.
frontend/…/DashboardView.tsxCoordinates dashboard metadata, tabs, filters, widgets, source inspection, and export.
frontend/…/useDashboard.tsDefines cached dashboard list and dashboard detail queries through the active data client.
frontend/…/useWidgetQuery.tsDefines per-widget data loading and cache identity.
frontend/…/useFilterOptions.tsDefines independent loading of query- and model-backed select values and their dependencies.
frontend/…/useCrossFilter.tsConnects widget selections to filter changes and protects interactions during refresh.
frontend/…/crossFilter.tsDefines field binding, selection conversion, date ranges, and safe result previews.
frontend/…/useDashboardData.tsDefines progressive data delivery and stream refresh behavior.
frontend/…/filterParams.tsDefines the typed contract between filter state and shareable URL parameters.
frontend/…/FilterBar.tsxShows filter controls, option states, date presets, and calendar ranges.
frontend/…/TableWidget.tsxShows table sorting, grouping, resizing, pivot display, frozen columns, grand totals, and cell formatting.
frontend/…/columnGroups.tsDefines how consecutive table columns become collapsible groups.
frontend/…/ColumnGroupToggle.tsxShows the accessible group expand and collapse control.
frontend/…/ExportMenuButton.tsxShows the shared export menu and its overlay behavior.
frontend/…/usePopover.tsDefines shared positioning, dismissal, scroll tracking, geometry reporting, and portal behavior for dashboard menus and tooltips.
frontend/…/SparklineCell.tsxShows compact trend cells and their point hover behavior.
frontend/…/sparkline.tsDefines the accepted sparkline data shape and safe parsing limits.
frontend/…/dashboardImage.tsDefines the shared safety rule for image URLs from query data.
frontend/…/ChartWidget.tsxShows the built-in chart views and their shared dashboard display rules.
frontend/…/VegaLiteChart.tsxShows how a Vega-Lite widget uses query data and the active theme.
frontend/…/WidgetFrame.tsxShows the common widget states and data-driven image presentation.
frontend/…/dashboard.tsDefines the dashboard, filter, widget, table, and source-file contracts used by the view.
frontend/…/YamlPanel.tsxShows how the raw dashboard source is fetched and presented.
frontend/…/useShikiHighlight.tsShows how source highlighting is loaded on demand and reused.
frontend/…/useLiveReload.tsShows how server file-change events invalidate frontend state.
frontend/…/TemplateProvider.tsxShows how the active template supplies the dashboard experience without changing its flow.
frontend/vite.config.tsShows the local API proxy and the asset base used for embedded builds.