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 / cli-dashboard-operations

Dashboard CLI operations

Dashboard CLI operations connect a DAC project to a local web experience or to an external dashboard tool. The serve command supports interactive local work, while import and export move dashboard meaning between DAC and supported outside systems.

Operation model

Dashboard operations use the same project context as the other CLI commands. A command selects a dashboard directory, discovers the optional .bruin.yml configuration, and can target a named environment for data access. See CLI platform and command architecture for the shared command surface and Query and connection commands for data access behavior.

Project context

The dashboard directory is the source of truth for these operations. DAC discovers dashboard definitions from that directory and can also use nearby semantic models and themes when the project layout provides them. The command can take the directory as an argument or through --dir, but it does not allow both forms at once.

References: cmd/common.go• L12-18 cmd/common.go• L20-50 cmd/common.go• L73-84 pkg/…/project.go• L15-53 pkg/…/loader.go• L14-56

Command boundaries

Each operation has a clear boundary around the dashboard content it owns:

OperationSystem boundaryResult
serveDAC project to a local browserInteractive dashboard service
import metabaseMetabase to DACDAC YAML and optional semantic model files
export slidesDAC to GoogleNew Google Slides presentation
buildDAC project to static hostingPortable HTML artifact; detailed lifecycle coverage is in Project lifecycle commands

These commands are registered as top-level CLI operations. Their shared global options include configuration discovery, environment selection, and debug logging.

References: cmd/root.go• L28-62 cmd/serve.go• L13-44 cmd/import.go• L19-27 cmd/export.go• L12-19 cmd/build.go• L12-39

Local dashboard service

The serve command turns dashboard definitions into a local web service. It combines the dashboard files with a browser application so an engineer can inspect dashboards, run their data work, change files, and see the result without a separate deployment.

Development server

The development server binds to localhost:8321 by default and serves the selected project with the chosen theme. It checks the discovered dashboards before it starts, then exposes browser-facing endpoints for dashboard metadata, definitions, widget data, themes, configuration, and live-reload events.

The command also lets the caller choose the host and port, open a browser at startup, and enable a password-protected management API. It can try later ports when the requested port is busy.

References: cmd/serve.go• L13-43 cmd/serve.go• L45-78 pkg/…/server.go• L95-141 pkg/…/server.go• L144-171 pkg/…/server.go• L214-246

Dashboard data flow

The local service keeps dashboard description separate from dashboard data. The browser first learns which dashboards exist and then asks for data for a dashboard or for one widget. The service merges request filter values over dashboard defaults before it runs data work, so a local view can use both preset and user-selected values.

This diagram shows how a local dashboard request moves from a project file to browser data.

flowchart LR
    A[Dashboard YAML or TSX] --> B[Dashboard loader]
    B --> C[Validated dashboard]
    C --> D[Browser dashboard view]
    D --> E[Filter values]
    E --> F[Widget data request]
    F --> G[Query or inline data]
    G --> H[Widget results]
    H --> D

Widgets with inline data do not need a database connection. Data-backed widgets use the configured connection and can resolve either direct SQL, named queries, or semantic query definitions.

References: pkg/…/model.go• L25-45 pkg/…/model.go• L82-115 pkg/…/api.go• L70-102 pkg/…/api.go• L147-203 pkg/…/api.go• L254-345 pkg/…/api.go• L437-482

Live reload

The server watches dashboard, semantic model, and theme directories while it runs. A file create, write, or remove event clears cached query data and sends a full-reload event to connected browsers. If the watcher cannot start, the service can still run, but live reload is not available.

References: pkg/…/server.go• L214-230 pkg/…/watcher.go• L13-24 pkg/…/watcher.go• L27-55 pkg/…/watcher.go• L58-83 pkg/…/watcher.go• L115-144

Administration boundary

The optional --password flag enables management endpoints for database connections. Without a password, those endpoints are not registered. With one, login and connection changes require the configured bearer value, and changes are written back to the selected environment in the project configuration.

This feature is for local management of connection settings. It is separate from the normal dashboard and query endpoints.

References: cmd/serve.go• L36-43 pkg/…/server.go• L158-166 pkg/…/admin.go• L11-29 pkg/…/admin.go• L31-52 pkg/…/admin.go• L54-84 pkg/…/admin.go• L92-146

External dashboard exchange

The import and export commands form the exchange boundary for dashboard content. Import adapts an outside dashboard into DAC definitions, while export turns a validated DAC dashboard and its current data into a presentation artifact.

Metabase import

dac import metabase converts a Metabase dashboard into DAC YAML. It accepts either a saved dashboard API response in JSON or YAML, or a live dashboard fetched from Metabase with an API key or session token. The command can attach a DAC connection name to the result and writes to a derived file path unless the caller selects another path or stdout.

The conversion keeps the dashboard’s main user-facing structure. SQL cards become DAC data widgets, supported query-builder cards become SQL-backed widgets, and unsupported cards become visible text placeholders by default. --strict changes that last behavior to a failure, which is useful when silent gaps are not acceptable.

References: cmd/import.go• L19-87 cmd/import.go• L89-120 cmd/import.go• L163-188 pkg/…/convert.go• L74-185

Semantic import

Metabase import can also carry explicit semantic meaning into DAC. With --semantic, supported Metabase models produce DAC semantic model files and named Metabase metrics can become semantic metrics. Cards that cannot be represented in the semantic form fall back to SQL unless --semantic-strict is set.

Generated semantic files need filesystem paths. For this reason, semantic import cannot write only to stdout. The default semantic directory is the project’s sibling semantic/ directory when the dashboard output is under dashboards/.

References: cmd/import.go• L95-140 cmd/import.go• L612-620 pkg/…/convert.go• L86-128 pkg/…/convert.go• L371-430

Google Slides export

dac export slides creates a new Google Slides presentation for one named dashboard. It validates the dashboard, resolves its filters, runs the widget data work, and maps the result into a title slide plus one slide for each dashboard row. The command accepts filter overrides as a JSON object and prints the resulting presentation URL.

The export is a presentation snapshot rather than a live DAC dashboard. Metrics become formatted text, charts become images, tables become native slide tables with up to ten data rows, and text widgets are not exported as dashboard content.

Google authentication uses Application Default Credentials first, then an explicit credentials file or the standard DAC credentials location. The Google Slides and Drive APIs must be enabled for the selected cloud project.

References: cmd/export.go• L12-71 pkg/…/export.go• L36-146 pkg/…/export.go• L149-169 docs/…/export.md• L22-38

Operation handoffs

Dashboard operations hand data and definitions from one stage to another. The key handoff is whether the next system receives editable DAC source, a live local view, or a fixed external artifact.

Source and artifact roles

The following roles help set expectations when choosing a command:

RolePreferred operationOngoing link to the project
Local review and iterationserveLive; reads project files and can reload after changes
Migration into DACimport metabaseSource is copied into DAC definitions; review warnings and placeholders
Sharing a point-in-time viewexport slidesFixed presentation; later dashboard changes do not update it
Static publicationbuildFixed web artifact; no server is needed after the build

The Dashboard domain model and pipeline explains the shared dashboard lifecycle behind these handoffs. The Project import and export conversion page covers broader interoperability concerns.

References: pkg/…/server.go• L41-68 pkg/…/export.go• L46-76 pkg/…/render.go• L33-57 pkg/…/render.go• L130-178

Change checklist

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

  • Changes to project path discovery must stay aligned with --dir, default import output paths, semantic file placement, and the directories watched by serve.
  • Changes to dashboard or widget query resolution must be checked against both local server requests and Google Slides export because both use the same widget-job contract.
  • Changes to Metabase conversion rules must keep strict mode, placeholder reporting, semantic fallback, and generated file output consistent.
  • Changes to server routes or admin protection must remain compatible with the browser client and with the promise that admin endpoints are absent unless a password is configured.
  • Changes to exported widget support must update the expectations for the external presentation, especially for charts, tables, and text content.

Important failure modes

TriggerConsequenceGuard
Dashboard definitions fail validation before serve startsThe local service does not startValidate dashboard files before using the development server
The requested port and the next available ports are all busyserve exits without a listening addressChoose a free port or change the host and port settings
The file watcher cannot access a project directoryThe service runs without live reloadCheck project paths and treat reload as an optional local feature
Metabase live import omits either the base URL or dashboard IDNo dashboard is fetchedProvide both values and one supported credential method
An imported card cannot be represented and strict mode is enabledThe import fails instead of producing a placeholderReview the card type and use non-strict mode only when placeholders are acceptable
Semantic import is combined with stdout outputThe import is rejected because semantic files need pathsSelect a filesystem output path when using --semantic
Google credentials or required APIs are unavailableSlide creation or chart image handling failsConfigure Application Default Credentials or a credentials file and enable Slides and Drive APIs

Key files

FileWhy to read it
cmd/root.goShows where dashboard-facing commands enter the top-level CLI and inherit global options.
cmd/common.goDefines project directory selection and optional configuration discovery shared by the operations.
cmd/serve.goDefines the local development command and its user-facing controls.
pkg/…/server.goDescribes the local service boundary, route groups, startup checks, and port behavior.
pkg/…/api.goShows how dashboard metadata and widget data reach the browser.
pkg/…/watcher.goExplains file change detection, cache invalidation, and reload events.
cmd/import.goDefines Metabase input modes, output choices, strictness, and semantic import controls.
pkg/…/convert.goDescribes the high-level mapping from Metabase dashboard content to DAC dashboard content.
cmd/export.goDefines the Google Slides export entry point, filter overrides, and credentials options.
pkg/…/export.goDescribes the data-to-presentation handoff and supported slide content.
cmd/build.goProvides the related static dashboard operation; lifecycle detail is covered by Project lifecycle commands.