{
  "$schema": "mantara.schema.v1",
  "system_name": "BMI Calculator App",
  "schema_name": "bmi_calc",
  "description": "A web application for calculating BMI and storing calculation history.",
  "menus": [
    {
      "menu_id": 1,
      "menu_name": "Calculation Management",
      "sequence_number": 1,
      "description": "Manage BMI calculations and history.",
      "submenus": [
        {
          "submenu_id": 101,
          "submenu_name": "Perform Calculation",
          "sequence_number": 1,
          "description": "Allows users to perform BMI calculations and view results.",
          "tables": [
            {
              "table_name": "calculation",
              "comment": "Stores individual BMI calculations performed by users.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 101 NOT NULL REFERENCES bmi_calc.submenu(submenu_id)"
                },
                {
                  "name": "height",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL CHECK (height > 0)",
                  "comment": "Height value entered by user"
                },
                {
                  "name": "weight",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL CHECK (weight > 0)",
                  "comment": "Weight value entered by user"
                },
                {
                  "name": "height_unit",
                  "type": "VARCHAR(10)",
                  "constraints": "NOT NULL CHECK (height_unit IN ('cm', 'm', 'ft', 'in'))",
                  "comment": "Unit of height measurement"
                },
                {
                  "name": "weight_unit",
                  "type": "VARCHAR(10)",
                  "constraints": "NOT NULL CHECK (weight_unit IN ('kg', 'lbs'))",
                  "comment": "Unit of weight measurement"
                },
                {
                  "name": "bmi_value",
                  "type": "DECIMAL(5,2)",
                  "constraints": "NOT NULL CHECK (bmi_value >= 0)",
                  "comment": "Calculated BMI result"
                },
                {
                  "name": "category",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL",
                  "comment": "Health category classification"
                },
                {
                  "name": "bmi_category_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES bmi_calc.bmi_category(id) ON DELETE RESTRICT",
                  "comment": "References the BMI category"
                },
                {
                  "name": "session_id",
                  "type": "VARCHAR(255)",
                  "comment": "Session identifier for calculation history"
                },
                {
                  "name": "timestamp",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP",
                  "comment": "When the calculation was performed"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ],
              "foreign_keys": [
                {
                  "column": "bmi_category_id",
                  "references": "bmi_calc.bmi_category(id)",
                  "on_delete": "RESTRICT"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 102,
          "submenu_name": "Calculation History",
          "sequence_number": 2,
          "description": "Displays the history of BMI calculations for the current session."
        }
      ]
    }
  ],
  "assumptions": [
    "Calculations are stored in browser session/local storage and not persisted in a database.",
    "Each calculation is associated with a single BMI category based on the calculated value."
  ],
  "open_questions": [
    "Should the application support user accounts for persistent history across sessions?",
    "Is there a need for additional health metrics beyond BMI?"
  ]
}
