{
  "$schema": "mantara.schema.v1",
  "system_name": "BMI Calculator App",
  "schema_name": "bmi_calc",
  "description": "A web application for calculating and tracking Body Mass Index (BMI)",
  "menus": [
    {
      "menu_id": 1,
      "menu_name": "BMI Calculation",
      "sequence_number": 1,
      "description": "Handles BMI calculations and displays results",
      "submenus": [
        {
          "submenu_id": 101,
          "submenu_name": "Input Form",
          "sequence_number": 1,
          "description": "Allows users to input height and weight for BMI calculation",
          "tables": [
            {
              "table_name": "calculation",
              "comment": "Stores individual BMI calculation records",
              "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": "User-entered height value"
                },
                {
                  "name": "weight",
                  "type": "DECIMAL(10,2)",
                  "constraints": "NOT NULL CHECK (weight > 0)",
                  "comment": "User-entered weight value"
                },
                {
                  "name": "height_unit",
                  "type": "VARCHAR(20)",
                  "constraints": "NOT NULL CHECK (height_unit IN ('cm', 'meters', 'feet', 'inches', 'feet_inches'))",
                  "comment": "Unit of height measurement"
                },
                {
                  "name": "weight_unit",
                  "type": "VARCHAR(20)",
                  "constraints": "NOT NULL CHECK (weight_unit IN ('kg', 'lbs'))",
                  "comment": "Unit of weight measurement"
                },
                {
                  "name": "bmi_value",
                  "type": "DECIMAL(4,1)",
                  "constraints": "NOT NULL CHECK (bmi_value > 0)",
                  "comment": "Calculated BMI value"
                },
                {
                  "name": "bmi_category_id",
                  "type": "UUID",
                  "constraints": "NOT NULL",
                  "comment": "References BMI category"
                },
                {
                  "name": "session_id",
                  "type": "VARCHAR(255)",
                  "comment": "Optional session identifier"
                },
                {
                  "name": "timestamp",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP",
                  "comment": "Time of calculation"
                },
                {
                  "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 history of BMI calculations"
        }
      ]
    },
    {
      "menu_id": 2,
      "menu_name": "BMI Categories",
      "sequence_number": 2,
      "description": "Manages BMI category definitions and classifications",
      "submenus": [
        {
          "submenu_id": 201,
          "submenu_name": "Category Management",
          "sequence_number": 1,
          "description": "Defines BMI categories and their properties",
          "tables": [
            {
              "table_name": "bmi_category",
              "comment": "Defines BMI categories and their classification ranges",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 201 NOT NULL REFERENCES bmi_calc.submenu(submenu_id)"
                },
                {
                  "name": "name",
                  "type": "VARCHAR(50)",
                  "constraints": "NOT NULL UNIQUE CHECK (name IN ('Underweight', 'Normal weight', 'Overweight', 'Obese'))",
                  "comment": "Name of the BMI category"
                },
                {
                  "name": "min_bmi",
                  "type": "DECIMAL(4,2)",
                  "constraints": "NOT NULL CHECK (min_bmi >= 0)",
                  "comment": "Minimum BMI value for category"
                },
                {
                  "name": "max_bmi",
                  "type": "DECIMAL(4,2)",
                  "constraints": "CHECK (max_bmi IS NULL OR max_bmi > min_bmi)",
                  "comment": "Maximum BMI value for category"
                },
                {
                  "name": "description",
                  "type": "TEXT",
                  "comment": "Health information about the category"
                },
                {
                  "name": "color_code",
                  "type": "VARCHAR(7)",
                  "comment": "UI color indicator for the category"
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "assumptions": [
    "Session-based history is stored in browser storage (sessionStorage or localStorage)",
    "BMI categories are predefined and follow WHO standards"
  ],
  "open_questions": [
    "Should the application support multi-language interfaces?",
    "Is there a need for user authentication to persist history across devices?"
  ]
}
