{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mobilidz.com/schemas/ai-catalog.schema.json",
  "title": "Mobilidz AI catalogue",
  "description": "Price snapshot of every phone with a live offer in Algeria. One entry per model, cheapest first, with provenance and licensing metadata.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "generatedAt", "site", "currency", "count", "provenance", "products"],
  "properties": {
    "schemaVersion": { "type": "string", "const": "1.0" },
    "generatedAt": { "type": "string", "format": "date-time" },
    "site": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "url", "locales"],
      "properties": {
        "name": { "type": "string" },
        "url": { "type": "string", "format": "uri" },
        "locales": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" }
        }
      }
    },
    "currency": { "type": "string", "const": "DZD" },
    "count": { "type": "integer", "minimum": 0 },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "market",
        "countryCode",
        "source",
        "updateFrequency",
        "methodologyUrl",
        "licenseUrl",
        "citationHint"
      ],
      "properties": {
        "market": { "type": "string", "const": "Algeria" },
        "countryCode": { "type": "string", "const": "DZ" },
        "source": { "type": "string", "minLength": 20 },
        "updateFrequency": { "type": "string", "const": "daily" },
        "methodologyUrl": { "type": "string", "format": "uri" },
        "licenseUrl": { "type": "string", "format": "uri" },
        "citationHint": { "type": "string", "minLength": 20 }
      }
    },
    "products": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "slug",
          "name",
          "brand",
          "priceDzd",
          "officialPriceDzd",
          "offers",
          "ramGb",
          "storageGb",
          "url",
          "imageUrl"
        ],
        "properties": {
          "id": { "type": "string" },
          "slug": { "type": "string" },
          "name": { "type": "string" },
          "brand": {
            "type": ["object", "null"],
            "additionalProperties": false,
            "required": ["slug", "name"],
            "properties": {
              "slug": { "type": "string" },
              "name": { "type": "string" }
            }
          },
          "priceDzd": { "type": "integer", "minimum": 1 },
          "officialPriceDzd": { "type": ["number", "null"], "minimum": 0 },
          "offers": { "type": "integer", "minimum": 0 },
          "ramGb": { "type": ["number", "null"], "minimum": 0 },
          "storageGb": { "type": ["number", "null"], "minimum": 0 },
          "url": { "type": "string", "format": "uri" },
          "imageUrl": { "type": ["string", "null"], "format": "uri" }
        }
      }
    }
  }
}
