{
  "$schema": "mantara.schema.v1",
  "system_name": "Simple SIP Calculator",
  "schema_name": "sip_calc",
  "description": "A web application for calculating future value of SIP investments without data persistence.",
  "menus": [
    {
      "menu_id": 1,
      "menu_name": "Calculation",
      "sequence_number": 1,
      "description": "Handles the input and calculation of SIP values.",
      "submenus": [
        {
          "submenu_id": 101,
          "submenu_name": "Input Parameters",
          "sequence_number": 1,
          "description": "Captures user input for SIP calculation.",
          "tables": [
            {
              "table_name": "calculation_input",
              "comment": "Stores the parameters for SIP calculation provided by the user.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 101 NOT NULL REFERENCES sip_calc.submenu(submenu_id)"
                },
                {
                  "name": "monthly_investment",
                  "type": "NUMERIC(15, 2)",
                  "constraints": "NOT NULL CHECK (monthly_investment >= 1 AND monthly_investment <= 10000000)",
                  "comment": "Monthly investment amount in currency units."
                },
                {
                  "name": "annual_return_rate",
                  "type": "NUMERIC(5, 2)",
                  "constraints": "NOT NULL CHECK (annual_return_rate >= 0.1 AND annual_return_rate <= 50)",
                  "comment": "Expected annual return rate as a percentage."
                },
                {
                  "name": "investment_period",
                  "type": "INTEGER",
                  "constraints": "NOT NULL CHECK (investment_period >= 1)",
                  "comment": "Duration of the investment in months or years."
                },
                {
                  "name": "period_unit",
                  "type": "VARCHAR(10)",
                  "constraints": "NOT NULL CHECK (period_unit IN ('months', 'years'))",
                  "comment": "Unit of the investment period, either months or years."
                },
                {
                  "name": "created_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                },
                {
                  "name": "updated_at",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 102,
          "submenu_name": "Calculation Results",
          "sequence_number": 2,
          "description": "Stores the results of the SIP calculation.",
          "tables": [
            {
              "table_name": "calculation_result",
              "comment": "Stores the results of the SIP calculation based on user input.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 102 NOT NULL REFERENCES sip_calc.submenu(submenu_id)"
                },
                {
                  "name": "calculation_input_id",
                  "type": "UUID",
                  "constraints": "NOT NULL",
                  "comment": "References the input parameters used for this calculation."
                },
                {
                  "name": "total_investment",
                  "type": "NUMERIC(15, 2)",
                  "constraints": "NOT NULL",
                  "comment": "Total amount invested over the period."
                },
                {
                  "name": "estimated_returns",
                  "type": "NUMERIC(15, 2)",
                  "constraints": "NOT NULL",
                  "comment": "Wealth gained from the investment."
                },
                {
                  "name": "future_value",
                  "type": "NUMERIC(15, 2)",
                  "constraints": "NOT NULL",
                  "comment": "Final maturity amount (total investment + returns)."
                },
                {
                  "name": "calculation_timestamp",
                  "type": "TIMESTAMP",
                  "constraints": "NOT NULL DEFAULT CURRENT_TIMESTAMP",
                  "comment": "Timestamp 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": "calculation_input_id",
                  "references": "sip_calc.calculation_input(id)",
                  "on_delete": "CASCADE"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 2,
      "menu_name": "Visualization",
      "sequence_number": 2,
      "description": "Handles the visualization of SIP calculation results.",
      "submenus": [
        {
          "submenu_id": 201,
          "submenu_name": "Growth Chart",
          "sequence_number": 1,
          "description": "Stores data points for visualizing investment growth over time.",
          "tables": [
            {
              "table_name": "chart_data_point",
              "comment": "Stores data points for the growth chart of SIP investments.",
              "columns": [
                {
                  "name": "id",
                  "type": "UUID",
                  "constraints": "PRIMARY KEY DEFAULT gen_random_uuid()"
                },
                {
                  "name": "submenu_id",
                  "type": "INT",
                  "constraints": "DEFAULT 201 NOT NULL REFERENCES sip_calc.submenu(submenu_id)"
                },
                {
                  "name": "calculation_result_id",
                  "type": "UUID",
                  "constraints": "NOT NULL",
                  "comment": "References the calculation result this data point belongs to."
                },
                {
                  "name": "period",
                  "type": "INTEGER",
                  "constraints": "NOT NULL",
                  "comment": "Time period (month/year number) for this data point."
                },
                {
                  "name": "invested_amount",
                  "type": "NUMERIC(15, 2)",
                  "constraints": "NOT NULL",
                  "comment": "Cumulative investment at this point in time."
                },
                {
                  "name": "projected_value",
                  "type": "NUMERIC(15, 2)",
                  "constraints": "NOT NULL",
                  "comment": "Projected portfolio value at this point in time."
                },
                {
                  "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": "calculation_result_id",
                  "references": "sip_calc.calculation_result(id)",
                  "on_delete": "CASCADE"
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "enum_types": [
    {
      "type_name": "sip_calc.period_unit_enum",
      "values": [
        "months",
        "years"
      ],
      "description": "Indicates whether the investment period is in months or years."
    }
  ],
  "assumptions": [
    "The system does not require data persistence beyond the session.",
    "Calculations are performed client-side without server interaction."
  ],
  "open_questions": [
    "Should the system support additional currencies beyond USD and INR?",
    "Is there a need for more detailed breakdowns of investment growth over time?"
  ]
}
