{
  "$schema": "mantara.schema.v1",
  "system_name": "Simple Interest Calculator",
  "schema_name": "sic",
  "description": "A web application for calculating simple interest on principal amounts.",
  "menus": [
    {
      "menu_id": 1,
      "menu_name": "Calculation Management",
      "sequence_number": 1,
      "description": "Manage and perform simple interest calculations.",
      "submenus": [
        {
          "submenu_id": 101,
          "submenu_name": "Perform Calculation",
          "sequence_number": 1,
          "description": "Interface for performing simple interest calculations.",
          "tables": [
            {
              "table_name": "sessions",
              "comment": "Stores session information for grouping calculations.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "session_identifier",
                  "type": "VARCHAR(255)",
                  "constraints": "NOT NULL UNIQUE",
                  "comment": "Unique identifier for the browser session."
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            },
            {
              "table_name": "calculations",
              "comment": "Stores individual simple interest 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 sic.submenu(submenu_id)"
                },
                {
                  "name": "session_id",
                  "type": "UUID",
                  "constraints": "NOT NULL",
                  "comment": "References the session in which the calculation was performed."
                },
                {
                  "name": "principal",
                  "type": "DECIMAL(15,2)",
                  "constraints": "NOT NULL CHECK (principal > 0)",
                  "comment": "The initial amount of money (loan or investment)."
                },
                {
                  "name": "rate",
                  "type": "DECIMAL(8,4)",
                  "constraints": "NOT NULL CHECK (rate >= 0)",
                  "comment": "Annual interest rate as a percentage."
                },
                {
                  "name": "time",
                  "type": "DECIMAL(10,4)",
                  "constraints": "NOT NULL CHECK (time > 0)",
                  "comment": "Time period in years."
                },
                {
                  "name": "time_unit",
                  "type": "VARCHAR(10)",
                  "constraints": "NOT NULL CHECK (time_unit IN ('years', 'months'))",
                  "comment": "Unit of time for the calculation, either 'years' or 'months'."
                },
                {
                  "name": "interest",
                  "type": "DECIMAL(15,2)",
                  "constraints": "NOT NULL",
                  "comment": "Calculated simple interest amount."
                },
                {
                  "name": "total_amount",
                  "type": "DECIMAL(15,2)",
                  "constraints": "NOT NULL",
                  "comment": "Total amount including principal and interest."
                },
                {
                  "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": "session_id",
                  "references": "sic.sessions(id)",
                  "on_delete": "CASCADE"
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "assumptions": [
    "Each calculation is associated with a unique browser session.",
    "Calculations are stored temporarily and are not persisted beyond the session."
  ],
  "open_questions": [
    "Should there be a limit to the number of calculations stored per session beyond the specified 10?",
    "Is there a need for additional user roles beyond the anonymous user?"
  ]
}
