<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Wernerpj Jacob</title>
    <description>The latest articles on Forem by Wernerpj Jacob (@wernerpj_purens_jaco).</description>
    <link>https://forem.com/wernerpj_purens_jaco</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3716747%2Fbfa24f9a-966e-4836-98c1-4f8bd6d5ac7d.jpg</url>
      <title>Forem: Wernerpj Jacob</title>
      <link>https://forem.com/wernerpj_purens_jaco</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/wernerpj_purens_jaco"/>
    <language>en</language>
    <item>
      <title>How I Built a Mortgage Calculator That Actually Helps People Save $200K+ (Next.js + Real Math)</title>
      <dc:creator>Wernerpj Jacob</dc:creator>
      <pubDate>Sat, 17 Jan 2026 16:04:36 +0000</pubDate>
      <link>https://forem.com/wernerpj_purens_jaco/how-i-built-a-mortgage-calculator-that-actually-helps-people-save-200k-nextjs-real-math-44</link>
      <guid>https://forem.com/wernerpj_purens_jaco/how-i-built-a-mortgage-calculator-that-actually-helps-people-save-200k-nextjs-real-math-44</guid>
      <description>&lt;p&gt;🎯 The Problem: Financial Calculators That Don't Actually Calculate Anything Useful&lt;br&gt;
Last year, I was trying to figure out if I should pay off my mortgage early. I found dozens of "mortgage calculators" online, but they all had the same problems:&lt;/p&gt;

&lt;p&gt;Basic math only (principal × rate × time).&lt;/p&gt;

&lt;p&gt;No strategy comparison (what if I invest instead?).&lt;/p&gt;

&lt;p&gt;Hidden behind email walls (give us your data first!).&lt;/p&gt;

&lt;p&gt;No explanation of the math (black box calculations).&lt;/p&gt;

&lt;p&gt;The worst part: They don't account for cash flow efficiency (Velocity Banking).&lt;/p&gt;

&lt;p&gt;I'm a developer. I understand compound interest. But even I couldn't find a tool that answered: "Should I use a HELOC, make extra payments, or just invest the difference?"&lt;/p&gt;

&lt;p&gt;So I built one. And it accidentally turned into a product that's helped 2,000+ users save an average of $142,000 in projected interest.&lt;/p&gt;

&lt;p&gt;In this post, I'll share how I built the Mortgage Killer Kit, the tech stack (Next.js 14 + Supabase), the floating-point math nightmares I faced, and why building fintech tools is harder than it looks.&lt;/p&gt;

&lt;p&gt;(Disclaimer: I am the creator of this tool. I built it to solve my own problem, and now I share the logic openly.)&lt;/p&gt;

&lt;p&gt;📊 The Math That Most Calculators Get Wrong&lt;br&gt;
Before diving into code, let's understand why 90% of mortgage calculators are useless.&lt;/p&gt;

&lt;p&gt;The Compound Interest Trap Most calculators use simple formulas that work for car loans but fail for mortgages because they ignore Amortization Schedules.&lt;/p&gt;

&lt;p&gt;A mortgage front-loads interest. A $100 extra payment in Year 1 saves significantly more than a $100 payment in Year 20.&lt;/p&gt;

&lt;p&gt;To solve this, I couldn't just use a simple formula. I had to build an Engine that simulates the loan month-by-month, reacting to events like "Lump Sum Payment" or "HELOC Injection".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5c30k131bf6mneffeeg2.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5c30k131bf6mneffeeg2.jpeg" alt=" " width="591" height="1280"&gt;&lt;/a&gt;&lt;br&gt;
Visualizing the difference between a standard 30-year loan and an optimized strategy&lt;/p&gt;

&lt;p&gt;🏗️ The Tech Stack&lt;br&gt;
I needed something fast, SEO-friendly, and capable of handling heavy math without freezing the browser.&lt;/p&gt;

&lt;p&gt;Frontend: Next.js 14 (App Router) + TypeScript&lt;/p&gt;

&lt;p&gt;Backend/DB: Supabase (PostgreSQL)&lt;/p&gt;

&lt;p&gt;Styling: Tailwind CSS + Shadcn UI&lt;/p&gt;

&lt;p&gt;Math: Custom Engine + decimal.js&lt;/p&gt;

&lt;p&gt;Frontend: Real-Time Reactivity&lt;br&gt;
I wanted the UI to feel "alive". No "Calculate" buttons. As you type, the graph updates.&lt;/p&gt;

&lt;p&gt;TypeScript&lt;/p&gt;

&lt;p&gt;// app/calculator/page.tsx (Simplified)&lt;br&gt;
'use client';&lt;/p&gt;

&lt;p&gt;import { useState, useEffect } from 'react';&lt;br&gt;
import { useDebounce } from '@/hooks/use-debounce';&lt;br&gt;
import { FinanceEngine } from '@/lib/engine';&lt;/p&gt;

&lt;p&gt;export default function Calculator() {&lt;br&gt;
  const [loanDetails, setLoanDetails] = useState(DEFAULT_VALUES);&lt;br&gt;
  const debouncedDetails = useDebounce(loanDetails, 500);&lt;br&gt;
  const [results, setResults] = useState(null);&lt;/p&gt;

&lt;p&gt;useEffect(() =&amp;gt; {&lt;br&gt;
    // We run the simulation whenever inputs change&lt;br&gt;
    const engine = new FinanceEngine(debouncedDetails);&lt;br&gt;
    const calculation = engine.simulateStrategy('velocity_banking');&lt;br&gt;
    setResults(calculation);&lt;br&gt;
  }, [debouncedDetails]);&lt;/p&gt;

&lt;p&gt;return (&lt;br&gt;
    &lt;/p&gt;
&lt;br&gt;
       &lt;br&gt;
       &lt;br&gt;
    &lt;br&gt;
  );&lt;br&gt;
}&lt;br&gt;
Backend: Why Supabase?&lt;br&gt;
I track anonymous usage patterns to see which strategies win. I use Supabase Edge Functions for complex scenarios that might be too heavy for the client (like Monte Carlo simulations).

&lt;p&gt;TypeScript&lt;/p&gt;

&lt;p&gt;// supabase/functions/analyze-scenario/index.ts&lt;br&gt;
import { serve } from '&lt;a href="https://deno.land/std@0.168.0/http/server.ts" rel="noopener noreferrer"&gt;https://deno.land/std@0.168.0/http/server.ts&lt;/a&gt;'&lt;/p&gt;

&lt;p&gt;serve(async (req) =&amp;gt; {&lt;br&gt;
  const { principal, strategy } = await req.json();&lt;/p&gt;

&lt;p&gt;// This runs on the Edge, close to the user&lt;br&gt;
  const result = heavyMathCalculation(principal, strategy);&lt;/p&gt;

&lt;p&gt;// Log anonymous stats&lt;br&gt;
  await supabase.from('analytics').insert({&lt;br&gt;
    strategy_type: strategy,&lt;br&gt;
    savings_projected: result.totalSavings&lt;br&gt;
  });&lt;/p&gt;

&lt;p&gt;return new Response(JSON.stringify(result));&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6c9mowarc7vt5t3uswlu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6c9mowarc7vt5t3uswlu.jpeg" alt=" " width="591" height="1280"&gt;&lt;/a&gt;&lt;br&gt;
60% of my users are on mobile, so the UI had to be responsive and touch-friendly&lt;/p&gt;

&lt;p&gt;🐛 The Bugs That Almost Killed Me&lt;br&gt;
Building a fintech app isn't just about UI. If the math is off by a cent, you lose trust.&lt;/p&gt;

&lt;p&gt;Bug #1: The Floating Point Nightmare&lt;br&gt;
JavaScript is terrible at math. Try typing 0.1 + 0.2 in your console. You get 0.30000000000000004. Now imagine compounding that error over 360 months (30 years). The final balance would be off by hundreds of dollars.&lt;/p&gt;

&lt;p&gt;The Fix: I migrated all math to Decimal.js.&lt;/p&gt;

&lt;p&gt;JavaScript&lt;/p&gt;

&lt;p&gt;// ❌ BAD (Native JS)&lt;br&gt;
const monthlyPayment = principal * (rate / 12); &lt;/p&gt;

&lt;p&gt;// ✅ GOOD (Decimal.js)&lt;br&gt;
import { Decimal } from 'decimal.js';&lt;/p&gt;

&lt;p&gt;const monthlyPayment = new Decimal(principal).mul(&lt;br&gt;
  new Decimal(rate).div(12)&lt;br&gt;
);&lt;br&gt;
Bug #2: The "Daily Interest" Trap&lt;br&gt;
Calculators often assume monthly interest. But HELOCs (Home Equity Lines of Credit) calculate interest Daily. I had to rewrite the engine to support mixed-mode calculations (Monthly for Mortgage, Daily for HELOC) to get accurate results.&lt;/p&gt;

&lt;p&gt;📈 The Results (Data from 2,000+ Users)&lt;br&gt;
After launching the &lt;a href="https://velocitymortgageapp.com/" rel="noopener noreferrer"&gt;Mortgage Killer Kit App&lt;/a&gt;, I started seeing interesting patterns in the database.&lt;/p&gt;

&lt;p&gt;Here is a simplified query of what users are choosing:&lt;/p&gt;

&lt;p&gt;SQL&lt;/p&gt;

&lt;p&gt;SELECT &lt;br&gt;
  strategy_chosen,&lt;br&gt;
  COUNT(*) as popularity,&lt;br&gt;
  AVG(potential_savings) as avg_savings&lt;br&gt;
FROM user_calculations&lt;br&gt;
GROUP BY strategy_chosen&lt;br&gt;
ORDER BY popularity DESC;&lt;br&gt;
The Data:&lt;/p&gt;

&lt;p&gt;Velocity Banking: 42% of users (Avg Savings: $142k)&lt;/p&gt;

&lt;p&gt;Extra Payments: 38% of users (Avg Savings: $89k)&lt;/p&gt;

&lt;p&gt;Investing Difference: 20% of users&lt;/p&gt;

&lt;p&gt;It turns out, when people see the math visualized, they rarely choose to "do nothing".&lt;/p&gt;

&lt;p&gt;💡 Lessons Learned&lt;br&gt;
Trust &amp;gt; Features: Users didn't care about dark mode until I added a "Show the Math" button that expanded the full amortization table. Transparency builds trust.&lt;/p&gt;

&lt;p&gt;Visualization Sells: A table of numbers is boring. A chart showing the "Freedom Date" moving from 2055 to 2032 is emotional.&lt;/p&gt;

&lt;p&gt;Context Matters: I realized the calculator wasn't enough. Users needed to understand why the math works. I had to link the tool back to my &lt;a href="https://blog.velocitymortgageapp.com/" rel="noopener noreferrer"&gt;Velocity Banking Strategy Guide&lt;/a&gt; to close the knowledge gap.&lt;/p&gt;

&lt;p&gt;🚀 Try It Yourself&lt;br&gt;
If you are a developer, I challenge you to build your own calculator—it's a great exercise in state management and precision math.&lt;/p&gt;

&lt;p&gt;If you just want to check your own mortgage numbers, you can play with the Live Demo I built:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://velocitymortgageapp.com/quiz" rel="noopener noreferrer"&gt;👉 Try the Mortgage Killer App here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or, if you want to understand the theory behind the algorithm, check out the Full Strategy Documentation.&lt;/p&gt;

&lt;p&gt;💬 Discussion&lt;br&gt;
Question for fellow devs: Some developers argue that financial math should always be done server-side for security. I do it client-side (mostly) for instant reactivity and UX. Where do you draw the line between Security vs. UX in fintech apps?&lt;/p&gt;

&lt;p&gt;Let me know in the comments! 👇&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
      <category>fintech</category>
      <category>buildinpublic</category>
    </item>
  </channel>
</rss>
