{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://cocoffee.app/recipe.schema.json",
  "title": "CoCoffee recipe",
  "description": "One coffee bag as read from its label and the brew recipes CoCoffee generated for it — filter methods, espresso, and the machine profiles we push to Fellow Aiden, Fellow Espresso One and xBloom. Published under CC0-1.0: use it, map it to your machine, credit CoCoffee if you like.",
  "license": "CC0-1.0",
  "type": "object",
  "required": [
    "schema_version",
    "id",
    "coffee",
    "methods"
  ],
  "properties": {
    "$schema": {
      "type": "string"
    },
    "schema_version": {
      "type": "string",
      "const": "1.0"
    },
    "id": {
      "type": "string",
      "description": "CoCoffee coffee id"
    },
    "url": {
      "type": "string",
      "format": "uri",
      "description": "the coffee's public page"
    },
    "license": {
      "type": "string",
      "const": "CC0-1.0"
    },
    "generated_by": {
      "type": "string"
    },
    "engine_version": {
      "type": [
        "string",
        "null"
      ],
      "description": "prompt|corpus|preferences signature the recipe was generated with"
    },
    "created_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "coffee": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "roaster",
        "name",
        "origin",
        "origin_iso2",
        "region",
        "altitude_m",
        "varietal",
        "process",
        "roast_level",
        "roast_date",
        "tasting_notes",
        "roast_intent",
        "decaf"
      ],
      "properties": {
        "roaster": {
          "type": [
            "string",
            "null"
          ]
        },
        "name": {
          "type": "string"
        },
        "origin": {
          "type": "string"
        },
        "origin_iso2": {
          "type": "string"
        },
        "region": {
          "type": [
            "string",
            "null"
          ]
        },
        "altitude_m": {
          "type": [
            "integer",
            "null"
          ]
        },
        "varietal": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "process": {
          "type": "string",
          "enum": [
            "washed",
            "natural",
            "honey",
            "anaerobic",
            "other"
          ]
        },
        "roast_level": {
          "type": "string",
          "enum": [
            "light",
            "medium-light",
            "medium",
            "medium-dark",
            "dark"
          ]
        },
        "roast_date": {
          "type": [
            "string",
            "null"
          ]
        },
        "tasting_notes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "roast_intent": {
          "type": "string",
          "enum": [
            "filter",
            "espresso",
            "omni",
            "unknown"
          ]
        },
        "decaf": {
          "type": "boolean"
        }
      }
    },
    "flavor_expectation": {
      "type": [
        "string",
        "null"
      ]
    },
    "grind": {
      "type": "object",
      "properties": {
        "single": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "microns": {
                  "type": "integer",
                  "description": "target particle size, µm"
                },
                "settings": {
                  "type": "object",
                  "additionalProperties": {
                    "type": [
                      "number",
                      "string"
                    ]
                  },
                  "description": "dial positions on common grinders, keyed by grinder id"
                }
              },
              "required": [
                "microns"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "batch": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "microns": {
                  "type": "integer",
                  "description": "target particle size, µm"
                },
                "settings": {
                  "type": "object",
                  "additionalProperties": {
                    "type": [
                      "number",
                      "string"
                    ]
                  },
                  "description": "dial positions on common grinders, keyed by grinder id"
                }
              },
              "required": [
                "microns"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "espresso": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "microns": {
                  "type": "integer",
                  "description": "target particle size, µm"
                },
                "settings": {
                  "type": "object",
                  "additionalProperties": {
                    "type": [
                      "number",
                      "string"
                    ]
                  },
                  "description": "dial positions on common grinders, keyed by grinder id"
                }
              },
              "required": [
                "microns"
              ]
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "methods": {
      "type": "object",
      "description": "one block per brewer; a block is null when the engine didn't produce it",
      "properties": {
        "v60": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "dose_g",
                "water_g",
                "ratio",
                "water_temp_c",
                "grind_microns",
                "bloom",
                "pours",
                "total_brew_time_s"
              ],
              "properties": {
                "dose_g": {
                  "type": "integer"
                },
                "water_g": {
                  "type": "integer"
                },
                "ratio": {
                  "type": "string"
                },
                "water_temp_c": {
                  "type": "integer"
                },
                "grind_microns": {
                  "type": "integer"
                },
                "bloom": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "water_g",
                    "time_s",
                    "agitation"
                  ],
                  "properties": {
                    "water_g": {
                      "type": "integer"
                    },
                    "time_s": {
                      "type": "integer"
                    },
                    "agitation": {
                      "type": "string"
                    }
                  }
                },
                "pours": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "at_time_s",
                      "water_g",
                      "technique"
                    ],
                    "properties": {
                      "at_time_s": {
                        "type": "integer"
                      },
                      "water_g": {
                        "type": "integer"
                      },
                      "technique": {
                        "type": "string"
                      }
                    }
                  }
                },
                "total_brew_time_s": {
                  "type": "integer"
                }
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "aeropress": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "style",
                "style_reason",
                "dose_g",
                "water_g",
                "ratio",
                "water_temp_c",
                "grind_microns",
                "steps",
                "total_brew_time_s"
              ],
              "properties": {
                "style": {
                  "type": "string",
                  "enum": [
                    "standard",
                    "inverted"
                  ]
                },
                "style_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "dose_g": {
                  "type": "integer"
                },
                "water_g": {
                  "type": "integer"
                },
                "ratio": {
                  "type": "string"
                },
                "water_temp_c": {
                  "type": "integer"
                },
                "grind_microns": {
                  "type": "integer"
                },
                "steps": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "at_time_s",
                      "action"
                    ],
                    "properties": {
                      "at_time_s": {
                        "type": "integer"
                      },
                      "action": {
                        "type": "string"
                      },
                      "details": {
                        "type": "string"
                      }
                    }
                  }
                },
                "total_brew_time_s": {
                  "type": "integer"
                }
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "espresso": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "dose_g",
                "yield_g",
                "time_s",
                "water_temp_c",
                "ratio_label",
                "grind_microns",
                "pressure_bar",
                "preinfusion_s",
                "notes"
              ],
              "properties": {
                "dose_g": {
                  "type": "integer"
                },
                "yield_g": {
                  "type": "integer"
                },
                "time_s": {
                  "type": "integer"
                },
                "water_temp_c": {
                  "type": "integer"
                },
                "ratio_label": {
                  "type": "string"
                },
                "grind_microns": {
                  "type": "integer"
                },
                "pressure_bar": {
                  "type": "integer"
                },
                "preinfusion_s": {
                  "type": "integer"
                },
                "notes": {
                  "type": "string"
                }
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "americano": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "dose_g",
                "yield_g",
                "water_g",
                "water_prep_temp_c",
                "shot_temp_c",
                "shot_time_s",
                "grind_microns",
                "notes"
              ],
              "properties": {
                "dose_g": {
                  "type": "integer"
                },
                "yield_g": {
                  "type": "integer"
                },
                "water_g": {
                  "type": "integer"
                },
                "water_prep_temp_c": {
                  "type": "integer"
                },
                "shot_temp_c": {
                  "type": "integer"
                },
                "shot_time_s": {
                  "type": "integer"
                },
                "grind_microns": {
                  "type": "integer"
                },
                "notes": {
                  "type": "string"
                }
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "xbloom": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "dose_g",
                "water_g",
                "ratio",
                "grind_microns",
                "phases"
              ],
              "properties": {
                "dose_g": {
                  "type": "integer"
                },
                "water_g": {
                  "type": "integer"
                },
                "ratio": {
                  "type": "string"
                },
                "grind_microns": {
                  "type": "integer"
                },
                "phases": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "name",
                      "water_ml",
                      "flow_ml_s",
                      "hold_s",
                      "temp_c",
                      "agitation"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "water_ml": {
                        "type": "integer"
                      },
                      "flow_ml_s": {
                        "type": "number"
                      },
                      "hold_s": {
                        "type": "integer"
                      },
                      "temp_c": {
                        "type": "integer"
                      },
                      "agitation": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "aiden": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title",
                "ratio",
                "bloomEnabled",
                "bloomRatio",
                "bloomDuration",
                "bloomTemperature",
                "ssPulsesEnabled",
                "ssPulsesNumber",
                "ssPulsesInterval",
                "ssPulseTemperatures",
                "batchPulsesEnabled",
                "batchPulsesNumber",
                "batchPulsesInterval",
                "batchPulseTemperatures"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "ratio": {
                  "type": "number"
                },
                "bloomEnabled": {
                  "type": "boolean"
                },
                "bloomRatio": {
                  "type": "number"
                },
                "bloomDuration": {
                  "type": "integer"
                },
                "bloomTemperature": {
                  "type": "integer"
                },
                "ssPulsesEnabled": {
                  "type": "boolean"
                },
                "ssPulsesNumber": {
                  "type": "integer"
                },
                "ssPulsesInterval": {
                  "type": "integer"
                },
                "ssPulseTemperatures": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  }
                },
                "batchPulsesEnabled": {
                  "type": "boolean"
                },
                "batchPulsesNumber": {
                  "type": "integer"
                },
                "batchPulsesInterval": {
                  "type": "integer"
                },
                "batchPulseTemperatures": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  }
                }
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "es1": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title",
                "dose",
                "ratio",
                "temperature",
                "transition",
                "adaptive",
                "decliningTemp",
                "preInfusionEnabled",
                "preInfusionHoldPressure",
                "preInfusionFillFlowRate",
                "preInfusionDuration",
                "infusion",
                "rampDownEnabled",
                "rampDownEndPressure",
                "rampDownDuration",
                "style",
                "style_reason"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "dose": {
                  "type": "number"
                },
                "ratio": {
                  "type": "number"
                },
                "temperature": {
                  "type": "number"
                },
                "transition": {
                  "type": "string",
                  "enum": [
                    "smooth",
                    "fast",
                    "step"
                  ]
                },
                "adaptive": {
                  "type": "boolean"
                },
                "decliningTemp": {
                  "type": "string",
                  "enum": [
                    "on",
                    "off"
                  ]
                },
                "preInfusionEnabled": {
                  "type": "boolean"
                },
                "preInfusionHoldPressure": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "preInfusionFillFlowRate": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "preInfusionDuration": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "infusion": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "duration",
                      "pressure"
                    ],
                    "properties": {
                      "duration": {
                        "type": "number"
                      },
                      "pressure": {
                        "type": "number"
                      }
                    }
                  }
                },
                "rampDownEnabled": {
                  "type": "boolean"
                },
                "rampDownEndPressure": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "rampDownDuration": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "style": {
                  "type": "string"
                },
                "style_reason": {
                  "type": "string"
                }
              }
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "device_links": {
      "type": "object",
      "description": "ready-to-open links we already minted (null until someone opens that device)",
      "properties": {
        "aiden": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "es1": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "xbloom": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        }
      }
    }
  }
}
