{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pointcast.xyz/grants/applications.schema.json",
  "title": "PointCast Machine-Readable Grant Applications",
  "type": "object",
  "required": ["schema_version", "generated_at", "applicant", "project", "common_packet", "applications"],
  "properties": {
    "schema_version": { "type": "string" },
    "generated_at": { "type": "string", "format": "date-time" },
    "canonical_url": { "type": "string", "format": "uri" },
    "human_url": { "type": "string", "format": "uri" },
    "applicant": {
      "type": "object",
      "required": ["name", "role", "website"],
      "properties": {
        "name": { "type": "string" },
        "role": { "type": "string" },
        "website": { "type": "string", "format": "uri" },
        "signature": { "type": "string" }
      }
    },
    "project": {
      "type": "object",
      "required": ["name", "summary", "urls"],
      "properties": {
        "name": { "type": "string" },
        "summary": { "type": "string" },
        "urls": {
          "type": "object",
          "additionalProperties": { "type": "string", "format": "uri" }
        }
      }
    },
    "common_packet": {
      "type": "object",
      "required": ["one_liner", "core_paragraph", "evidence", "reward_loop"],
      "properties": {
        "one_liner": { "type": "string" },
        "core_paragraph": { "type": "string" },
        "evidence": { "type": "array", "items": { "type": "string" } },
        "reward_loop": { "type": "string" }
      }
    },
    "applications": {
      "type": "array",
      "items": { "$ref": "#/$defs/application" }
    }
  },
  "$defs": {
    "application": {
      "type": "object",
      "required": ["id", "status", "program", "ask", "fit", "milestones", "budget", "deliverables", "metrics", "links"],
      "properties": {
        "id": { "type": "string" },
        "status": { "type": "string", "enum": ["draft", "ready_for_human_review", "submitted", "archived"] },
        "requires_human_review_before_submit": { "type": "boolean" },
        "program": {
          "type": "object",
          "required": ["name", "category", "url"],
          "properties": {
            "name": { "type": "string" },
            "category": { "type": "string" },
            "url": { "type": "string", "format": "uri" }
          }
        },
        "ask": {
          "type": "object",
          "required": ["type", "amount_usd_range", "request"],
          "properties": {
            "type": { "type": "string" },
            "amount_usd_range": {
              "type": "object",
              "required": ["min", "max"],
              "properties": {
                "min": { "type": "number" },
                "max": { "type": "number" }
              }
            },
            "request": { "type": "string" }
          }
        },
        "fit": { "type": "string" },
        "milestones": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["name", "duration_days", "output"],
            "properties": {
              "name": { "type": "string" },
              "duration_days": { "type": "number" },
              "output": { "type": "string" }
            }
          }
        },
        "budget": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["line_item", "amount_usd"],
            "properties": {
              "line_item": { "type": "string" },
              "amount_usd": { "type": "number" }
            }
          }
        },
        "deliverables": { "type": "array", "items": { "type": "string" } },
        "metrics": { "type": "array", "items": { "type": "string" } },
        "links": {
          "type": "object",
          "additionalProperties": { "type": "string", "format": "uri" }
        }
      }
    }
  }
}
