D2 ContainerDiagram Spec¶
Source: d2.container-diagram.json
This schema describes the ContainerDiagram spec for the D2 backend.
Properties¶
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Type of the diagram. Must be exactly ContainerDiagram. |
title |
string | null |
Optional diagram title. |
elements |
array[Element] |
Top-level elements. |
boundaries |
array[Boundary] |
Top-level boundaries. |
relationships |
array[D2RelationshipSchema] |
Top-level relationships. |
render_options |
D2RenderOptionsSchema |
D2-specific render options. |
backend(required) |
string |
JSON schema backend. Must be exactly d2. |
Examples
JSON source
{
"backend": "d2",
"type": "ContainerDiagram",
"title": "Web App",
"elements": [
{
"type": "Person",
"alias": "user",
"label": "User"
}
],
"boundaries": [
{
"type": "SystemBoundary",
"alias": "system",
"label": "Simple System",
"elements": [
{
"type": "Container",
"alias": "web",
"label": "Web App",
"technology": "React"
},
{
"type": "Container",
"alias": "api",
"label": "API",
"technology": "Python"
},
{
"type": "ContainerDb",
"alias": "db",
"label": "Database",
"technology": "PostgreSQL"
}
]
}
],
"relationships": [
{
"type": "REL",
"from": "user",
"to": "web",
"label": "Uses"
},
{
"type": "REL",
"from": "web",
"to": "api",
"label": "Calls"
},
{
"type": "REL",
"from": "api",
"to": "db",
"label": "Reads/Writes"
}
]
}
Rendered D2 source
direction: right
__title: ||md
# Web App
|| {
near: top-center
}
classes: {
c4_person: {
style.fill: "#f5f1ff"
style.stroke: "#6f4bb2"
style.font-color: "#211436"
}
c4_database: {
style.fill: "#edf7ff"
style.stroke: "#2d6f9f"
}
}
user: {
label: "User"
shape: c4-person
class: ["c4_person"]
}
system: {
label: "Simple System"
web: "Web App\n[React]"
api: "API\n[Python]"
db: {
label: "Database\n[PostgreSQL]"
shape: cylinder
class: ["c4_database"]
}
}
user -> system.web: "Uses"
system.web -> system.api: "Calls"
system.api -> system.db: "Reads/Writes"
Rendered image
JSON source
{
"backend": "d2",
"type": "ContainerDiagram",
"title": "Online Shop - Container Diagram",
"elements": [
{
"type": "Person",
"alias": "customer",
"label": "Customer",
"description": "Browses products and places orders.",
"properties": {
"properties": [
[
"Channel",
"Web / Mobile"
]
]
}
},
{
"type": "PersonExt",
"alias": "support_agent",
"label": "Support Agent",
"description": "Investigates customer issues from an external support tool.",
"properties": {
"properties": [
[
"Organization",
"Support Vendor"
]
]
}
},
{
"type": "SystemExt",
"alias": "payment_provider",
"label": "Payment Provider",
"description": "Processes card payments and payment webhooks."
},
{
"type": "ContainerExt",
"alias": "recommendation_api",
"label": "Recommendation API",
"description": "Returns personalized product recommendations."
},
{
"type": "ContainerDbExt",
"alias": "fraud_db",
"label": "Fraud Signals DB",
"description": "External datastore containing fraud intelligence.",
"technology": "Vendor DB"
},
{
"type": "ContainerQueueExt",
"alias": "shipping_events",
"label": "Shipping Events Topic",
"description": "External topic used by logistics partner.",
"technology": "Kafka"
}
],
"boundaries": [
{
"type": "EnterpriseBoundary",
"alias": "acme",
"label": "Acme Corp",
"description": "Enterprise boundary for internal platforms.",
"properties": {
"properties": [
[
"Region",
"EU"
],
[
"Business Unit",
"Digital Commerce"
]
]
},
"boundaries": [
{
"type": "SystemBoundary",
"alias": "shop_boundary",
"label": "Online Shop Platform",
"description": "Main system boundary for the commerce platform.",
"properties": {
"properties": [
[
"Owner",
"Commerce Team"
],
[
"Environment",
"Production"
]
]
},
"elements": [
{
"type": "Container",
"alias": "web_app",
"label": "Web Application",
"description": "Serves the storefront and checkout UI.",
"technology": "React + Next.js",
"properties": {
"properties": [
[
"Runtime",
"Node.js"
],
[
"Team",
"Storefront"
]
]
}
},
{
"type": "Container",
"alias": "backend_api",
"label": "Backend API",
"description": "Handles catalog, carts, checkout, and order APIs.",
"technology": "Python / FastAPI",
"properties": {
"properties": [
[
"Runtime",
"Python 3.12"
],
[
"Team",
"Platform"
]
]
}
},
{
"type": "ContainerDb",
"alias": "orders_db",
"label": "Orders Database",
"description": "Stores orders, payments, and status transitions.",
"technology": "PostgreSQL",
"properties": {
"properties": [
[
"Engine",
"PostgreSQL 16"
],
[
"HA",
"Primary / Replica"
]
]
}
},
{
"type": "ContainerQueue",
"alias": "order_events",
"label": "Order Events Queue",
"description": "Publishes asynchronous order lifecycle events.",
"technology": "Kafka",
"properties": {
"properties": [
[
"Retention",
"7 days"
],
[
"Format",
"JSON"
]
]
}
}
],
"boundaries": [
{
"type": "ContainerBoundary",
"alias": "checkout_boundary",
"label": "Checkout Subsystem",
"description": "Groups checkout-related containers.",
"properties": {
"properties": [
[
"Owner",
"Checkout Team"
],
[
"Criticality",
"High"
]
]
},
"elements": [
{
"type": "Container",
"alias": "checkout_api",
"label": "Checkout API",
"description": "Handles checkout and payment orchestration.",
"technology": "Python / FastAPI"
},
{
"type": "ContainerDb",
"alias": "checkout_db",
"label": "Checkout DB",
"description": "Stores checkout sessions.",
"technology": "PostgreSQL"
}
],
"relationships": [
{
"type": "REL",
"from": "checkout_api",
"to": "checkout_db",
"label": "Reads and writes",
"technology": "SQL"
}
]
}
]
}
]
}
],
"relationships": [
{
"type": "REL",
"from": "customer",
"to": "web_app",
"label": "Uses",
"technology": "HTTPS"
},
{
"type": "REL",
"from": "web_app",
"to": "backend_api",
"label": "Calls",
"technology": "HTTPS/JSON"
},
{
"type": "REL",
"from": "backend_api",
"to": "orders_db",
"label": "Reads and writes",
"technology": "SQL"
},
{
"type": "REL",
"from": "backend_api",
"to": "order_events",
"label": "Publishes order events",
"technology": "Kafka"
},
{
"type": "REL",
"from": "backend_api",
"to": "payment_provider",
"label": "Creates payment intents",
"technology": "REST API"
},
{
"type": "REL",
"from": "backend_api",
"to": "recommendation_api",
"label": "Fetches recommendations",
"technology": "REST API"
},
{
"type": "REL",
"from": "backend_api",
"to": "fraud_db",
"label": "Checks fraud signals",
"technology": "JDBC"
},
{
"type": "REL",
"from": "shipping_events",
"to": "backend_api",
"label": "Delivers shipping updates",
"technology": "Kafka"
},
{
"type": "REL",
"from": "support_agent",
"to": "backend_api",
"label": "Queries order state",
"technology": "HTTPS"
}
],
"render_options": {
"layout": "dagre",
"include_properties": true,
"bidirectional_relationships": "single_edge"
}
}
Rendered D2 source
direction: right
__title: ||md
# Online Shop - Container Diagram
|| {
near: top-center
}
classes: {
c4_person: {
style.fill: "#f5f1ff"
style.stroke: "#6f4bb2"
style.font-color: "#211436"
}
c4_external: {
style.fill: "#f7f7f7"
style.stroke: "#767676"
style.stroke-dash: "5"
}
c4_database: {
style.fill: "#edf7ff"
style.stroke: "#2d6f9f"
}
c4_queue: {
style.fill: "#fff6e5"
style.stroke: "#9b6500"
}
}
customer: ||md
## Customer
[Person]
Browses products and places orders.
| Property | Value |
| --- | --- |
| Channel | Web / Mobile |
|| {
shape: c4-person
class: ["c4_person"]
}
support_agent: ||md
## Support Agent
[Person]
Investigates customer issues from an external support tool.
| Property | Value |
| --- | --- |
| Organization | Support Vendor |
|| {
shape: c4-person
class: ["c4_person"; "c4_external"]
}
payment_provider: ||md
## Payment Provider
[Software System]
Processes card payments and payment webhooks.
|| {
shape: rectangle
class: ["c4_external"]
}
recommendation_api: ||md
## Recommendation API
[Container]
Returns personalized product recommendations.
|| {
shape: rectangle
class: ["c4_external"]
}
fraud_db: ||md
## Fraud Signals DB
[Container: Vendor DB]
External datastore containing fraud intelligence.
|| {
shape: cylinder
class: ["c4_external"; "c4_database"]
}
shipping_events: ||md
## Shipping Events Topic
[Container: Kafka]
External topic used by logistics partner.
|| {
shape: queue
class: ["c4_external"; "c4_queue"]
}
acme: {
label: ||md
## Acme Corp
[Enterprise]
Enterprise boundary for internal platforms.
||
shape: rectangle
shop_boundary: {
label: ||md
## Online Shop Platform
[System]
Main system boundary for the commerce platform.
||
shape: rectangle
web_app: ||md
## Web Application
[Container: React + Next.js]
Serves the storefront and checkout UI.
| Property | Value |
| --- | --- |
| Runtime | Node.js |
| Team | Storefront |
|| {
shape: rectangle
}
backend_api: ||md
## Backend API
[Container: Python / FastAPI]
Handles catalog, carts, checkout, and order APIs.
| Property | Value |
| --- | --- |
| Runtime | Python 3.12 |
| Team | Platform |
|| {
shape: rectangle
}
orders_db: ||md
## Orders Database
[Container: PostgreSQL]
Stores orders, payments, and status transitions.
| Property | Value |
| --- | --- |
| Engine | PostgreSQL 16 |
| HA | Primary / Replica |
|| {
shape: cylinder
class: ["c4_database"]
}
order_events: ||md
## Order Events Queue
[Container: Kafka]
Publishes asynchronous order lifecycle events.
| Property | Value |
| --- | --- |
| Retention | 7 days |
| Format | JSON |
|| {
shape: queue
class: ["c4_queue"]
}
checkout_boundary: {
label: ||md
## Checkout Subsystem
[Container]
Groups checkout-related containers.
||
shape: rectangle
checkout_api: ||md
## Checkout API
[Container: Python / FastAPI]
Handles checkout and payment orchestration.
|| {
shape: rectangle
}
checkout_db: ||md
## Checkout DB
[Container: PostgreSQL]
Stores checkout sessions.
|| {
shape: cylinder
class: ["c4_database"]
}
acme.shop_boundary.checkout_boundary.checkout_api -> acme.shop_boundary.checkout_boundary.checkout_db: "Reads and writes\n[SQL]"
}
}
}
customer -> acme.shop_boundary.web_app: "Uses\n[HTTPS]"
acme.shop_boundary.web_app -> acme.shop_boundary.backend_api: "Calls\n[HTTPS/JSON]"
acme.shop_boundary.backend_api -> acme.shop_boundary.orders_db: "Reads and writes\n[SQL]"
acme.shop_boundary.backend_api -> acme.shop_boundary.order_events: "Publishes order events\n[Kafka]"
acme.shop_boundary.backend_api -> payment_provider: "Creates payment intents\n[REST API]"
acme.shop_boundary.backend_api -> recommendation_api: "Fetches recommendations\n[REST API]"
acme.shop_boundary.backend_api -> fraud_db: "Checks fraud signals\n[JDBC]"
shipping_events -> acme.shop_boundary.backend_api: "Delivers shipping updates\n[Kafka]"
support_agent -> acme.shop_boundary.backend_api: "Queries order state\n[HTTPS]"
Rendered image
Elements¶
- D2PersonSchema
- D2PersonExtSchema
- D2SystemSchema
- D2SystemExtSchema
- D2SystemDbSchema
- D2SystemDbExtSchema
- D2SystemQueueSchema
- D2SystemQueueExtSchema
- D2ContainerSchema
- D2ContainerExtSchema
- D2ContainerDbSchema
- D2ContainerDbExtSchema
- D2ContainerQueueSchema
- D2ContainerQueueExtSchema
Boundaries¶
- D2ContainerBoundarySchema
- D2ContainerEnterpriseBoundarySchema
- D2ContainerSystemBoundarySchema
- D2ContainerGenericBoundarySchema
Relationships¶
Definitions¶
About labels and aliases
label is a display name for the element.
alias is a unique identifier used for referencing elements
in relationships and layouts.
If omitted, it is generated automatically.
You can also use label for referencing elements in relationships and layouts, but each label must be unique within the diagram.
D2ContainerBoundarySchema¶
D2 JSON schema for a container boundary.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly ContainerBoundary. |
elements |
array[Element] |
Elements may be nested arbitrarily. |
boundaries |
array[Boundary] |
Boundaries may be nested arbitrarily. |
relationships |
array[D2RelationshipSchema] |
Relationships declared inside the boundary. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2ContainerDbExtSchema¶
D2 JSON schema for an external database-like container.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly ContainerDbExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
technology |
string | null |
Optional technology. |
tooltip |
string | null |
Optional D2 tooltip. |
D2ContainerDbSchema¶
D2 JSON schema for a database-like container.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly ContainerDb. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
technology |
string | null |
Optional technology. |
tooltip |
string | null |
Optional D2 tooltip. |
D2ContainerEnterpriseBoundarySchema¶
D2 JSON schema for an enterprise boundary in container diagrams.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly EnterpriseBoundary. |
elements |
array[Element] |
Elements may be nested arbitrarily. |
boundaries |
array[Boundary] |
Boundaries may be nested arbitrarily. |
relationships |
array[D2RelationshipSchema] |
Relationships declared inside the boundary. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2ContainerExtSchema¶
D2 JSON schema for an external container.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly ContainerExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
technology |
string | null |
Optional technology. |
tooltip |
string | null |
Optional D2 tooltip. |
D2ContainerGenericBoundarySchema¶
D2 JSON schema for a generic boundary in container diagrams.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly Boundary. |
elements |
array[Element] |
Elements may be nested arbitrarily. |
boundaries |
array[Boundary] |
Boundaries may be nested arbitrarily. |
relationships |
array[D2RelationshipSchema] |
Relationships declared inside the boundary. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2ContainerQueueExtSchema¶
D2 JSON schema for an external queue-like container.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly ContainerQueueExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
technology |
string | null |
Optional technology. |
tooltip |
string | null |
Optional D2 tooltip. |
D2ContainerQueueSchema¶
D2 JSON schema for a queue-like container.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly ContainerQueue. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
technology |
string | null |
Optional technology. |
tooltip |
string | null |
Optional D2 tooltip. |
D2ContainerSchema¶
D2 JSON schema for a container.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly Container. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
technology |
string | null |
Optional technology. |
tooltip |
string | null |
Optional D2 tooltip. |
D2ContainerSystemBoundarySchema¶
D2 JSON schema for a system boundary in a container diagram.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemBoundary. |
elements |
array[Element] |
Elements may be nested arbitrarily. |
boundaries |
array[Boundary] |
Boundaries may be nested arbitrarily. |
relationships |
array[D2RelationshipSchema] |
Relationships declared inside the boundary. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2PersonExtSchema¶
D2 JSON schema for an external person.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly PersonExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2PersonSchema¶
D2 JSON schema for a person.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly Person. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2RelationshipSchema¶
JSON schema for relationships supported by D2 C4 diagrams.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
RelationshipType |
Type of the relationship. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Additional details about the relationship. |
from(required) |
string |
The source element alias (or unique label). |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
The label shown on the relationship edge. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
style |
D2StyleSchema |
Optional D2 style attributes. |
technology |
string | null |
The technology used in the communication. |
to(required) |
string |
The destination element alias (or unique label). |
tooltip |
string | null |
Optional D2 tooltip. |
RelationshipType¶
Relationship types supported by D2 C4 diagrams.
Items
| Type | Description |
|---|---|
BI_REL |
A bidirectional relationship between two elements. |
REL |
A unidirectional relationship between two elements. |
D2SystemDbExtSchema¶
D2 JSON schema for an external database-like system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemDbExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2SystemDbSchema¶
D2 JSON schema for a database-like system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemDb. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2SystemExtSchema¶
D2 JSON schema for an external software system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2SystemQueueExtSchema¶
D2 JSON schema for an external queue-like system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemQueueExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2SystemQueueSchema¶
D2 JSON schema for a queue-like system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemQueue. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
D2SystemSchema¶
D2 JSON schema for a software system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly System. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
classes |
array[string] |
Optional D2 classes. |
description |
string | null |
Optional description text. |
direction |
enum[up | down | left | right] | null |
Optional D2 layout direction for a container. |
icon |
string | null |
Optional D2 icon URL. |
label(required) |
string |
Display name for the element. |
link |
string | null |
Optional D2 link URL. |
near |
string | null |
Optional D2 near reference. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
shape |
string | null |
Optional D2 shape. |
style |
D2StyleSchema |
Optional D2 style attributes. |
tooltip |
string | null |
Optional D2 tooltip. |
DiagramElementPropertiesSchema¶
JSON schema for tabular diagram element properties.
Properties
| Field | Type | Description |
|---|---|---|
header |
array[string] |
Header columns. Default: ["Property", "Value"]. |
properties(required) |
array[array[string]] |
List of rows (each row is a list of string values). |
show_header |
boolean |
Whether to display the header row. Default: true. |
D2 Render Options¶
D2RenderOptionsSchema¶
Render options for the D2 renderer.
Properties
| Field | Type | Description |
|---|---|---|
auto_number_relationships |
boolean |
Auto Number Relationships Default: false. |
bidirectional_relationships |
enum[two_edges | single_edge] |
Bidirectional Relationships Default: two_edges. |
direction |
enum[up | down | left | right] | null |
Direction Default: right. |
fully_qualified_relationships |
boolean |
Fully Qualified Relationships Default: true. |
include_properties |
boolean |
Include Properties Default: false. |
include_technology |
boolean |
Include Technology Default: true. |
include_type_label |
boolean |
Include Type Label Default: true. |
layout |
enum[dagre | elk] |
Layout Default: dagre. |
legend |
D2LegendSchema |
|
sequence_diagram |
boolean |
Sequence Diagram Default: false. |
theme |
integer | null |
Theme |
title_near |
enum[top-left | top-center | top-right | center-left | center-right | bottom-left | bottom-center | bottom-right] | null |
Title Near Default: top-center. |
D2StyleSchema¶
D2 style attributes used by D2 render options.
Properties
| Field | Type | Description |
|---|---|---|
animated |
boolean | null |
Animated |
bold |
boolean | null |
Bold |
border_radius |
integer | null |
Border Radius |
double_border |
boolean | null |
Double Border |
fill |
string | null |
Fill |
fill_pattern |
string | null |
Fill Pattern |
font |
string | null |
Font |
font_color |
string | null |
Font Color |
font_size |
integer | null |
Font Size |
italic |
boolean | null |
Italic |
multiple |
boolean | null |
Multiple |
opacity |
number | null |
Opacity |
shadow |
boolean | null |
Shadow |
stroke |
string | null |
Stroke |
stroke_dash |
integer | null |
Stroke Dash |
stroke_width |
integer | null |
Stroke Width |
text_transform |
string | null |
Text Transform |
three_d |
boolean | null |
Three D |
underline |
boolean | null |
Underline |
D2LegendSchema¶
Structured D2 legend render options.
Properties
| Field | Type | Description |
|---|---|---|
items |
array[ |
Items |
label |
string |
Label Default: Legend. |
D2LegendElementSchema¶
Schema for a D2 legend node sample.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Legend item discriminator. Must be exactly element. |
alias |
string | null |
Optional D2 identifier. |
classes |
array[string] |
Classes |
icon |
string | null |
Icon |
label(required) |
string |
Legend item label. |
shape |
string | null |
Shape |
style |
D2StyleSchema |
D2LegendRelSchema¶
Schema for a D2 legend relationship sample.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Legend item discriminator. Must be exactly relationship. |
alias |
string | null |
Optional D2 identifier. |
bidirectional |
boolean |
Bidirectional Default: false. |
classes |
array[string] |
Classes |
hide_endpoints |
boolean | null |
Hide Endpoints |
label(required) |
string |
Legend item label. |
source |
string | null |
Source |
style |
D2StyleSchema |
|
target |
string | null |
Target |