{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "/api/v1/schema.json",
  "title": "Funding Radar opportunity",
  "type": "object",
  "required": [
    "id",
    "title",
    "programme",
    "status",
    "facts",
    "analysis",
    "provenance",
    "links"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._~-]*$"
    },
    "source_reference_id": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "programme": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "open",
        "closed",
        "unknown"
      ]
    },
    "facts": {
      "$ref": "#/$defs/facts"
    },
    "analysis": {
      "$ref": "#/$defs/analysis"
    },
    "provenance": {
      "$ref": "#/$defs/provenance"
    },
    "links": {
      "$ref": "#/$defs/links"
    }
  },
  "$defs": {
    "facts": {
      "type": "object",
      "properties": {
        "opening_date": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "deadline": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "funding_amount": {
          "type": "string"
        },
        "eligible_applicants": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "applicant_eligibility_status": {
          "type": "string",
          "enum": [
            "known",
            "unknown"
          ]
        },
        "partnership_requirements": {
          "type": "string"
        },
        "other_requirements": {
          "type": "string"
        },
        "themes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "geography": {
          "$ref": "#/$defs/geography"
        }
      },
      "additionalProperties": false
    },
    "analysis": {
      "type": "object",
      "required": [
        "summary"
      ],
      "properties": {
        "summary": {
          "type": "string"
        },
        "relevance_score": {
          "type": "integer"
        },
        "relevance_category": {
          "type": "string"
        },
        "relevance_explanation": {
          "type": "string"
        },
        "llm_analysis": {
          "type": "object"
        }
      },
      "additionalProperties": false
    },
    "geography": {
      "type": "object",
      "required": [
        "scope",
        "areas"
      ],
      "properties": {
        "scope": {
          "type": "string",
          "enum": [
            "local",
            "regional",
            "national",
            "transnational",
            "eu",
            "unknown"
          ]
        },
        "areas": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    },
    "provenance": {
      "type": "object",
      "required": [
        "source_reference_id",
        "report_generated_at"
      ],
      "properties": {
        "source_organisation": {
          "type": "string"
        },
        "source_reference_id": {
          "type": "string"
        },
        "report_generated_at": {
          "type": "string",
          "format": "date-time"
        },
        "opening_date_source": {
          "type": "string"
        },
        "deadline_source": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "links": {
      "type": "object",
      "properties": {
        "source_url": {
          "type": "string",
          "format": "uri"
        },
        "document_url": {
          "type": "string",
          "format": "uri"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
