Modern, responsive web app for running common personal finance calculations (mortgages and timeβvalueβofβmoney) with clear summaries and interactive charts. Built with React, Vite, and Recharts.
- π Mortgage Calculator - Calculate monthly payments, amortization schedules, and see the impact of extra payments
- π° Time Value of Money (TVM) - Future Value, Present Value, and Annuity Payment calculators
- π Interactive Charts - Visualize payment breakdowns and amortization schedules
- π¨ Beautiful UI - Modern design inspired by mortgagecalculator.org
- π± Responsive - Works perfectly on desktop, tablet, and mobile devices
- Node.js 18+ and npm (matches CI and
npm run verify:calculations)
# Install dependencies
npm install
# Start development server
npm run devThe app will be available at http://localhost:3000
npm run buildThe built files will be in the dist directory.
| Command | Purpose |
|---|---|
npm run dev |
Dev server (default port 3000, see vite.config.js) |
npm run build |
Production build β dist/ |
npm run preview |
After npm run build, serve dist/ locally; open the printed URL (includes /financial-calculator-frontend/ for this repoβs base) |
npm run verify:calculations |
Sanity-check reference formulas; use VERIFY_API=1 to assert the live API |
See the verify:calculations row in the NPM scripts table above. The script spot-checks reference formulas (mortgage payment + compound future value).
# Verify reference formulas locally (no network)
npm run verify:calculations
# Also verify against the hosted API (requires network)
VERIFY_API=1 npm run verify:calculationsBy default, the app calls the hosted API at https://financial-calculations-api.onrender.com (see src/services/api.js). To use a different backend (for example your own machine):
- Create a
.envfile in the root directory:
VITE_API_BASE=http://localhost:8000- Or change the fallback in
src/services/api.js:
const API_BASE = import.meta.env.VITE_API_BASE || 'https://financial-calculations-api.onrender.com'βββ index.html # App shell (Vite; favicon uses %BASE_URL%)
βββ public/ # Static assets copied to dist root (e.g. vite.svg)
βββ scripts/
β βββ verify-calculations.mjs # Reference formula checks (see npm script)
βββ vite.config.js # base path for GitHub Pages, dev server port
src/
βββ constants/
β βββ tvm.js # TVM `calc` modes for URL / tab detection
βββ components/
β βββ Header.jsx # App header
β βββ Navigation.jsx # Tab navigation
β βββ MortgageCalculator.jsx # Main mortgage calculator
β βββ TVMCalculator.jsx # TVM calculators
β βββ PaymentBreakdownChart.jsx # Pie chart for payment breakdown
β βββ AmortizationChart.jsx # Line chart for amortization
βββ hooks/
β βββ useLocalStorage.js # Persist form state to localStorage
βββ services/
β βββ api.js # API service layer
βββ utils/
β βββ finiteNumber.js # Safe numeric coercion for forms / URLs
β βββ mortgageInputs.js # Mortgage defaults and URL parsing
β βββ tvmInputs.js # TVM defaults and URL parsing
β βββ formatCurrency.js
β βββ share.js # Share links and clipboard
βββ App.jsx # Main app component
βββ main.jsx # Entry point
- Live demo: Open the app at https://mytherapy-coding.github.io/financial-calculator-frontend/.
- Mortgage tab:
- Enter loan amount (principal), interest rate, and loan term (years).
- Optionally add property tax, home insurance, PMI, and HOA to see an all-in monthly payment.
- Scroll down to view the amortization chart and payment breakdown pie chart.
- TVM tab:
- Choose Future Value, Present Value, or Annuity Payment.
- Fill in the known inputs (rate, periods, payment/amount) and calculate the missing value.
- Use this to compare savings plans, loan offers, or investment scenarios.
- Share copies a link with your inputs and a
sharedtimestamp. Opening the link restores inputs; form state is also persisted in localStorage for the same origin. - Mortgage shared links include
principal,rate,years, and optional escrow fields where set. - TVM shared links include
tab=tvm,calc, and the relevant fields. Iftab=tvmis missing butcalcis a valid mode (future-value,present-value,annuity-payment), the app still opens the TVM tab.
- Calculate monthly mortgage payments
- Include property tax, home insurance, PMI, and HOA fees
- See total interest paid and payoff date
- Calculate impact of extra monthly payments
- View detailed amortization schedule with charts
- Visualize payment breakdown with pie charts
- Future Value: Calculate compound interest growth
- Present Value: Calculate current value of future amount
- Annuity Payment: Calculate payment for fixed-term annuity
- React 18 - UI framework
- Vite - Build tool and dev server
- Recharts - Chart library for visualizations
- CSS3 - Modern styling with gradients and animations
This frontend integrates with the financial-calculations-api backend:
/v1/mortgage/payment- Calculate mortgage payment/v1/mortgage/summary- Get mortgage summary/v1/mortgage/amortization-schedule- Get amortization schedule/v1/mortgage/with-extra-payments- Calculate with extra payments/v1/tvm/future-value- Calculate future value/v1/tvm/present-value- Calculate present value/v1/tvm/annuity-payment- Calculate annuity payment
- Create a new component in
src/components/ - Add API methods in
src/services/api.js - Add navigation tab in
src/components/Navigation.jsx - Wire the tab in
src/App.jsx(URLtab=param if you use query-based navigation) - Add URL parsing helpers in
src/utils/and any shared constants undersrc/constants/when needed
Each component imports its own CSS file (plain CSS, not CSS Modules). The design follows a modern, clean aesthetic with:
- Gradient backgrounds
- Smooth transitions
- Responsive grid layouts
- Accessible color contrasts
- API errors or failed calculations: Confirm the API is reachable (default: hosted on Render). To run against a local backend, start
financial-calculations-apiand setVITE_API_BASE=http://localhost:8000in.env, then restartnpm run dev. - CORS errors in the browser: The backend must allow your frontend origin (e.g.
http://localhost:3000or your GitHub Pages URL). Configure CORS on the API, not in this repo. - Preview production build locally: After
npm run build, runnpm run previewto test thedistoutput. Use the printed URL (for this repoβsbase, it includes/financial-calculator-frontend/).
This project is configured for automatic deployment to GitHub Pages.
Live Site: https://mytherapy-coding.github.io/financial-calculator-frontend/
Setup Instructions:
-
Enable GitHub Pages in your repository settings:
- Go to Settings β Pages
- Source: Select "GitHub Actions"
-
Configure API URL (optional):
- The app defaults to the hosted Render API unless you override
VITE_API_BASE - To point production at another URL, set the
VITE_API_BASEsecret in GitHub:- Go to Settings β Secrets and variables β Actions
- Add a new secret:
VITE_API_BASEwith your API URL (e.g.,https://your-api.onrender.com)
- The app defaults to the hosted Render API unless you override
-
Automatic Deployment:
- Every push to
mainbranch automatically triggers deployment - The workflow builds the app and deploys to GitHub Pages
- Check the Actions tab to see deployment status
- Every push to
Manual Deployment:
# Build the project
npm run build
# The dist folder contains the production build
# GitHub Actions will automatically deploy it- This app is for educational and planning purposes only and does not constitute financial advice.
- Calculations assume constant interest rates and on-time payments; real-world results may differ.
- Tax, insurance, PMI, and HOA estimates are approximations and can vary by lender and region.
- Always verify numbers with your lender or a qualified financial professional before making decisions.
See the LICENSE file for details.