Skip to content

Repository files navigation

RetLax. Retirement Planning Calculator

CI

RetLax is a retirement planning calculator that helps people understand how much they need to save for a comfortable retirement in India. It is built with Next.js 15.5.9 and focuses on inflation, withdrawal tax, glide path, and Monte Carlo risk disclosures.

What is RetLax?

RetLax is a tool that helps people plan for their retirement. It shows them how much they need to save to have a life after they stop working. The results from RetLax are for purposes only and do not guarantee anything.

Features

• RetLax has a 4-Step Guided Wizard that makes it easy to use. • It also has Inflation Bucketing which means it separates rates for types of expenses like general, medical and lifestyle expenses. • RetLax gives credit for Existing Savings so people can see how their current savings will help them in retirement. • It also has a Top-Up SIP feature that helps people save more each year. • Uses Monte Carlo Simulation to show how different scenarios might play out. • It estimates the Break- Age, which is the age when the retirement savings will run out. • Has an Inflation-Adjusted Depletion Table that shows how the savings will be used over time. • The What-If Explorer lets people see how different choices might affect their retirement savings. • Also has a Scenario A vs B Comparison feature that lets people compare scenarios side by side. • Keeps a record of all the changes made to the assumptions so people can see how they affected the results. • RetLax does a Sensitivity Analysis to show how different factors might affect the results. • It is WCAG 2.1 AA Compliant which means it is accessible to people with disabilities. • RetLax can be used offline. Is fully responsive so it works well on all devices. • Has a Dark Mode and can be printed or saved as a PDF. • All the inputs are saved in the URL so people can share their results with others. • RetLax has a disclaimer on every page to remind people that the results are illustrative and not a guarantee.

Tech Stack

Layer Technology
Framework Next.js 15.5.9
Runtime Node.js 22.11.0
Language TypeScript
Styling Pure CSS (no Tailwind)
Fonts Montserrat (Google Fonts)
Testing Jest + ts-jest

Example Scenario

A 30-year-old planner wants to retire at age 60 with a monthly lifestyle budget of ₹50,000 today and expects 6% general inflation, 8% post-retirement return, and 12% pre-retirement return. They also have ₹5,00,000 in existing savings and want a 25-year retirement horizon.

RetLax turns these assumptions into an illustrative plan, including:

  • required retirement corpus,
  • monthly SIP to build the corpus,
  • a Monte Carlo success rate and p10/p90 ending corpus range,
  • a 3×3 sensitivity matrix for inflation and return variation,
  • an annual corpus depletion table that can be exported as CSV,
  • a downloadable text report for summary review.

Getting Started

bash npm install npm run dev # → http://localhost:3000 npm run build # Production build npm run export # Create static export in out/ npm test # Run 25 unit tests

Deployment

This app is ready for static export; run npm run export and host the generated out/ folder on GitHub Pages, Netlify, Vercel, or any static host.

For GitHub Pages, use a static export workflow or a package such as gh-pages to publish the out/ directory.

Project Structure

retirement-calculator/ ├── tests/ │ └── retirement.test.ts # 25 unit tests covering all core functions ├── app/ │ ├── globals.css # Brand design system, dark mode, print, PWA │ ├── layout.tsx # Root layout, metadata, SW registration │ └── page.tsx # Main RetLax page ├── components/ │ ├── steps/ │ │ ├── Step1Age.tsx # Age & timeline (focus-managed) │ │ ├── Step2Expenses.tsx # Expenses + fraction guards (focus-managed) │ │ ├── Step3Assumptions.tsx # Lifestyle presets, returns, existing savings │ │ └── Step4Results.tsx # Full results dashboard │ └── ui/ │ ├── AssumptionChangeLog.tsx # Diff from defaults │ ├── DonutChart.tsx # Pure SVG donut │ ├── FormComponents.tsx # Slider, Input, Tooltip (unique IDs) │ ├── LiveResultsPanel.tsx # Sticky sidebar (no MC jank) │ ├── MonteCarloChart.tsx # Fan chart │ ├── ScenarioComparison.tsx # A vs B table │ ├── Stepper.tsx # Progress stepper (all visited steps clickable) │ └── WhatIfSliders.tsx # Debounced what-if explorer ├── hooks/ │ ├── useAnimatedCounter.ts # Animated number count-up │ ├── useDebounce.ts # 150ms debounce for WhatIf sliders │ └── useRetirementCalc.ts # State, URL sync, scenario management ├── lib/ │ └── retirement.ts # All pure calculation logic └── public/ ├── icon-192.png # PWA icon ├── icon-512.png # PWA icon ├── manifest.json # Web App Manifest └── sw.js # Service Worker

Calculation Logic

Step 1: Inflate Annual Expenses (per bucket) BasicInflated = BasicNow × (1 + generalInflation) ^ yearsToRetirement LifestyleInflated = LifestyleNow × (1 + lifestyleInflation) ^ yearsToRetirement HealthcareInflated = HealthcareNow × (1 + medicalInflation) ^ yearsToRetirement

Step 2: Retirement Corpus (PV of Annuity) Corpus = AnnualExpense × [(1 − (1 + r) ^ −t) ÷ r] where, r = post-retirement return t = years in retirement Existing savings are compounded to retirement at pre-retirement return and deducted.

Step 3: Monthly SIP SIP = Corpus × r ÷ [((1 + r) ^ n − 1) × (1 + r)] where, r = monthly rate n = total months to retirement

Step 3b: Top-Up SIP Binary search (80 iterations) for first-year SIP that compounds to target corpus with annual step-ups.

Monte Carlo

500 log-normal return sequences. Volatility calibrated to portfolio conservatism (7–12%). Reports success rate, p10–p90 fan, and median ruin age. Illustrative only.

Break-Even Age

Iterates year-by-year with inflation-adjusted withdrawals until corpus reaches zero.

Compliance

• RetLax has a disclaimer bar below the header on every screen. • Has a disclaimer on every page. • All outputs are labelled "Illustrative Estimate." • All assumptions are visible and editable. • There is no guarantee language. • There is a "What this doesn't include" disclosure box on the results.

Methodology

A dedicated methodology page is available at /methodology to explain the formulas, risk assumptions, and model limitations in plain language.

Accessibility

• RetLax is accessible to people with disabilities. • Focus moves to heading on every step transition (all 4 steps) • Unique tooltip IDs via useId() — no duplicate aria-describedby targets • aria-live="polite" on results and live panel • role="alert" + aria-live="assertive" on errors • aria-current="step" on active stepper • Screen reader step announcer • All form inputs have associated labels • Keyboard navigation, visible 3px focus rings • Colour contrast ≥ 4.5:1 • forced-colors media query support

Contributing

Please open issues for bugs, enhancement requests, or deployment support. Contributions should keep the tool focused on inflation, withdrawal tax, glide-path risk, and Monte Carlo disclosure.

  • Run locally: npm install && npm run dev
  • Build: npm run build
  • Tests: npm test

Known limitations are called out in the app and README; this repo does not currently support full Indian tax slab modelling or international currency formats.

Contributing

Please open issues for bugs, enhancements, or deployment support. Contributions should keep the tool focused on retirement risk disclosure, inflation modelling, and practical output quality.

  • Run locally: npm install && npm run dev
  • Build: npm run build
  • Tests: npm test

Known limitations are called out in the app and README; this repo does not currently support full Indian tax slab modelling or international currency formats.

License

All code is the intellectual property of the RetLax project contributors.

Video

Google Drive Folder

About

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages