{
  "openapi": "3.0.0",
  "info": {
    "title": "Calorie Deficit Calculator Mathematical API Specification",
    "version": "1.0.0",
    "description": "Calculates precise daily calorie deficit targets, macronutrient breakdowns, BMR, TDEE, Body Fat percentage and BMI values using clinical standard physiological formulas."
  },
  "servers": [
    {
      "url": "https://caloriedeficitcalculator.co/api/v1",
      "description": "Virtual Mathematical Server (Client-Side JS Engine execution)"
    }
  ],
  "paths": {
    "/calculate": {
      "post": {
        "summary": "Compute client-side BMR, TDEE, Deficit plan, and Macros.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CalculatorInputs"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful calculation output model",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculatorOutputs"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CalculatorInputs": {
        "type": "object",
        "properties": {
          "gender": { "type": "string", "enum": ["male", "female"] },
          "age": { "type": "integer", "minimum": 15, "maximum": 100 },
          "weightKg": { "type": "number", "minimum": 30 },
          "heightCm": { "type": "number", "minimum": 100 },
          "activityLevel": { "type": "string", "enum": ["sedentary", "light", "moderate", "active", "extreme"] },
          "weeklyLossGoalKg": { "type": "number", "enum": [0.25, 0.5, 0.75, 1.0] },
          "targetWeightKg": { "type": "number" }
        },
        "required": ["gender", "age", "weightKg", "heightCm", "activityLevel", "weeklyLossGoalKg", "targetWeightKg"]
      },
      "CalculatorOutputs": {
        "type": "object",
        "properties": {
          "maintenanceCalories": { "type": "integer" },
          "targetCalories": { "type": "integer" },
          "deficit": { "type": "integer" },
          "daysToGoal": { "type": "integer" },
          "weeksToGoal": { "type": "number" },
          "formattedDate": { "type": "string" },
          "isFloorClipped": { "type": "boolean" },
          "macros": {
            "type": "object",
            "properties": {
              "proteinGrams": { "type": "integer" },
              "fatGrams": { "type": "integer" },
              "carbGrams": { "type": "integer" },
              "fiberGrams": { "type": "integer" }
            }
          }
        }
      }
    }
  }
}
