# Canvas

> Schemas, tables, columns, relationships, areas, the three views, undo and redo, auto-layout, search, issues, export and keyboard shortcuts.

Source: https://docs.architure.dev/docs/canvas

The canvas is where you design one [database](/docs/databases) of your architecture: its schemas, tables, columns, relationships and descriptions, the part your agents read when they work with its data. The same canvas runs on a draft at `https://app.architure.dev/new` and on a saved database of your organization, at **Databases**, then the database. On a saved database, the organization's sidebar starts collapsed to icons to leave the room to the diagram.

## Layout

- **Top bar**: the back arrow to all databases, the database's name and whether your changes are saved; the view (**Simple**, **Raw** or **Text**); **Collapse all tables**, **Auto-layout**, **Undo** and **Redo**; **Import**, **Export** and **Connect an agent**. On a saved database, **Connections** (the database's [connections](/docs/database-connections) and the [schema sync](/docs/schema-sync); not for viewers) and **Packages** (the packages that use the database, see [Databases](/docs/databases)) close the bar, each with its count. In a draft, **Start over** and **Save** close it instead.
- **Left sidebar**: two tabs. **Tables** lists the database's schemas, each with its table count, a button that hides or shows it on the diagram, and its tables, then **New schema**, with the search box; **Issues** lists what to fix, with their count.
- **Diagram**: a toolbar at the bottom centre holds **Table** and **Area**, then **Zoom out**, the zoom level, **Zoom in** and **Fit view**. An empty database shows "This database is empty" with **Import** and **Add a table**. Drag the background to pan, scroll or pinch to zoom. <kbd>Shift</kbd> and drag selects several objects; <kbd>Cmd</kbd> or <kbd>Ctrl</kbd> and click adds an object to the selection.
- **Details panel** on the right: what you selected (a table, a column, a relationship, an area or a schema), with its description. With nothing selected, it shows the database: its numbers of tables and relationships, its **Schemas** with their table counts (**Schema** adds one), its **Name**, its **Dialect** and its **Description**, then the colours of the information types.

## Schemas

A database holds one or more schemas, such as `public` and `audit` in PostgreSQL. A new database starts with `public`. The sidebar always lists them, each with its table count, and a table's name shows its schema (`audit.events`) when the database has more than one.

- **Add one** with **New schema** in the sidebar, or **Schema** in the database's details. It is called `new_schema`: rename it in its details.
- **Put tables in it.** Select the schema, then press <kbd>T</kbd>: the new table goes into it. Otherwise a new table goes into the schema of the selected table, else into the first schema shown. Move a table with the **Schema** field of its details.
- **Hide it** with the eye button beside its name, in the sidebar or its details: its tables and the relationships that touch them leave the diagram until you show it again. Your browser remembers it for this database; your teammates keep their own view.
- **Delete it** from its details. Its tables are deleted with it, after you confirm; undo brings them back. A database keeps at least one schema: rename the last one rather than delete it.

## Tables and columns

Press <kbd>T</kbd> or choose **Table** to add a table in the middle of the view. Drag a table by its header; double-click the header to rename it. The arrow at the left of the header collapses the table to its header.

The table's details hold its name, its schema, its description, its columns and its indexes. Add a column with **Column**, reorder columns with their up and down arrows, and select one to edit it. A column has:

- a **name** and a **type**. The type picker shows your organization's [column definitions](/docs/column-definitions) first, then the data types of the database's dialect; type any other type and choose **Use** to keep it as written;
- **Nullable**, **Primary key**, **Unique** and **Auto-increment**. A composite primary key is several columns marked as primary key, in column order;
- a **Default value**, written as SQL (`0`, `'draft'`, `now()`);
- an **Information type** ([information types](/docs/information-types)), the colour band at the left of the column;
- a **Description**.

A column linked to a column definition shows a chain icon and takes its type, values, information type and description from the definition. **Unlink and keep the type** gives the column back its own type.

The table's indexes are listed in its details. Add or change them in the [text view](/docs/text-format#indexes), or let an agent do it.

## Relationships

- **Between columns.** Drag from the handle at the edge of one column to another column. This is a foreign key: the column that is not a primary key references the one that is, whichever way you drag. Its details hold its **Cardinality**, **On delete** and **On update** (no action, restrict, cascade, set null, set default) and its **Constraint name** (left empty, the database names the constraint when you run the exported SQL).
- **Between tables.** Drag from one table's header to another's. The dashed line says "these tables are related" before you know which columns join them, so you can design fast. To detail it, select it, choose the **Referencing column** and the **Referenced column**, then **Detail into columns**. Until then the issues panel lists it.

Cardinalities are one to one, many to one, and many to many. Many to many exists only between tables: detail it with a link table that holds a foreign key to each side. A composite foreign key is several column relationships that share one constraint name, written in the [text view](/docs/text-format#references) or imported.

## Areas

Press <kbd>A</kbd> or choose **Area** to add an area: a titled, coloured rectangle that groups tables, such as "Billing" or "Catalogue". Drag it by its title and resize it by its edges. A table you drop joins the area its centre lands in (the smallest one, where areas overlap), and dragging an area moves its tables with it. Its details hold its title and colour; deleting an area keeps its tables.

Area colours: slate, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink and rose.

## Views

| View | Key | Shows |
| --- | --- | --- |
| Simple | <kbd>1</kbd> | Column names and a `NULL` or `NOT NULL` mark |
| Raw | <kbd>2</kbd> | Column names and data types, with `PK` (primary key), `FK` (foreign key) and `UQ` (unique) badges |
| Text | <kbd>3</kbd> | The whole database in the [text format](/docs/text-format), in a code editor |

In both diagram views, each column shows its information type's colour band, and a primary key column is in bold. When you zoom far out, the columns turn into bars without text.

In the text view, edit the text, then choose **Apply** or press <kbd>Cmd</kbd> + <kbd>S</kbd> (<kbd>Ctrl</kbd> + <kbd>S</kbd> on Windows and Linux). **Discard** drops your edit. Errors are marked at their line and nothing changes until the text applies. Renaming in the text view deletes the object and creates a new one, which loses a table's position and description: rename on the canvas to keep them.

**Collapse all tables** shows every table as its header only, with relationships drawn between the headers; **Expand all tables** brings the columns back.

## Descriptions

Select a schema, a table, a column or a relationship, or nothing for the database, to write its description in the details panel. The editor keeps to what Markdown can carry: headings (two levels), bold, italic, inline code, links, bulleted and numbered lists, and code blocks. Type <kbd>/</kbd> for the block menu, select text for the formatting menu, or type Markdown shortcuts such as `## ` or `- `. A column linked to a column definition shows the definition's description: edit it on the definition.

Agents read descriptions as Markdown and can write them too.

## Search and issues

Press <kbd>/</kbd> to search tables and columns by name in the **Tables** tab; <kbd>Esc</kbd> clears the search. The **Issues** tab lists errors, warnings and information about the database as you edit, the same list an agent gets from `check_database`. Choose an issue to select its object and centre the view on it. Every rule is in the [issues reference](/docs/issues).

## Auto-layout

**Auto-layout** arranges the tables from left to right along their relationships, keeps the tables of an area together, and respects each table's column order. It runs in the background on large schemas, and you can undo it like any other change.

## Undo and redo

Undo and redo cover the changes you make in this tab, up to 100 steps: edits, moves, auto-layout, the text view. An [import](/docs/import) is not in the undo history. Changes made by teammates or agents are not in your undo history either, and an undo step that would touch an object someone else deleted is dropped with a notice.

## Copy, paste and duplicate

<kbd>Cmd</kbd> + <kbd>C</kbd> copies the selected tables with their columns, their indexes and the relationships between them; <kbd>Cmd</kbd> + <kbd>V</kbd> pastes them in this tab, next to the originals, named `<table>_copy`. <kbd>Cmd</kbd> + <kbd>D</kbd> duplicates the selected tables in one step. Pasted tables keep their schema, or go into the schema you selected before pasting, and join no area.

## Export

**Export** opens three tabs:

- **PostgreSQL DDL** or **MySQL DDL**: the `CREATE` statements for the database's dialect. Column definitions with values become `CREATE TYPE ... AS ENUM` in PostgreSQL and inline `ENUM(...)` types in MySQL.
- **DBML**: for dbdiagram.io and other DBML tools, with descriptions as notes. Information types, column definition links, area colours and relationships between tables are left out.
- **Image**: **Download PNG** or **Download SVG** of the whole diagram in the current view, with its areas. Switch to the simple or raw view first.

**Copy** copies the DDL or the DBML; **Download .sql** or **Download .dbml** saves it as a file. Exporting works on read-only databases too.

## Keyboard shortcuts

On macOS use <kbd>Cmd</kbd>; on Windows and Linux use <kbd>Ctrl</kbd>. Shortcuts do not fire while you type in a field, the description editor or the text view.

| Shortcut | Action |
| --- | --- |
| <kbd>Cmd</kbd> + <kbd>Z</kbd> | Undo |
| <kbd>Shift</kbd> + <kbd>Cmd</kbd> + <kbd>Z</kbd>, or <kbd>Cmd</kbd> + <kbd>Y</kbd> | Redo |
| <kbd>Cmd</kbd> + <kbd>C</kbd> | Copy the selected tables |
| <kbd>Cmd</kbd> + <kbd>V</kbd> | Paste the copied tables |
| <kbd>Cmd</kbd> + <kbd>D</kbd> | Duplicate the selected tables |
| <kbd>Delete</kbd> or <kbd>Backspace</kbd> | Delete the selection |
| <kbd>T</kbd> | Add a table |
| <kbd>A</kbd> | Add an area |
| <kbd>/</kbd> | Search tables and columns |
| <kbd>1</kbd>, <kbd>2</kbd>, <kbd>3</kbd> | Simple, raw and text view |
| <kbd>Cmd</kbd> + <kbd>S</kbd> | Apply the text view |

## Saving, teammates and agents

A saved database is written as you edit; there is no save button. The top bar says **Saved**, **Unsaved changes**, **Saving…**, **Offline, retrying** while the connection is down, or **Not saved** when a change could not be saved (a notice says why). A draft says **Saved in this browser**.

The canvas picks up changes from teammates and agents every 3 seconds while the tab is visible, and at once when you come back to it: an agent's new table appears without a reload.

When someone else changed the database at the same moment as you, their changes are applied first and yours on top. A change of yours that no longer fits (for example, an edit to a table they deleted) is dropped, and a notice tells you.

## Connect an agent

**Connect an agent** shows the MCP server's address, a link to create an API key, and a link to [Connect your agent](/docs/connect-your-agent). In a draft, it asks you to save the database first.

## Read-only databases

A database opens read-only when you are a viewer of the organization (the top bar says **Read-only**), or when the organization has no active plan, for example after a trial that ended without payment (**Read-only: plan required**, with a **Subscribe** link; see [Billing and trial](/docs/billing)). You can still browse, search, read descriptions, check issues and export.

## What your browser remembers

The canvas position and zoom, the collapsed tables, the hidden schemas and the view are saved per database in this browser. They are not part of the database: your teammates keep their own.
