{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.connectsoft.ai/reference/schemas/blueprint-service.schema.json",
  "title": "Service Blueprint (blueprint-service-v1)",
  "description": "Descriptor document of the Service Blueprint kind (BC-02). Validated by BlueprintService; metadata per blueprint-common.schema.json; generation outputs and validation rules per model/blueprints.yaml.",
  "type": "object",
  "required": [
    "metadata",
    "businessResponsibility",
    "features",
    "boundedContexts",
    "aggregates",
    "apis",
    "events",
    "security"
  ],
  "additionalProperties": false,
  "properties": {
    "metadata": {
      "$ref": "blueprint-common.schema.json#/$defs/Metadata"
    },
    "businessResponsibility": {
      "type": "string"
    },
    "features": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "visionFeatureId": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "boundedContexts": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "name",
          "responsibility"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "responsibility": {
            "type": "string"
          },
          "relationships": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "to",
                "kind"
              ],
              "properties": {
                "to": {
                  "type": "string"
                },
                "kind": {
                  "enum": [
                    "upstream",
                    "downstream",
                    "shared-kernel",
                    "acl",
                    "conformist",
                    "published-language"
                  ]
                }
              },
              "additionalProperties": false
            }
          }
        },
        "additionalProperties": false
      }
    },
    "aggregates": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "contextId",
          "name",
          "rootEntity",
          "identity",
          "invariants"
        ],
        "properties": {
          "contextId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "rootEntity": {
            "type": "string"
          },
          "identity": {
            "type": "string"
          },
          "entities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "valueObjects": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "invariants": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      }
    },
    "apis": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "operation",
          "kind",
          "aggregate",
          "scope"
        ],
        "properties": {
          "operation": {
            "type": "string"
          },
          "kind": {
            "enum": [
              "command",
              "query"
            ]
          },
          "aggregate": {
            "type": "string"
          },
          "scope": {
            "type": "string"
          },
          "sideEffectClass": {
            "$ref": "blueprint-common.schema.json#/$defs/SideEffectClass"
          }
        },
        "additionalProperties": false
      }
    },
    "events": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "topic",
          "aggregate"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "topic": {
            "type": "string",
            "pattern": "^[a-z0-9-]+\\.[a-z0-9-]+\\.v\\d+\\.[a-z0-9-]+$"
          },
          "aggregate": {
            "type": "string"
          },
          "consumers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      }
    },
    "security": {
      "type": "object",
      "required": [
        "roles",
        "scopes",
        "classification"
      ],
      "properties": {
        "roles": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "scopes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "classification": {
          "$ref": "blueprint-common.schema.json#/$defs/Classification"
        }
      },
      "additionalProperties": false
    },
    "quality": {
      "type": "object",
      "required": [],
      "properties": {
        "coverageMin": {
          "type": "number"
        },
        "latencyP95Ms": {
          "type": "integer"
        },
        "availability": {
          "type": "number"
        }
      },
      "additionalProperties": false
    }
  }
}
