# Dashboards as code

> Dashboards as code means a dashboard is a versioned, schema-validated document you can read, diff, review, and roll back, instead of state saved inside a GUI.

Canonical: https://dvt.dev/glossary/dashboards-as-code/

Dashboards as code is the practice of defining a dashboard as a versioned, schema-validated document, so every query, chart, layout position, and color is a named property you can read, diff, review, and roll back like source code.

The alternative is the model most BI tools still use: a dashboard is whatever the editor saved after a series of clicks, stored in a format only the vendor's renderer understands. Nothing outside that tool can read it, so nothing can review a change to it or explain why a number moved last Tuesday.

## How it works in dvt

Every dvt dashboard is a JSON [dashboard spec](https://dvt.dev/glossary/dashboard-spec), and that spec is the only thing the renderer reads. A person editing in the browser, an agent writing over MCP, and a script calling the REST API all change the same document. Here is one complete [panel](https://dvt.dev/glossary/dashboard-panel):

```json
{ "id": "revenue-by-month", "title": "Revenue by month", "type": "chart:bar",
  "data": { "rows": [{ "month": "Jan", "revenue": 120 }, { "month": "Feb", "revenue": 150 }] },
  "spec": { "series": [{ "type": "bar", "barMaxWidth": 48 }] } }
```

Change `barMaxWidth` and the bars change; there is no hidden setting elsewhere. Because the dashboard is a document, every save becomes a [revision](https://dvt.dev/glossary/dashboard-version-history) with a diff and an author, every write is [validated](https://dvt.dev/glossary/spec-validation) against the schema first, and any version can be restored.

## Related terms

- [Dashboards as data](https://dvt.dev/glossary/dashboards-as-data)
- [BI as code](https://dvt.dev/glossary/bi-as-code)
- [Dashboard spec](https://dvt.dev/glossary/dashboard-spec)
- [Dashboard version history (revision)](https://dvt.dev/glossary/dashboard-version-history)
- [Dashboards as code, the dvt implementation](https://dvt.dev/solutions/dashboards-as-code)
