{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.connectsoft.ai/reference/schemas/blueprint-module.schema.json",
  "title": "Module Blueprint (blueprint-module-v1)",
  "description": "Descriptor document of the Module 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",
    "contextId",
    "serviceBlueprintId",
    "kind",
    "template",
    "persistence"
  ],
  "additionalProperties": false,
  "properties": {
    "metadata": {
      "$ref": "blueprint-common.schema.json#/$defs/Metadata"
    },
    "contextId": {
      "type": "string"
    },
    "serviceBlueprintId": {
      "type": "string"
    },
    "kind": {
      "enum": [
        "Microservice",
        "Worker",
        "ApiGateway",
        "Library"
      ]
    },
    "template": {
      "type": "object",
      "required": [
        "id",
        "version"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "switches": {
          "type": "object"
        }
      },
      "additionalProperties": false
    },
    "layers": {
      "type": "object",
      "required": [],
      "properties": {
        "entityModel": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "domainModel": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "applicationModel": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "persistenceModel": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "serviceModel": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "infrastructureModel": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "dependencies": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "contextId",
          "port"
        ],
        "properties": {
          "contextId": {
            "type": "string"
          },
          "port": {
            "enum": [
              "http",
              "grpc",
              "messaging"
            ]
          },
          "purpose": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "persistence": {
      "type": "object",
      "required": [
        "storeClass",
        "tenantIdConvention"
      ],
      "properties": {
        "storeClass": {
          "type": "string"
        },
        "tenantIdConvention": {
          "enum": [
            "column",
            "platform-scoped"
          ]
        }
      },
      "additionalProperties": false
    },
    "configuration": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "section",
          "key",
          "type"
        ],
        "properties": {
          "section": {
            "type": "string"
          },
          "key": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "default": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    }
  }
}
