{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://abx-git.github.io/E2/schemas/board-snapshot-v1.schema.json",
  "title": "Event Storming Board Snapshot",
  "description": "Export-/Import-Format der E2 Event-Storming-App (format: event-storming-tool, version: 1). Andere Tools können dieses Schema nutzen, um gültige .storm.json-Dateien zu erzeugen.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "format",
    "version",
    "exportedAt",
    "title",
    "workshopFormat",
    "facilitatorEnabled",
    "facilitatorPhase",
    "elements",
    "relations",
    "swimlanes",
    "boundedContexts",
    "timeline",
    "viewport",
    "glossary",
    "snapToTimeline",
    "snapToGrid"
  ],
  "properties": {
    "$schema": {
      "type": "string",
      "description": "Optionaler Verweis auf dieses JSON Schema (z. B. für Editor-Autovervollständigung)."
    },
    "format": {
      "const": "event-storming-tool",
      "description": "Kennung des Dateiformats."
    },
    "version": {
      "const": 1,
      "description": "Schema-/Formatversion. Derzeit nur 1."
    },
    "exportedAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO-8601-Zeitstempel des Exports. Wird beim Import nicht für Sync-Vergleiche genutzt."
    },
    "title": {
      "type": "string",
      "description": "Board-Titel."
    },
    "modelingMode": {
      "$ref": "#/$defs/modelingMode",
      "description": "Methoden-Modus für Palette/Facilitator. Fehlt in älteren Dateien → eventStorming. Board-Inhalt darf Typen beider Modi enthalten."
    },
    "workshopFormat": {
      "$ref": "#/$defs/workshopFormat"
    },
    "facilitatorEnabled": {
      "type": "boolean",
      "description": "Ob der Facilitator-Modus aktiv ist."
    },
    "facilitatorPhase": {
      "type": "integer",
      "minimum": 0,
      "description": "Aktueller Facilitator-Phasenindex (0-basiert)."
    },
    "elements": {
      "type": "array",
      "description": "Sticky-Notes / Modellelemente auf dem Canvas.",
      "items": { "$ref": "#/$defs/stormElement" }
    },
    "relations": {
      "type": "array",
      "description": "Verbindungen zwischen Elementen.",
      "items": { "$ref": "#/$defs/stormRelation" }
    },
    "contextRelations": {
      "type": "array",
      "description": "Context-Map-Beziehungen zwischen Bounded Contexts. Beim Import Standard: [] falls fehlend.",
      "items": { "$ref": "#/$defs/contextRelation" }
    },
    "swimlanes": {
      "type": "array",
      "items": { "$ref": "#/$defs/swimlane" }
    },
    "boundedContexts": {
      "type": "array",
      "items": { "$ref": "#/$defs/boundedContext" }
    },
    "timeline": {
      "$ref": "#/$defs/timeline"
    },
    "viewport": {
      "$ref": "#/$defs/viewport"
    },
    "glossary": {
      "type": "array",
      "items": { "$ref": "#/$defs/glossaryEntry" }
    },
    "appearance": {
      "$ref": "#/$defs/appearance",
      "description": "Farben für Arbeitsbereich und Seitenleisten."
    },
    "snapToTimeline": {
      "type": "boolean",
      "description": "Elemente an die Timeline einrasten. Beim Import Standard: true, falls fehlend."
    },
    "snapToGrid": {
      "type": "boolean",
      "description": "Elemente am Raster einrasten. Beim Import Standard: false, falls fehlend."
    },
    "canvasLines": {
      "type": "array",
      "description": "Freie Linien auf dem Canvas. Beim Import Standard: [] falls fehlend.",
      "items": { "$ref": "#/$defs/canvasLine" }
    },
    "bookmarks": {
      "type": "array",
      "description": "Gespeicherte Viewport-Lesezeichen. Beim Import Standard: [] falls fehlend.",
      "items": { "$ref": "#/$defs/viewBookmark" }
    }
  },
  "$defs": {
    "modelingMode": {
      "type": "string",
      "enum": [
        "eventStorming",
        "domainDrivenDesign",
        "bdd",
        "userStoryMapping",
        "eventModeling",
        "processFlow",
        "dataModel",
        "c4",
        "arc42",
        "cloud",
        "architectureDocumentation"
      ]
    },
    "workshopFormat": {
      "type": "string",
      "enum": [
        "bigPicture",
        "processModeling",
        "softwareDesign",
        "strategicDesign",
        "tacticalDesign",
        "exampleMapping",
        "storyMapping",
        "eventModelingWorkshop",
        "processWorkshop",
        "dataModelWorkshop",
        "arc42Workshop",
        "c4Modeling",
        "cloudArchitecture",
        "ermDocumentation",
        "free"
      ]
    },
    "elementType": {
      "type": "string",
      "enum": [
        "domainEvent",
        "command",
        "actor",
        "aggregate",
        "policy",
        "readModel",
        "externalSystem",
        "ui",
        "note",
        "instruction",
        "hotspot",
        "pivotalEvent",
        "entity",
        "valueObject",
        "domainService",
        "repository",
        "factory",
        "subdomain",
        "rule",
        "example",
        "question",
        "activity",
        "userTask",
        "userStory",
        "release",
        "slice",
        "processStart",
        "processEnd",
        "processActivity",
        "processGateway",
        "dataEntity",
        "dataAssociation",
        "c4Person",
        "c4SoftwareSystem",
        "c4Container",
        "c4Component",
        "arc42Section",
        "archBlackbox",
        "archWhitebox",
        "archComponent",
        "link"
      ]
    },
    "linkKind": {
      "type": "string",
      "enum": ["external", "view"]
    },
    "gatewayKind": {
      "type": "string",
      "enum": ["xor", "and", "or"]
    },
    "dataCardinality": {
      "type": "string",
      "enum": ["1:1", "1:n", "n:1", "n:m"]
    },
    "subdomainKind": {
      "type": "string",
      "enum": ["core", "supporting", "generic"]
    },
    "storyPriority": {
      "type": "string",
      "enum": ["must", "should", "could", "wont"]
    },
    "questionStatus": {
      "type": "string",
      "enum": ["open", "resolved"]
    },
    "relationType": {
      "type": "string",
      "enum": [
        "triggers",
        "reactsWith",
        "informs",
        "executedBy",
        "invokes",
        "causal",
        "contains",
        "annotates"
      ]
    },
    "contextMapPattern": {
      "type": "string",
      "enum": [
        "partnership",
        "sharedKernel",
        "customerSupplier",
        "conformist",
        "antiCorruptionLayer",
        "openHostService",
        "publishedLanguage",
        "separateWays"
      ],
      "description": "DDD Context-Map-Muster zwischen Bounded Contexts."
    },
    "hotspotStatus": {
      "type": "string",
      "enum": ["open", "resolved"]
    },
    "hotspotPriority": {
      "type": "string",
      "enum": ["low", "medium", "high"]
    },
    "noteColor": {
      "type": "string",
      "enum": ["cream", "yellow", "mint", "sky", "lavender", "rose", "peach", "slate"],
      "description": "Hintergrundfarbe für Notizen."
    },
    "elementMetadata": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "eventSchema": {
          "type": "object",
          "additionalProperties": true,
          "description": "Freies JSON-Objekt für Event-/Aggregate-Schema."
        },
        "aggregateMethods": {
          "type": "array",
          "items": { "type": "string" }
        },
        "aggregateInvariants": {
          "type": "array",
          "items": { "type": "string" }
        },
        "isRecurring": {
          "type": "boolean"
        },
        "hotspotStatus": {
          "$ref": "#/$defs/hotspotStatus"
        },
        "hotspotPriority": {
          "$ref": "#/$defs/hotspotPriority"
        },
        "noteColor": {
          "$ref": "#/$defs/noteColor"
        },
        "subdomainKind": {
          "$ref": "#/$defs/subdomainKind"
        },
        "attributes": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Entity / Value Object / Aggregate / Data Entity: Eigenschaften („name“ oder „name: Typ“)."
        },
        "identityFields": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Entity / Data Entity: Identitätsfelder."
        },
        "operations": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Entity / Domain Service / Repository / Factory: Operationen."
        },
        "immutable": {
          "type": "boolean",
          "description": "Value Object: unveränderlich."
        },
        "stateless": {
          "type": "boolean",
          "description": "Domain Service: ohne eigenen Zustand."
        },
        "aggregateRootRef": {
          "type": "string",
          "description": "Repository: zugehöriger Aggregate Root."
        },
        "createsRef": {
          "type": "string",
          "description": "Factory: erzeugter Typ / Aggregate."
        },
        "ruleCriteria": {
          "type": "array",
          "items": { "type": "string" },
          "description": "BDD Rule: Akzeptanzhinweise."
        },
        "exampleGiven": {
          "type": "array",
          "items": { "type": "string" }
        },
        "exampleWhen": {
          "type": "array",
          "items": { "type": "string" }
        },
        "exampleThen": {
          "type": "array",
          "items": { "type": "string" }
        },
        "questionStatus": {
          "$ref": "#/$defs/questionStatus"
        },
        "storyPersona": {
          "type": "string"
        },
        "storyPriority": {
          "$ref": "#/$defs/storyPriority"
        },
        "storyEstimate": {
          "type": "string"
        },
        "storyAcceptance": {
          "type": "array",
          "items": { "type": "string" }
        },
        "releaseGoal": {
          "type": "string"
        },
        "sliceSystems": {
          "type": "array",
          "items": { "type": "string" }
        },
        "processRole": {
          "type": "string",
          "description": "Process Activity: Rolle / Verantwortlich."
        },
        "processSystem": {
          "type": "string",
          "description": "Process Activity: System / Anwendung."
        },
        "processInputs": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Process Activity: Eingaben."
        },
        "processOutputs": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Process Activity: Ausgaben."
        },
        "processDuration": {
          "type": "string",
          "description": "Process Activity: Dauer / SLA."
        },
        "gatewayKind": {
          "$ref": "#/$defs/gatewayKind"
        },
        "gatewayConditions": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Process Gateway: Bedingungen / Pfade."
        },
        "processTrigger": {
          "type": "string",
          "description": "Process Start: Auslöser."
        },
        "processResult": {
          "type": "string",
          "description": "Process End: Ergebnis."
        },
        "dataTableName": {
          "type": "string",
          "description": "Data Entity: Tabellenname."
        },
        "dataUniqueKeys": {
          "type": "array",
          "items": { "type": "string" },
          "description": "Data Entity: Unique Keys."
        },
        "dataCardinality": {
          "$ref": "#/$defs/dataCardinality"
        },
        "dataLeftEntity": {
          "type": "string",
          "description": "Data Association: linke Entität."
        },
        "dataRightEntity": {
          "type": "string",
          "description": "Data Association: rechte Entität."
        },
        "linkKind": {
          "$ref": "#/$defs/linkKind"
        },
        "linkUrl": {
          "type": "string",
          "description": "Link (external): Ziel-URL."
        },
        "linkViewId": {
          "type": "string",
          "description": "Link (view): ID einer Board-Sicht."
        },
        "c4Technology": {
          "type": "string",
          "description": "C4 Container/Component: Technologie-Stack."
        },
        "arc42SectionNumber": {
          "type": "integer",
          "minimum": 1,
          "maximum": 12,
          "description": "Legacy arc42 Abschnittsnummer (migriert zu Blackbox)."
        },
        "showDescriptionOnCard": {
          "type": "boolean",
          "description": "Beschreibung auf dem Sticky anzeigen."
        },
        "showAttributesOnCard": {
          "type": "boolean",
          "description": "Attribute / Kriterien auf dem Sticky anzeigen."
        },
        "showMethodsOnCard": {
          "type": "boolean",
          "description": "Methoden / Operationen auf dem Sticky anzeigen."
        }
      }
    },
    "stormElement": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "label", "x", "y"],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "Stabile Element-ID (Referenzziel für Relationen)."
        },
        "type": {
          "$ref": "#/$defs/elementType"
        },
        "label": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "x": {
          "type": "number",
          "description": "Welt-X der linken oberen Ecke."
        },
        "y": {
          "type": "number",
          "description": "Welt-Y der linken oberen Ecke."
        },
        "width": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "height": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "rotation": {
          "type": "number",
          "description": "Rotation in Grad (z. B. 45 für Hotspots)."
        },
        "zIndex": {
          "type": "integer",
          "description": "Stapelreihenfolge auf dem Canvas (höher = weiter vorn)."
        },
        "swimlaneId": {
          "type": "string",
          "description": "Optionale ID einer Swimlane."
        },
        "boundedContextId": {
          "type": "string",
          "description": "Optionale ID eines Bounded Context."
        },
        "metadata": {
          "$ref": "#/$defs/elementMetadata"
        }
      }
    },
    "stormRelation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "sourceId", "targetId"],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "$ref": "#/$defs/relationType"
        },
        "sourceId": {
          "type": "string",
          "minLength": 1,
          "description": "ID des Quell-Elements."
        },
        "targetId": {
          "type": "string",
          "minLength": 1,
          "description": "ID des Ziel-Elements."
        },
        "label": {
          "type": "string"
        },
        "labelMode": {
          "type": "string",
          "enum": ["type", "custom"]
        },
        "strokeStyle": {
          "type": "string",
          "enum": ["solid", "dashed", "dotted"]
        }
      }
    },
    "contextRelation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "type", "sourceContextId", "targetContextId"],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "$ref": "#/$defs/contextMapPattern"
        },
        "sourceContextId": {
          "type": "string",
          "minLength": 1,
          "description": "Upstream-/Supplier-Bounded-Context-ID."
        },
        "targetContextId": {
          "type": "string",
          "minLength": 1,
          "description": "Downstream-/Customer-Bounded-Context-ID."
        },
        "label": {
          "type": "string"
        }
      }
    },
    "swimlane": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "label", "x", "y", "width", "height"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "label": { "type": "string" },
        "x": { "type": "number" },
        "y": { "type": "number" },
        "width": { "type": "number", "exclusiveMinimum": 0 },
        "height": { "type": "number", "exclusiveMinimum": 0 },
        "color": { "type": "string" },
        "fillOpacity": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Deckkraft der Füllung (0–1)."
        },
        "borderColor": {
          "type": "string",
          "description": "Randfarbe (#rrggbb)."
        },
        "borderOpacity": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Deckkraft des Rands (0–1)."
        },
        "locked": {
          "type": "boolean",
          "description": "Wenn true, Position und Größe sind auf dem Canvas gesperrt."
        },
        "zIndex": {
          "type": "integer",
          "description": "Stapelreihenfolge unter Swimlanes und Bounded Contexts (höher = weiter vorn)."
        }
      }
    },
    "boundedContext": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "label", "x", "y", "width", "height"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "label": { "type": "string" },
        "purpose": { "type": "string" },
        "x": { "type": "number" },
        "y": { "type": "number" },
        "width": { "type": "number", "exclusiveMinimum": 0 },
        "height": { "type": "number", "exclusiveMinimum": 0 },
        "color": { "type": "string" },
        "fillOpacity": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Deckkraft der Füllung (0–1)."
        },
        "borderColor": {
          "type": "string",
          "description": "Randfarbe (#rrggbb)."
        },
        "borderOpacity": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Deckkraft des Rands (0–1)."
        },
        "locked": {
          "type": "boolean",
          "description": "Wenn true, Position und Größe sind auf dem Canvas gesperrt."
        },
        "zIndex": {
          "type": "integer",
          "description": "Stapelreihenfolge unter Swimlanes und Bounded Contexts (höher = weiter vorn)."
        }
      }
    },
    "timeline": {
      "type": "object",
      "additionalProperties": false,
      "required": ["y"],
      "properties": {
        "y": { "type": "number", "description": "Vertikale Position der Timeline-Linie." },
        "startLabel": { "type": "string" },
        "endLabel": { "type": "string" },
        "visible": {
          "type": "boolean",
          "description": "Timeline-Linie anzeigen. Standard: true."
        }
      }
    },
    "viewport": {
      "type": "object",
      "additionalProperties": false,
      "required": ["x", "y", "zoom"],
      "properties": {
        "x": { "type": "number", "description": "Pan-Offset X in Bildschirmkoordinaten." },
        "y": { "type": "number", "description": "Pan-Offset Y in Bildschirmkoordinaten." },
        "zoom": { "type": "number", "exclusiveMinimum": 0 }
      }
    },
    "glossaryEntry": {
      "type": "object",
      "additionalProperties": false,
      "required": ["term", "definition"],
      "properties": {
        "term": { "type": "string" },
        "definition": { "type": "string" }
      }
    },
    "appearance": {
      "type": "object",
      "additionalProperties": false,
      "required": ["canvas", "sidebar"],
      "properties": {
        "canvas": {
          "type": "string",
          "pattern": "^#[0-9A-Fa-f]{6}$",
          "description": "Hintergrundfarbe des Arbeitsbereichs (Canvas)."
        },
        "sidebar": {
          "type": "string",
          "pattern": "^#[0-9A-Fa-f]{6}$",
          "description": "Hintergrundfarbe der Seitenleisten und Docks."
        }
      }
    },
    "lineArrowHead": {
      "type": "string",
      "enum": ["none", "start", "end", "both"]
    },
    "canvasLine": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "x1", "y1", "x2", "y2"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "x1": { "type": "number" },
        "y1": { "type": "number" },
        "x2": { "type": "number" },
        "y2": { "type": "number" },
        "arrowHead": { "$ref": "#/$defs/lineArrowHead" },
        "label": { "type": "string" },
        "color": { "type": "string" },
        "strokeStyle": {
          "type": "string",
          "enum": ["solid", "dashed", "dotted"]
        }
      }
    },
    "viewBookmark": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "name", "viewId", "viewport"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "name": { "type": "string", "minLength": 1 },
        "viewId": { "type": "string", "minLength": 1 },
        "viewport": { "$ref": "#/$defs/viewport" }
      }
    }
  }
}
