{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://continentalclub.ae/public/ai_feed/schema.json",
 "title": "Continental Club feed record (one line of projects-*.ndjson or listings-*.ndjson)",
 "oneOf": [
  {
   "$ref": "#/$defs/project"
  },
  {
   "$ref": "#/$defs/listing"
  }
 ],
 "$defs": {
  "project": {
   "type": "object",
   "required": [
    "id",
    "type",
    "lang",
    "name",
    "url"
   ],
   "properties": {
    "id": {
     "type": "integer"
    },
    "url": {
     "type": "string",
     "format": "uri"
    },
    "lang": {
     "type": "string",
     "enum": [
      "en",
      "ru"
     ]
    },
    "translations": {
     "type": "object",
     "additionalProperties": {
      "type": "string",
      "format": "uri"
     },
     "description": "language code → URL of the same record"
    },
    "name": {
     "type": "string"
    },
    "description": {
     "type": "string",
     "description": "plain text"
    },
    "updated_at": {
     "type": "string"
    },
    "type": {
     "const": "project"
    },
    "developer": {
     "type": "object",
     "properties": {
      "name": {
       "type": "string"
      },
      "url": {
       "type": "string",
       "format": "uri"
      }
     }
    },
    "location": {
     "type": "object",
     "properties": {
      "community": {
       "type": "string"
      },
      "url": {
       "type": "string",
       "format": "uri"
      },
      "city": {
       "type": "string"
      },
      "country": {
       "type": "string"
      },
      "lat": {
       "type": "number"
      },
      "lng": {
       "type": "number"
      }
     }
    },
    "status": {
     "type": "object",
     "properties": {
      "state": {
       "type": "string",
       "enum": [
        "ready",
        "off_plan"
       ]
      },
      "planned_handover": {
       "type": "string",
       "description": "YYYY or YYYY-Qn"
      },
      "handover_text": {
       "type": "string"
      },
      "dld_status": {
       "type": "string"
      },
      "completion_percent": {
       "type": "number"
      },
      "last_inspection": {
       "type": "string"
      }
     }
    },
    "dld": {
     "type": "object",
     "properties": {
      "project_number": {
       "type": "string"
      },
      "escrow_bank": {
       "type": "string"
      },
      "units_in_registry": {
       "type": "integer"
      },
      "inspections": {
       "type": "array",
       "description": "DLD technical inspections: date and completion %",
       "items": {
        "type": "object",
        "properties": {
         "date": {
          "type": "string"
         },
         "completion_percent": {
          "type": "number"
         }
        }
       }
      },
      "pace": {
       "type": "object",
       "description": "our estimate of construction pace from inspections (origin: calculation)"
      }
     }
    },
    "prices": {
     "type": "object",
     "properties": {
      "starting_price_aed": {
       "type": "number"
      },
      "service_charge_aed_sqft": {
       "type": "number"
      }
     }
    },
    "payment_plan": {
     "type": "object",
     "properties": {
      "split": {
       "type": "string"
      },
      "down_payment_pct": {
       "type": "number"
      },
      "text": {
       "type": "string"
      }
     }
    },
    "building": {
     "type": "object",
     "properties": {
      "units": {
       "type": "integer"
      },
      "floors": {
       "type": "integer"
      }
     }
    },
    "unit_types": {
     "type": "array",
     "items": {
      "type": "object",
      "properties": {
       "label": {
        "type": "string"
       },
       "bedrooms": {
        "type": "integer"
       },
       "size_sqft_min": {
        "type": "number"
       },
       "size_sqft_max": {
        "type": "number"
       },
       "price_from_aed": {
        "type": "number"
       }
      }
     }
    },
    "amenities": {
     "type": "array",
     "items": {
      "type": "string"
     }
    },
    "faq": {
     "type": "array",
     "items": {
      "type": "object",
      "required": [
       "q",
       "a"
      ],
      "properties": {
       "q": {
        "type": "string"
       },
       "a": {
        "type": "string"
       }
      }
     }
    },
    "images": {
     "type": "object",
     "properties": {
      "facade": {
       "type": "object",
       "required": [
        "url"
       ],
       "properties": {
        "url": {
         "type": "string",
         "format": "uri"
        },
        "width": {
         "type": "integer"
        },
        "height": {
         "type": "integer"
        }
       }
      },
      "gallery": {
       "type": "array",
       "items": {
        "type": "object",
        "required": [
         "url"
        ],
        "properties": {
         "url": {
          "type": "string",
          "format": "uri"
         },
         "width": {
          "type": "integer"
         },
         "height": {
          "type": "integer"
         },
         "category": {
          "type": "string",
          "enum": [
           "exterior",
           "interior",
           "amenity",
           "plan_map",
           "other"
          ],
          "description": "What the image shows: exterior (building, view, aerial render), interior (rooms, a unit's own balcony/terrace), amenity (pool, gym, lobby, shared areas), plan_map (master plan, location map, site plan), other (brochure page, logo, decorative). Machine-classified; absent for images added after the last classification run."
         }
        }
       }
      },
      "floorplans": {
       "type": "array",
       "items": {
        "allOf": [
         {
          "type": "object",
          "required": [
           "url"
          ],
          "properties": {
           "url": {
            "type": "string",
            "format": "uri"
           },
           "width": {
            "type": "integer"
           },
           "height": {
            "type": "integer"
           }
          }
         },
         {
          "type": "object",
          "properties": {
           "bedrooms": {
            "type": "integer"
           },
           "area_sqft": {
            "type": "number"
           },
           "layout": {
            "type": "string"
           }
          }
         }
        ]
       }
      }
     }
    },
    "listings": {
     "type": "array",
     "items": {
      "type": "object",
      "properties": {
       "id": {
        "type": "integer"
       },
       "url": {
        "type": "string",
        "format": "uri"
       }
      }
     }
    },
    "sources": {
     "type": "object"
    },
    "machine": {
     "type": "object",
     "properties": {
      "json": {
       "type": "string",
       "format": "uri"
      },
      "markdown": {
       "type": "string",
       "format": "uri"
      }
     }
    },
    "dld_sales": {
     "type": "object",
     "description": "summary of all registered DLD sales of the project: deals, median AED/m2, resale share, yoy, gross yield, medians by bedrooms (origin: DLD registry + our calculation)"
    },
    "dld_history": {
     "type": "object",
     "description": "DLD transaction history (anonymised aggregates): medians per calendar year and the last 8 quarters, last 12 months vs previous 12, latest deals (date/type/size/price only). Full quarterly series since first registration: machine.json -> dld_history",
     "properties": {
      "sales": {
       "type": "object",
       "properties": {
        "records": {
         "type": "integer"
        },
        "last_12m": {
         "type": "object"
        },
        "previous_12m": {
         "type": "object"
        },
        "by_year": {
         "type": "array",
         "items": {
          "type": "object",
          "properties": {
           "period": {
            "type": "string",
            "description": "YYYY or YYYY-Qn"
           },
           "n": {
            "type": "integer"
           }
          },
          "additionalProperties": {
           "type": [
            "number",
            "string",
            "null"
           ]
          }
         }
        },
        "by_quarter_last_8": {
         "type": "array",
         "items": {
          "type": "object",
          "properties": {
           "period": {
            "type": "string",
            "description": "YYYY or YYYY-Qn"
           },
           "n": {
            "type": "integer"
           }
          },
          "additionalProperties": {
           "type": [
            "number",
            "string",
            "null"
           ]
          }
         }
        },
        "latest": {
         "type": "array",
         "items": {
          "type": "object"
         }
        }
       }
      },
      "rent": {
       "type": "object",
       "properties": {
        "records": {
         "type": "integer"
        },
        "last_12m": {
         "type": "object"
        },
        "by_year": {
         "type": "array",
         "items": {
          "type": "object",
          "properties": {
           "period": {
            "type": "string",
            "description": "YYYY or YYYY-Qn"
           },
           "n": {
            "type": "integer"
           }
          },
          "additionalProperties": {
           "type": [
            "number",
            "string",
            "null"
           ]
          }
         }
        },
        "by_quarter_last_8": {
         "type": "array",
         "items": {
          "type": "object",
          "properties": {
           "period": {
            "type": "string",
            "description": "YYYY or YYYY-Qn"
           },
           "n": {
            "type": "integer"
           }
          },
          "additionalProperties": {
           "type": [
            "number",
            "string",
            "null"
           ]
          }
         }
        },
        "latest": {
         "type": "array",
         "items": {
          "type": "object"
         }
        }
       }
      },
      "generated": {
       "type": "string"
      },
      "full": {
       "type": "string"
      }
     }
    }
   }
  },
  "listing": {
   "type": "object",
   "required": [
    "id",
    "type",
    "lang",
    "url",
    "price_aed"
   ],
   "properties": {
    "id": {
     "type": "integer"
    },
    "url": {
     "type": "string",
     "format": "uri"
    },
    "lang": {
     "type": "string",
     "enum": [
      "en",
      "ru"
     ]
    },
    "translations": {
     "type": "object",
     "additionalProperties": {
      "type": "string",
      "format": "uri"
     },
     "description": "language code → URL of the same record"
    },
    "name": {
     "type": "string"
    },
    "description": {
     "type": "string",
     "description": "plain text"
    },
    "updated_at": {
     "type": "string"
    },
    "type": {
     "const": "listing"
    },
    "deal": {
     "type": "string",
     "enum": [
      "sale",
      "rent"
     ]
    },
    "price_aed": {
     "type": "number"
    },
    "price_period": {
     "type": "string",
     "enum": [
      "year"
     ]
    },
    "property_type": {
     "type": "string"
    },
    "bedrooms": {
     "type": [
      "integer",
      "string"
     ],
     "description": "number or \"Studio\""
    },
    "bathrooms": {
     "type": "number"
    },
    "area_sqm": {
     "type": "number"
    },
    "area_sqft": {
     "type": "integer"
    },
    "completion": {
     "type": "string",
     "enum": [
      "ready",
      "off_plan"
     ]
    },
    "building": {
     "type": "string"
    },
    "location": {
     "type": "object",
     "properties": {
      "community": {
       "type": "string"
      },
      "url": {
       "type": "string",
       "format": "uri"
      },
      "city": {
       "type": "string"
      },
      "country": {
       "type": "string"
      },
      "lat": {
       "type": "number"
      },
      "lng": {
       "type": "number"
      }
     }
    },
    "developer": {
     "type": "string"
    },
    "project": {
     "type": "object",
     "properties": {
      "id": {
       "type": "integer"
      },
      "url": {
       "type": "string",
       "format": "uri"
      }
     }
    },
    "permit": {
     "type": "object",
     "properties": {
      "trakheesi": {
       "type": "string"
      }
     }
    },
    "agent": {
     "type": "object",
     "properties": {
      "name": {
       "type": "string"
      }
     }
    },
    "images": {
     "type": "object",
     "properties": {
      "photos": {
       "type": "array",
       "items": {
        "type": "object",
        "required": [
         "url"
        ],
        "properties": {
         "url": {
          "type": "string",
          "format": "uri"
         },
         "width": {
          "type": "integer"
         },
         "height": {
          "type": "integer"
         },
         "category": {
          "type": "string",
          "enum": [
           "exterior",
           "interior",
           "amenity",
           "plan_map",
           "other"
          ],
          "description": "What the image shows: exterior (building, view, aerial render), interior (rooms, a unit's own balcony/terrace), amenity (pool, gym, lobby, shared areas), plan_map (master plan, location map, site plan), other (brochure page, logo, decorative). Machine-classified; absent for images added after the last classification run."
         }
        }
       }
      },
      "photos_source": {
       "type": "string",
       "enum": [
        "listing",
        "project"
       ]
      }
     }
    }
   }
  }
 }
}