{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://loop.firmiana.si/opensource/v1/opensource.schema.json",
  "title": "Loop open source: fastest-growing AI repositories on GitHub, trending and new models on Hugging Face, new models in the Ollama library",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "version", "generated_at", "license", "sources", "github", "huggingface", "ollama"],
  "properties": {
    "schema": { "const": "https://loop.firmiana.si/opensource/v1/opensource.schema.json" },
    "version": { "const": 1 },
    "generated_at": { "type": "string", "format": "date-time" },
    "license": { "const": "CC-BY-4.0" },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "name", "url", "how"],
        "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "url": { "type": "string", "format": "uri" }, "how": { "type": "string" } }
      }
    },
    "github": {
      "type": "object",
      "additionalProperties": false,
      "required": ["checked_at", "latest", "compared_with", "repos"],
      "properties": {
        "checked_at": { "type": ["string", "null"], "format": "date-time" },
        "latest": { "type": ["string", "null"], "format": "date", "description": "UTC day of the newest star snapshot" },
        "compared_with": {
          "type": "object",
          "additionalProperties": false,
          "required": ["d1", "d7", "d30"],
          "description": "The snapshot day each gain is measured from; null when no snapshot that old exists yet",
          "properties": { "d1": { "$ref": "#/$defs/day" }, "d7": { "$ref": "#/$defs/day" }, "d30": { "$ref": "#/$defs/day" } }
        },
        "repos": { "type": "array", "items": { "$ref": "#/$defs/repo" } }
      }
    },
    "huggingface": {
      "type": "object",
      "additionalProperties": false,
      "required": ["checked_at", "trending", "new", "orgs"],
      "properties": {
        "checked_at": { "type": ["string", "null"], "format": "date-time" },
        "trending": { "type": "array", "items": { "$ref": "#/$defs/hfModel" } },
        "new": { "type": "array", "items": { "$ref": "#/$defs/hfModel" } },
        "orgs": { "type": "array", "items": { "type": "string" } }
      }
    },
    "ollama": {
      "type": "object",
      "additionalProperties": false,
      "required": ["checked_at", "models"],
      "properties": {
        "checked_at": { "type": ["string", "null"], "format": "date-time" },
        "models": { "type": "array", "items": { "$ref": "#/$defs/ollamaModel" } }
      }
    }
  },
  "$defs": {
    "day": { "type": ["string", "null"], "format": "date" },
    "repo": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "repo", "description", "language", "topics", "license", "created_at", "url", "stars", "gain_1d", "gain_7d", "gain_30d", "first_seen"],
      "properties": {
        "id": { "type": "string", "description": "github/<owner>/<name>" },
        "repo": { "type": "string" },
        "description": { "type": ["string", "null"] },
        "language": { "type": ["string", "null"] },
        "topics": { "type": "array", "items": { "type": "string" } },
        "license": { "type": ["string", "null"] },
        "created_at": { "type": ["string", "null"], "format": "date-time" },
        "url": { "type": "string", "format": "uri" },
        "stars": { "type": "integer", "minimum": 0 },
        "gain_1d": { "type": ["integer", "null"], "description": "stars minus stars on compared_with.d1; for a repository created after that day, all its stars" },
        "gain_7d": { "type": ["integer", "null"] },
        "gain_30d": { "type": ["integer", "null"] },
        "first_seen": { "type": "string", "format": "date" }
      }
    },
    "hfModel": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "author", "pipeline_tag", "library", "license", "likes", "downloads", "trending_score", "created_at", "last_modified", "url"],
      "properties": {
        "id": { "type": "string" },
        "author": { "type": "string" },
        "pipeline_tag": { "type": ["string", "null"] },
        "library": { "type": ["string", "null"] },
        "license": { "type": ["string", "null"] },
        "likes": { "type": "integer", "minimum": 0 },
        "downloads": { "type": "integer", "minimum": 0, "description": "downloads in the last 30 days, as reported by Hugging Face" },
        "trending_score": { "type": ["number", "null"] },
        "created_at": { "type": ["string", "null"], "format": "date-time" },
        "last_modified": { "type": ["string", "null"], "format": "date-time" },
        "url": { "type": "string", "format": "uri" }
      }
    },
    "ollamaModel": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "description", "capabilities", "sizes", "pulls", "tags", "updated_at", "first_seen", "newest_rank", "url"],
      "properties": {
        "name": { "type": "string" },
        "description": { "type": ["string", "null"] },
        "capabilities": { "type": "array", "items": { "type": "string" } },
        "sizes": { "type": "array", "items": { "type": "string" } },
        "pulls": { "type": ["integer", "null"], "minimum": 0, "description": "rounded from the page (e.g. 240.1K)" },
        "tags": { "type": ["integer", "null"], "minimum": 0 },
        "updated_at": { "type": ["string", "null"], "format": "date-time" },
        "first_seen": { "type": "string", "format": "date-time", "description": "when this job first saw the model; for the first run, the page's updated time" },
        "newest_rank": { "type": "integer", "minimum": 1 },
        "url": { "type": "string", "format": "uri" }
      }
    }
  }
}
