{
  "$schema": "mantara.schema.v1",
  "system_name": "SIP Calculator",
  "schema_name": "ai_sch_jay_mata_di",
  "description": "A financial tool for calculating potential returns from systematic investments.",
  "menus": [
    {
      "menu_id": 1,
      "menu_name": "Calculation Management",
      "sequence_number": 1,
      "description": "Handles the input and output of SIP calculations.",
      "submenus": [
        {
          "submenu_id": 101,
          "submenu_name": "Input Parameters",
          "sequence_number": 1,
          "description": "Stores user-provided parameters for SIP calculations.",
          "tables": [
            {
              "table_name": "calculation_inputs",
              "comment": "Stores the parameters for each SIP calculation performed 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": "DECIMAL(12,2)",
                  "constraints": "NOT NULL CHECK (monthly_investment >= 0)",
                  "comment": "Monthly investment amount in currency units."
                },
                {
                  "name": "expected_return_rate",
                  "type": "DECIMAL(5,2)",
                  "constraints": "NOT NULL CHECK (expected_return_rate >= 0 AND expected_return_rate <= 100)",
                  "comment": "Expected annual return rate as a percentage."
                },
                {
                  "name": "time_period",
                  "type": "INTEGER",
                  "constraints": "NOT NULL CHECK (time_period > 0)",
                  "comment": "Investment duration in years."
                },
                {
                  "name": "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"
                }
              ]
            }
          ]
        },
        {
          "submenu_id": 102,
          "submenu_name": "Calculation Results",
          "sequence_number": 2,
          "description": "Stores the results of SIP calculations.",
          "tables": [
            {
              "table_name": "calculation_results",
              "comment": "Stores the results of each SIP calculation, including total investment and maturity value.",
              "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 REFERENCES sip_calc.calculation_inputs(id) ON DELETE CASCADE",
                  "comment": "Reference to the input parameters used for this calculation."
                },
                {
                  "name": "total_investment",
                  "type": "DECIMAL(15,2)",
                  "constraints": "NOT NULL CHECK (total_investment >= 0)",
                  "comment": "Total amount invested over the period."
                },
                {
                  "name": "estimated_returns",
                  "type": "DECIMAL(15,2)",
                  "constraints": "NOT NULL",
                  "comment": "Wealth gained through compounding."
                },
                {
                  "name": "maturity_value",
                  "type": "DECIMAL(15,2)",
                  "constraints": "NOT NULL CHECK (maturity_value >= 0)",
                  "comment": "Total corpus at the end of the investment period."
                },
                {
                  "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_inputs(id)",
                  "on_delete": "CASCADE"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "menu_id": 2,
      "menu_name": "Visualization Management",
      "sequence_number": 2,
      "description": "Handles the visualization of SIP calculation results.",
      "submenus": [
        {
          "submenu_id": 201,
          "submenu_name": "Chart Data Points",
          "sequence_number": 1,
          "description": "Stores data points for visualizing investment growth over time.",
          "tables": [
            {
              "table_name": "chart_data_points",
              "comment": "Stores data points for each year of the investment, used for charting growth.",
              "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_input_id",
                  "type": "UUID",
                  "constraints": "NOT NULL REFERENCES sip_calc.calculation_inputs(id) ON DELETE CASCADE",
                  "comment": "Reference to the calculation input this data point belongs to."
                },
                {
                  "name": "year",
                  "type": "INTEGER",
                  "constraints": "NOT NULL CHECK (year > 0)",
                  "comment": "Year number in the investment timeline."
                },
                {
                  "name": "invested_amount",
                  "type": "DECIMAL(15,2)",
                  "constraints": "NOT NULL CHECK (invested_amount >= 0)",
                  "comment": "Cumulative amount invested up to this year."
                },
                {
                  "name": "projected_value",
                  "type": "DECIMAL(15,2)",
                  "constraints": "NOT NULL CHECK (projected_value >= 0)",
                  "comment": "Projected portfolio value at this year."
                },
                {
                  "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_inputs(id)",
                  "on_delete": "CASCADE"
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "assumptions": [
    "The system is stateless and does not require persistent storage beyond session duration.",
    "All calculations are performed client-side with no server-side processing."
  ],
  "open_questions": [
    "Should the system support different compounding frequencies beyond monthly?",
    "Is there a need for exporting calculation results to a file format like CSV or PDF?"
  ],
  "run_id": "jay_mata_di"
}
