Scene schema

A diagram is a scene document in DSP, the Diagram Scene Protocol. Two JSON Schemas define it, and they are the machine-readable contract:

SchemaDefines
scene.schema.jsonScene documents: elements, styles, assets, constraints, computed data
ops.schema.jsonOperation envelopes and the typed operations

Both use JSON Schema Draft 2020-12, and their URLs are stable. The schemas and the DSP spec are open source under the Apache License 2.0 at github.com/zindexai/diagram-scene-protocol; the Zindex engine and hosted service are not.

A scene document

{
  "schemaVersion": "0.1",
  "diagramFamily": "workflow",
  "layoutStrategy": { "direction": "TB" },
  "scene": {
    "title": "My Diagram",
    "units": "px",
    "canvas": { "width": 1200, "height": 800, "background": "#ffffff" }
  },
  "elements": [],
  "styles": {},
  "constraints": []
}

Element kinds

KindIs
nodeA shape with a label
edgeA connection between two elements
groupA logical grouping, not drawn
frameA visual container with a title
textA standalone text block
imageAn image from the scene’s assets
guideA horizontal or vertical guide line

Element types has every kind’s fields, shapes, node types and edge types.

Layout modes

A scene can mix them: fix some nodes and let the engine place the rest.

Checking a document

POST /v1/diagrams/validate and diagram_validate check a scene against the schema and every rule, with no key (Validation rules). Any JSON Schema validator checks the schema alone:

# ajv-cli reads local files: download the schema first.
# The schemas are Draft 2020-12 and use the uri and date-time formats.
curl -sO https://zindex.ai/schemas/scene.schema.json
npx -p ajv-cli -p ajv-formats ajv validate --spec=draft2020 --strict=false -c ajv-formats -s scene.schema.json -d my-scene.json

Types for other languages can be generated from the schemas, for example with npx -p json-schema-to-typescript json2ts -i scene.schema.json -o dsp-types.ts.