{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "./geometry.schema.json",
  "title": "Sacred Geometry Atlas geometry dataset",
  "description": "Machine-readable contract for the Sacred Geometry Atlas JSON collection, including schema metadata and proportional church geometry studies.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "title",
    "schema",
    "schemaUrl",
    "studies"
  ],
  "properties": {
    "title": {
      "const": "Sacred Geometry Atlas"
    },
    "schemaUrl": {
      "const": "data/geometry.schema.json"
    },
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "version",
        "units",
        "unitSymbol",
        "statusValues",
        "statusDefinitions",
        "note"
      ],
      "properties": {
        "version": {
          "type": "string",
          "minLength": 1,
          "description": "Version of the published geometry data contract."
        },
        "units": {
          "type": "string",
          "minLength": 1,
          "description": "Human-readable unit system used by linear dimensions and derived readings."
        },
        "unitSymbol": {
          "type": "string",
          "minLength": 1,
          "description": "Display symbol for the schema unit system, such as m or ft."
        },
        "statusValues": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1,
            "enum": [
              "schematic",
              "measured"
            ]
          }
        },
        "statusDefinitions": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "schematic",
            "measured"
          ],
          "properties": {
            "schematic": {
              "type": "string",
              "minLength": 1
            },
            "measured": {
              "type": "string",
              "minLength": 1
            }
          }
        },
        "note": {
          "type": "string",
          "minLength": 1,
          "description": "Collection-level evidence and provenance note."
        }
      }
    },
    "studies": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/study"
      }
    }
  },
  "$defs": {
    "study": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "index",
        "name",
        "shortName",
        "typology",
        "place",
        "era",
        "emphasis",
        "type",
        "churchName",
        "source",
        "sourceUrl",
        "sourceNote",
        "envelope",
        "axis",
        "surfaceNote",
        "exteriorNote",
        "interiorNote",
        "status",
        "length",
        "span",
        "height",
        "bayCount",
        "module",
        "radius",
        "symmetry",
        "details"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "index": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "shortName": {
          "type": "string",
          "minLength": 1
        },
        "typology": {
          "type": "string",
          "minLength": 1
        },
        "place": {
          "type": "string",
          "minLength": 1
        },
        "era": {
          "type": "string",
          "minLength": 1
        },
        "emphasis": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "minLength": 1
        },
        "churchName": {
          "type": "string",
          "minLength": 1
        },
        "source": {
          "type": "string",
          "minLength": 1
        },
        "sourceUrl": {
          "type": "string",
          "minLength": 1,
          "format": "uri",
          "pattern": "^https?://",
          "description": "Canonical absolute http(s) source page for the named reference building or source note."
        },
        "sourceNote": {
          "type": "string",
          "minLength": 1
        },
        "envelope": {
          "type": "string",
          "minLength": 1
        },
        "axis": {
          "type": "string",
          "minLength": 1
        },
        "surfaceNote": {
          "type": "string",
          "minLength": 1
        },
        "exteriorNote": {
          "type": "string",
          "minLength": 1
        },
        "interiorNote": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "type": "string",
          "minLength": 1,
          "enum": [
            "schematic",
            "measured"
          ],
          "description": "Schema-defined evidence label for the study record."
        },
        "length": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Overall longitudinal dimension in the schema unit."
        },
        "span": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Overall cross-width dimension in the schema unit."
        },
        "height": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Overall vertical dimension in the schema unit."
        },
        "bayCount": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "description": "Number of notional repeated bays or frames."
        },
        "module": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Notional repeated bay or frame module in the schema unit."
        },
        "radius": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Primary curved reach in the schema unit."
        },
        "symmetry": {
          "type": "number",
          "minimum": 0,
          "maximum": 1,
          "description": "Normalized 0–1 reading of plan balance; 0 is valid for an intentionally asymmetric study."
        },
        "floorAreaEstimate": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Optional supplied floor-area estimate in the schema unit squared; when absent, the interface identifies its length × span fallback."
        },
        "volumeEstimate": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Optional estimated volume in the schema unit cubed."
        },
        "volumeBasis": {
          "type": "string",
          "minLength": 1,
          "description": "Calculation or source basis for the optional volume estimate."
        },
        "details": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "string",
              "minLength": 1
            }
          }
        }
      }
    }
  }
}
