{
  "$schema": "https://json-schema.org/draft-07/schema#",
  "$id": "https://locale-lab.example/atlas/usage-schema.json",
  "title": "Atlas BYO usage dataset",
  "description": "Per-market product usage (DAU/MAU, optional monthly revenue in USD) for the Atlas dual-metric views. Upload at /atlas/data or POST to /api/atlas/usage as application/json. A bare array of market rows is also accepted.",
  "type": "object",
  "required": ["product", "markets"],
  "additionalProperties": true,
  "properties": {
    "product": {
      "type": "string",
      "minLength": 1,
      "description": "Product / app name shown in every readout."
    },
    "asOf": {
      "type": "string",
      "pattern": "^\\d{4}(-\\d{2}){0,2}$",
      "description": "Reporting date for the numbers, ideally YYYY-MM-DD."
    },
    "source": {
      "type": "string",
      "description": "Where the numbers came from (dashboard, warehouse table, …)."
    },
    "markets": {
      "type": "array",
      "minItems": 1,
      "maxItems": 400,
      "items": {
        "type": "object",
        "required": ["country", "mau"],
        "additionalProperties": true,
        "properties": {
          "country": {
            "type": "string",
            "pattern": "^[A-Za-z]{2}$",
            "description": "ISO-3166-1 alpha-2 territory code — the join key across Atlas ('UK' is accepted as 'GB')."
          },
          "mau": {
            "type": ["number", "string"],
            "description": "Monthly active users. Numbers, or strings with separators/suffixes: '12,345', '1.5M', '450k', '2.1B'. 0 is legal (pre-launch market)."
          },
          "dau": {
            "type": ["number", "string"],
            "description": "Daily active users, optional. Same formats as mau."
          },
          "revenue": {
            "type": ["number", "string"],
            "description": "Monthly revenue for this market in USD, optional (aliases accepted: monthly_revenue, revenue_usd, rev, mrr). Same period as mau; no currency conversion is attempted. Same formats as mau, leading '$' tolerated. Must be non-negative — a negative value drops the row."
          },
          "note": {
            "type": "string",
            "maxLength": 200,
            "description": "Free-form annotation, carried through untouched."
          }
        }
      }
    }
  }
}
