# Blueprint

> The compiled form of a bot, and the checks every deploy goes through.

Source: https://docs.buildcord.dev/reference/blueprint/

The builder stores your flows as drawings: nodes with positions and wires between handles. The runtime doesn't read drawings. When you deploy, Buildcord compiles every enabled flow into a *blueprint*, and the runtime executes that.

A blueprint is immutable and versioned. A run records the version it started on and finishes on it.

## Shape

| Field | What it holds |
| --- | --- |
| `format` | The format's own version, currently `1`. |
| `botId`, `builtAt` | Which bot, and when it was compiled. |
| `intents`, `privilegedIntents` | Gateway intents the handlers need. Privileged ones are listed apart so the builder can flag them. |
| `permissions` | Discord permissions the bot needs, for its invite link. |
| `requiresGateway` | Why the bot can't run on the commands-only plan. Empty means it can. |
| `commands` | Slash commands to register with Discord, each naming its handler. |
| `handlers` | One for each flow. |
| `embeds`, `components`, `modals` | The designs steps refer to by ID. |
| `variables`, `collections` | Declarations only. Values live in the data store. |

### Handlers and steps

A handler has an `id` that's stable across versions, a `name`, a `trigger`, an `entry` (the first step, or null) and a table of `steps`.

A trigger is one of:

| Type | Fields |
| --- | --- |
| `command` | `name` |
| `event` | `event` |
| `schedule` | `cron` |
| `component` | `action` |
| `call` | None. Only another handler's `flow.call` runs it. |

A step has:

| Field | Meaning |
| --- | --- |
| `op` | The operation, the node's kind, such as `message.reply`. |
| `args` | The settings, with defaults filled in. |
| `next` | Every way out, and the step it leads to. Null ends the path. |
| `resume` | Present when the step pauses: `component`, `modal` or `timer`. |
| `onError` | The way out taken when the step throws. |

## Pausing

A step that pauses is saved to the data store under its resume key and takes no memory. A different process can wake it minutes or days later.

- `component`: someone presses one of its buttons or picks from its menu.
- `modal`: someone submits its form.
- `timer`: its wait runs out.

## Checks

Every deploy goes through two passes.

1. **Shape.** The document is checked against the blueprint's JSON Schema.
2. **References.** Everything a schema can't see: a step that leads to one that doesn't exist, a button whose action no flow runs, a bad cron expression, a command whose handler is missing.

Each problem is an *error* or a *warning*. Errors block a deploy. Warnings are worth a look but ship. The lint notch in the builder shows them as you work.

Common warnings include a command flow that no command registers and a sub-flow that nothing calls.
