Skip to content

Software Requirement Specification (SRS) - AI-Powered Financial Calculator

FieldDetail
Company Nameruizdev7
Document TitleAI-Powered Financial Calculator - SRS
Document NumberSRS-005
Version1.0
Specification Date17-November-24
StatusImplemented
RoleNameDate
Project ManagerJoseph Ruiz17-November-24
Tech LeadJoseph Ruiz17-November-24
VersionDateChanges MadeAuthor
1.017-November-24Initial SRS DocumentationJoseph Ruiz

This document specifies the requirements for the implementation of an AI-Powered Financial Calculator in the ruizdev7 Portfolio application.
The objective is to provide users with sophisticated financial calculation tools that support investment planning, loan analysis, retirement planning, and financial decision-making with optional AI-powered explanations and insights.

The AI-Powered Financial Calculator includes the following components:

  • Present Value (PV) Calculations: Determine the current value of future cash flows.
  • Future Value (FV) Calculations: Project the future value of current investments.
  • Annuity Calculations: Evaluate the present value of regular payment streams.
  • Compound Interest: Calculate investment growth with periodic compounding.
  • Loan Amortization: Generate detailed payment schedules for loans with principal and interest breakdown.
  • Calculation History: Store and retrieve past calculations for reference.
  • AI Integration: (Optional) OpenAI integration for explaining calculations and providing financial insights.
  • CRUD Operations: Create, read, update, and delete saved calculations.
  • User-Specific Data: Each user maintains their own calculation history.

The implementation ensures:

  • Mathematical accuracy for all financial formulas
  • Data privacy for user financial information
  • Scalable storage for calculation history
  • Integration with authentication system
  • Present Value (PV): The current value of a future sum of money, discounted at a specific interest rate.
  • Future Value (FV): The value of a current investment at a future date based on an assumed growth rate.
  • Annuity: A series of equal payments made at regular intervals.
  • Compound Interest: Interest calculated on the initial principal and accumulated interest from previous periods.
  • Amortization: The process of paying off debt through regular payments over time.
  • Time Periods: The number of compounding periods in a calculation (years, months, quarters).
  • Interest Rate: The percentage rate used for discounting or compounding calculations.

Priority: High
Description:

FieldDetail
Use Case NameCalculate Present Value
Subject AreaFinancial Calculations
Business EventThis use case applies when users need to determine the current value of future money.
ActorsAuthenticated user, ruizdev7 Platform.
Use Case OverviewThis use case covers calculating present value using the formula: PV = FV / (1 + r)^n
PreconditionsUser must be authenticated.
Termination OutcomePresent value is calculated and saved to user’s history.
Condition Affecting OutcomeInvalid input values, mathematical errors, or database failures.
Use Case DescriptionThe system validates inputs (future value, interest rate, time periods), applies the PV formula, stores the calculation with metadata, and returns the result with detailed breakdown.
Use Case AssociationsUC-033: Calculate Future Value, UC-037: View Calculation History.
Traceability ToSRS-005.
Input SummaryTitle, description (optional), future_value (float), interest_rate (%), time_periods (integer).
Output SummaryPresent value, discount factor, total discount amount, input parameters.
Usability IndexHigh, essential for investment evaluation.
Use Case NotesFormula: PV = FV / (1 + r)^n. Interest rate converted from percentage to decimal.
CriterionDescription / Acceptance Condition
Calculation AccuracyAll financial formulas produce mathematically correct results.
Calculation TypesSystem supports PV, FV, Annuity, Compound Interest, and Amortization.
Data PersistenceAll calculations are saved to user’s history.
User IsolationUsers can only access their own calculations.
Input ValidationSystem validates all numeric inputs and returns clear error messages.
Amortization TableLoan amortization generates complete monthly breakdown.
PerformanceCalculations complete in <200ms.
History ManagementUsers can view, update, and delete saved calculations.
PaginationHistory supports pagination for large datasets.
Error HandlingGraceful handling of edge cases (division by zero, negative values).
CategoryRequirement
PerformanceCalculations <200ms, history retrieval <300ms.
AccuracyFloating-point precision to 2 decimal places for monetary values.
SecurityUser data isolation, JWT authentication, input validation.
Availability99.9% uptime for calculator endpoints.
ScalabilitySupport for 100,000+ calculations per user without performance degradation.
UsabilityIntuitive interface with examples and tooltips.
Data IntegrityForeign key constraints, NOT NULL validations.

Table: tbl_financial_calculations

  • id (Primary Key, Auto-increment)
  • user_id (Foreign Key -> tbl_users, Required)
  • calculation_type (Enum: present_value, future_value, annuity, compound_interest, amortization, Required)
  • title (String, Max 200 chars, Required)
  • description (Text, Optional)
  • input_parameters (JSON, All input values)
  • result_value (Decimal(15,2), Main result)
  • result_details (JSON, Detailed breakdown)
  • created_at (Timestamp, Auto-generated)
  • updated_at (Timestamp, Auto-updated)

Present Value:

PV = FV / (1 + r)^n
Where: FV = Future Value, r = Interest Rate, n = Time Periods

Future Value:

FV = PV × (1 + r)^n
Where: PV = Present Value, r = Interest Rate, n = Time Periods

Annuity:

PV = P × [(1 - (1 + r)^-n) / r]
Where: P = Payment, r = Interest Rate, n = Number of Periods

Compound Interest:

A = P × (1 + r/n)^(n×t)
Where: P = Principal, r = Annual Rate, n = Compounding Frequency, t = Time

Loan Payment (PMT):

PMT = P × [r(1 + r)^n] / [(1 + r)^n - 1]
Where: P = Loan Amount, r = Monthly Rate, n = Total Payments
MethodEndpointDescriptionAuthPermission
POST/api/financial-calculatorCreate calculationYesJWT
GET/api/financial-calculatorGet calculations (paginated)YesJWT
GET/api/financial-calculator/{id}Get specific calculationYesJWT
PUT/api/financial-calculator/{id}Update calculationYesJWT
DELETE/api/financial-calculator/{id}Delete calculationYesJWT
GET/api/financial-calculator/typesGet available calculation typesNoNone

FinancialCalculationInputSchema (Marshmallow):

  • calculation_type: Required, One of [present_value, future_value, annuity, compound_interest, amortization]
  • title: Required, String, 1-200 characters
  • description: Optional, String, max 1000 characters
  • Type-specific fields validated based on calculation_type

FinancialCalculatorService:

  • perform_calculation(calc_type, data): Main calculation dispatcher
  • calculate_present_value(fv, rate, periods): PV calculation
  • calculate_future_value(pv, rate, periods): FV calculation
  • calculate_annuity(payment, rate, periods): Annuity calculation
  • calculate_compound_interest(principal, rate, periods, frequency): Compound interest
  • calculate_amortization(loan_amount, rate, term_years): Amortization schedule

AIFinantialCalculator.jsx:

  • Type selection cards with examples
  • Dynamic form based on selected type
  • Result display with detailed breakdown
  • Calculation history table
  • Export functionality

Calculation Type Cards:

  1. Present Value (Target icon)
  2. Future Value (TrendingUp icon)
  3. Annuity (Repeat icon)
  4. Compound Interest (LineChart icon)
  5. Amortization (FileText icon)

Amortization Response:

{
"monthly_payment": 1266.71,
"total_interest": 103610.40,
"total_amount": 303610.40,
"amortization_schedule": [
{
"month": 1,
"payment": 1266.71,
"principal": 516.71,
"interest": 750.00,
"remaining_balance": 199483.29
},
// ... more months
]
}
FieldDetail
Stakeholdersruizdev7 Team, Financial Planning Users
Attachments[CALCULADORA_FINANCIERA_EJEMPLOS.md]
Tech StackFlask, SQLAlchemy, Marshmallow, React
Frontend ComponentsAIFinantialCalculator.jsx
Future EnhancementsOpenAI integration for explanations, chart visualizations, comparison tools
Name/TitleSignatureDate
Client Representativeruizdev717-November-24
Company Representativeruizdev717-November-24