# nathoyina/financial-goal-calculator architecture

> Architecture diagram of the GitHub repository nathoyina/financial-goal-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nathoyina/financial-goal-calculator
- Repository: https://github.com/nathoyina/financial-goal-calculator

## Overview

This is a browser-only Singapore retirement-planning app: users enter personal, income, spending, CPF, loan, and education assumptions, then receive a retirement verdict, projected cash and gap, guidance, and a balance chart. The main runtime path runs from the planner UI through form parsing into the plan calculation; CPF projection and education/loan calculations support that result. The README documents the major outputs and inputs. Several subsystem links are based on README descriptions or index references because their full implementation was not sampled; no account or server-side persistence is documented.

Main entry points: [`src/components/planner-app.tsx`](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/planner-app.tsx) (Planner workflow), [`src/lib/finance/plan.ts`](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/plan.ts) (Retirement projection), [`src/lib/finance/plan-form.ts`](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/plan-form.ts) (Form validation), [`src/lib/finance/suggestion-preview.ts`](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/suggestion-preview.ts) (Gap suggestions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Planner experience"]
  node_app["Planner workflow<br/>[planner-app.tsx]"]
  node_field["Number fields<br/>[number-field.tsx]"]
  node_education_ui["Child education"]
  node_suggest_ui["Suggestion preview UI"]
  node_estimate["Estimate labels<br/>[estimate-tag.tsx]"]
  node_analytics["In-memory analytics<br/>[track.ts]"]
end

subgraph group_inputs["Plan inputs"]
  node_form["Form validation<br/>[plan-form.ts]"]
  node_education_choice["Education choices"]
  node_education_presets["Education presets<br/>[constants.ts]"]
  node_registry["Goal registry<br/>[registry.ts]"]
end

subgraph group_calculation["Projection engine"]
  node_plan["Retirement projection<br/>[plan.ts]"]
  node_cpf["CPF projection<br/>[project.ts]"]
  node_cpf_tables["CPF reference tables<br/>[constants.ts]"]
  node_loan["Housing loan<br/>[loan.ts]"]
  node_education_cost["Education costs<br/>[education.ts]"]
  node_rates["Return rates<br/>[rates.ts]"]
end

subgraph group_results["Results and guidance"]
  node_guidance["Retirement guidance<br/>[guidance.ts]"]
  node_suggestions["Gap suggestions"]
  node_chart["Balance chart<br/>[balance-chart.tsx]"]
  node_format["Financial formatting<br/>[format.ts]"]
end

node_user(("Planner user"))

node_user -->|"enters assumptions"| node_app
node_app -->|"renders fields"| node_field
node_app -->|"renders education"| node_education_ui
node_app -->|"renders labels"| node_estimate
node_app -->|"parses plan"| node_form
node_education_ui -->|"uses choices"| node_education_choice
node_education_choice -->|"reads presets"| node_education_presets
node_form -->|"parses education"| node_education_choice
node_form -->|"calculates plan"| node_plan
node_plan -->|"projects CPF"| node_cpf
node_cpf -->|"reads tables"| node_cpf_tables
node_plan -->|"uses loan schedule"| node_loan
node_plan -->|"projects withdrawals"| node_education_cost
node_plan -->|"computes returns"| node_rates
node_app -->|"renders suggestions"| node_suggest_ui
node_suggest_ui -->|"builds previews"| node_suggestions
node_suggestions -->|"reparses changes"| node_form
node_suggestions -->|"recalculates preview"| node_plan
node_app -->|"renders projection"| node_chart
node_chart -->|"formats values"| node_format
node_chart -->|"converts balances"| node_guidance
node_plan -->|"uses guidance"| node_guidance
node_guidance -->|"uses contributions"| node_cpf
node_app -.->|"tracks events"| node_analytics
node_registry -->|"registers retirement"| node_plan

click node_app "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/planner-app.tsx"
click node_field "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/number-field.tsx"
click node_education_ui "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/child-education.tsx"
click node_suggest_ui "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/suggestion-preview.tsx"
click node_estimate "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/estimate-tag.tsx"
click node_form "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/plan-form.ts"
click node_education_choice "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/education-choice.ts"
click node_education_presets "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/education/constants.ts"
click node_plan "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/plan.ts"
click node_cpf "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/cpf/project.ts"
click node_cpf_tables "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/cpf/constants.ts"
click node_loan "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/loan.ts"
click node_education_cost "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/education.ts"
click node_rates "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/rates.ts"
click node_guidance "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/guidance.ts"
click node_suggestions "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/suggestion-preview.ts"
click node_chart "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/balance-chart.tsx"
click node_format "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/format.ts"
click node_analytics "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/analytics/track.ts"
click node_registry "https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/goals/registry.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_field,node_education_ui,node_suggest_ui,node_estimate,node_analytics,node_user toneBlue
class node_form,node_education_choice,node_education_presets,node_registry toneAmber
class node_plan,node_cpf,node_cpf_tables,node_loan,node_education_cost,node_rates toneMint
class node_guidance,node_suggestions,node_chart,node_format toneRose
```

## Components

### Planner experience

- [Planner workflow](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/planner-app.tsx): `src/components/planner-app.tsx`
- [Number fields](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/number-field.tsx): `src/components/number-field.tsx`
- [Child education](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/child-education.tsx): `src/components/child-education.tsx`
- [Suggestion preview UI](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/suggestion-preview.tsx): `src/components/suggestion-preview.tsx`
- [Estimate labels](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/estimate-tag.tsx): `src/components/estimate-tag.tsx`
- [In-memory analytics](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/analytics/track.ts): `src/lib/analytics/track.ts`

### Plan inputs

- [Form validation](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/plan-form.ts): `src/lib/finance/plan-form.ts`
- [Education choices](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/education-choice.ts): `src/lib/finance/education-choice.ts`
- [Education presets](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/education/constants.ts): `src/lib/education/constants.ts`
- [Goal registry](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/goals/registry.ts): `src/lib/goals/registry.ts`

### Projection engine

- [Retirement projection](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/plan.ts): `src/lib/finance/plan.ts`
- [CPF projection](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/cpf/project.ts): `src/lib/cpf/project.ts`
- [CPF reference tables](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/cpf/constants.ts): `src/lib/cpf/constants.ts`
- [Housing loan](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/loan.ts): `src/lib/finance/loan.ts`
- [Education costs](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/education.ts): `src/lib/finance/education.ts`
- [Return rates](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/rates.ts): `src/lib/finance/rates.ts`

### Results and guidance

- [Retirement guidance](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/guidance.ts): `src/lib/finance/guidance.ts`
- [Gap suggestions](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/suggestion-preview.ts): `src/lib/finance/suggestion-preview.ts`
- [Balance chart](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/components/balance-chart.tsx): `src/components/balance-chart.tsx`
- [Financial formatting](https://github.com/nathoyina/financial-goal-calculator/blob/main/src/lib/finance/format.ts): `src/lib/finance/format.ts`

### Other components

- **Planner user**

## Connections

- Planner user → Planner workflow: enters assumptions (evidence: `README.md`)
- Planner workflow → Number fields: renders fields (evidence: `src/components/planner-app.tsx`)
- Planner workflow → Child education: renders education (evidence: `src/components/planner-app.tsx`)
- Planner workflow → Estimate labels: renders labels (evidence: `src/components/planner-app.tsx`)
- Planner workflow → Form validation: parses plan (evidence: `src/components/planner-app.tsx`)
- Child education → Education choices: uses choices (evidence: `src/components/child-education.tsx`)
- Education choices → Education presets: reads presets (evidence: `src/lib/finance/education-choice.ts`)
- Form validation → Education choices: parses education (evidence: `src/lib/finance/plan-form.ts`)
- Form validation → Retirement projection: calculates plan (evidence: `src/lib/finance/plan-form.ts`)
- Retirement projection → CPF projection: projects CPF (evidence: `src/lib/finance/plan.ts`)
- CPF projection → CPF reference tables: reads tables (evidence: `src/lib/cpf/project.ts`)
- Retirement projection → Housing loan: uses loan schedule (evidence: `src/lib/finance/plan.ts`)
- Retirement projection → Education costs: projects withdrawals (evidence: `src/lib/finance/plan.ts`)
- Retirement projection → Return rates: computes returns (evidence: `src/lib/finance/plan.ts`)
- Planner workflow → Suggestion preview UI: renders suggestions (evidence: `src/components/planner-app.tsx`)
- Suggestion preview UI → Gap suggestions: builds previews (evidence: `src/components/suggestion-preview.tsx`)
- Gap suggestions → Form validation: reparses changes (evidence: `src/lib/finance/suggestion-preview.ts`)
- Gap suggestions → Retirement projection: recalculates preview (evidence: `src/lib/finance/suggestion-preview.ts`)
- Planner workflow → Balance chart: renders projection (evidence: `src/components/planner-app.tsx`)
- Balance chart → Financial formatting: formats values (evidence: `src/components/balance-chart.tsx`)
- Balance chart → Retirement guidance: converts balances (evidence: `src/components/balance-chart.tsx`)
- Retirement projection → Retirement guidance: uses guidance (evidence: `src/lib/finance/plan.ts`)
- Retirement guidance → CPF projection: uses contributions (evidence: `src/lib/finance/guidance.ts`)
- Planner workflow → In-memory analytics: tracks events (evidence: `src/components/planner-app.tsx`)
- Goal registry → Retirement projection: registers retirement (evidence: `src/lib/goals/registry.ts`)
