# ArcSync diagram syntax reference

> Paste plain Mermaid and get an editable canvas. Add metadata and it becomes ArcSync Mermaid,
> with real cloud icons, descriptions and state machines a reader can open.

HTML version of this page: https://arcsync.dev/docs/diagram-syntax

## Import a diagram

Open https://arcsync.dev/new, then paste source into the Diagram source lane or upload a `.mmd`
or `.md` file. The lane names the dialect and counts the nodes as you type. Add the source to the
queue and import it.

Any Mermaid `flowchart`, `graph`, `stateDiagram-v2` or `erDiagram` works as it is:

```mermaid
graph TD
  client[Web client]
  api[API gateway]
  db[(Orders DB)]
  client --> api --> db
```

Nodes in plain Mermaid render as generic shapes. Metadata adds icons, descriptions and more:

```arcsync
flowchart LR
  %% diagram: checkout
  %% title: Checkout service
  shopper[Shopper]@{ icon: "browser" }
  subgraph aws[Production]@{ kind: "account" }
    gw[HTTP API]@{ icon: "aws:api-gateway", description: "JWT authorizer" }
    fn[Checkout]@{ icon: "aws:lambda", props: { runtime: "nodejs22.x" } }
    sfn[Order workflow]@{ icon: "aws:step-functions" }
    orders[(Orders)]@{ icon: "aws:dynamodb" }
  end
  shopper --> gw --> fn
  fn -- "StartExecution"@{ kind: "async" } --> sfn
  sfn -- "put order"@{ kind: "data" } --> orders
```

Other Mermaid diagram types, such as sequence diagrams, are not supported.

## Blocks and titles

- A pasted source with no code fences is one block. In a file, each ` ```arcsync ` fence is a
  block. If a file has no `arcsync` fence, each ` ```mermaid ` fence is a block. Fences in other
  languages are skipped.
- **One source is one diagram**, however many blocks it holds. Several flowchart blocks each
  become a container.
- `%% diagram: <id>` names a block. Ids are lowercase letters, digits and hyphens, up to 64
  characters. Importing the same id again updates that diagram as a new version.
- `%% title: <text>` gives the diagram its title. Without an id, the id comes from the title.
  With neither, each import creates a new diagram.
- Other `%%` lines are comments.

## Nodes

```text
id                          plain node, label = id
id[Label]                   rectangle
id(Label)  id([Label])      rounded, stadium
id[(Label)]                 cylinder (databases)
id((Label))  id(((Label)))  circle, double circle
id{Label}  id{{Label}}      diamond, hexagon
id[[Label]]  id>Label]      subroutine, flag
id["Label with [brackets] or |pipes|"]
```

- Ids use letters, digits, `_`, `-` and `.`. `end` and `subgraph` cannot be ids.
- Quote a label that contains `]`, `)`, `|` or `@{`.
- A node used in an edge without being defined is created for you, with no icon.
- A node belongs to the subgraph where it first appears, so write edges after the subgraphs.

## Node metadata

Put `@{ … }` directly after a node, or after its shape:

```arcsync
fn[Checkout handler]@{
  icon: "aws:lambda",
  kind: "function",
  description: "One sentence shown on the card",
  details: "Longer text shown when the node is opened",
  props: { runtime: "nodejs22.x", retries: 3 },
  link: "https://github.com/acme/checkout",
  expands: "order-flow"
}
```

| Key | Meaning |
|-----|---------|
| `icon` | An icon id. See Icons. |
| `kind` | A short type word shown above the label, such as `saas` or `dlq`. |
| `description` | One sentence on the card. |
| `details` | A longer explanation in the side panel. |
| `props` | Facts listed in the side panel: runtimes, sizes, retention, limits. |
| `link` | An `http` or `https` URL. Other schemes are dropped. |
| `expands` | The `%% diagram:` id of a state block that opens from this node. |
| `label`, `shape` | An alternative to the bracket syntax. |

## Containers

```arcsync
subgraph vpc[10.0.0.0/16]@{ kind: "vpc", icon: "aws:vpc" }
  ...
end
```

- Close every `subgraph` with `end`. Containers take the same metadata as nodes.
- Give each a `kind`, such as `account`, `region`, `vpc` or `cluster`. The header reads
  `Kind: Label`, so leave the kind out of the label.

## Edges

```text
a --> b                  plain link
a -.-> b                 async
a ==> b                  sync
a <--> b                 both directions
a -->|text| b            labelled
a -- "text" --> b        labelled
a -- "text"@{ kind: "data" } --> b
a --> b --> c            chain
a & b --> c & d          four edges
```

The edge kinds are `sync`, `async`, `data`, `network` and `iam`.

## State machines

```arcsync
stateDiagram-v2
  %% diagram: order-flow
  state "Charge card" as Charge
  state paid <<choice>>
  [*] --> Reserve
  Reserve --> Charge
  Charge --> paid
  paid --> Fulfil: approved
  paid --> Refund: declined
  Fulfil --> [*]
  Refund --> [*]
```

A state block that a node `expands` opens from that node. One that no node expands is drawn as a
standalone node.

## Icons

Add `@{ icon: "aws:lambda" }` to a node. Common ids:

- Generic: `user`, `browser`, `mobile`, `service`, `database`, `queue`, `external`
- AWS: `aws:lambda`, `aws:api-gateway`, `aws:s3`, `aws:dynamodb`, `aws:sqs`, `aws:sns`, `aws:ecs`,
  `aws:cloudfront`, `aws:rds`, `aws:eventbridge`, `aws:step-functions`, `aws:vpc`
- Azure: `azure:functions`, `azure:app-service`, `azure:aks`, `azure:cosmos-db`, `azure:sql`,
  `azure:service-bus`
- GCP: `gcp:cloud-run`, `gcp:gke`, `gcp:pubsub`, `gcp:bigquery`, `gcp:cloud-storage`

An unknown id is a warning, not an error: the lane suggests the closest match and the node gets a
placeholder.

## Limits

- Source can be up to 200,000 characters and 2,000 nodes.
- An import counts against your stored diagrams and your hourly limit, not your monthly parses.
- An imported diagram is private to your workspace until you share it.
- `linkStyle`, `%%{init}%%`, fonts and themes are accepted and ignored.

Coding agents can write and publish diagrams through the MCP server:
https://arcsync.dev/docs/mcp
