DEV Community

Cover image for Under the Hood of a Zero-Dependency MACRS and Depreciation Engine
ludy.dev
ludy.dev

Posted on • Originally published at mydepreciation.org

Under the Hood of a Zero-Dependency MACRS and Depreciation Engine

Featured Image

If you've ever had to handle accounting for business assets, tax write-offs, or real estate, you know that calculating depreciation is a massive headache. IRS rules for MACRS (Modified Accelerated Cost Recovery System) are filled with quirks like half-year conventions, mid-month rules, and declining balance switches.

Most tools online are either hidden behind aggressive paywalls, buried in ad-heavy accounting blogs, or require downloading bloated Excel templates. Over the weekend, I decided to scratch my own itch and build a clean, lightning-fast utility to solve this once and for all: mydepreciation.org.

Here is a look at the technical decisions and engineering challenges that went into building a zero-dependency depreciation engine.

The Mathematical Challenge: Coding a Pure TS MACRS Engine

At first glance, straight-line depreciation is trivial: (Cost - Salvage) / Useful Life. But modern tax accounting relies heavily on MACRS and Declining Balance methods. MACRS requires applying specific percentage tables defined by the IRS based on the asset class (e.g., 3-year, 5-year, 15-year, 27.5-year property) and depreciation conventions (usually Half-Year or Mid-Month).

Instead of pulling in a massive npm library or relying on server-side database lookups, I wanted everything to happen client-side instantly. I mapped out the IRS Pub 946 depreciation tables into lightweight JSON structures and wrote a pure TypeScript utility engine to handle the state transitions.

Keeping It Zero-Dependency

To ensure the site loads in under 100ms, I avoided importing heavy charting or heavy state-management libraries. The entire math core is written in vanilla JS/TS. For the visualization, I used custom lightweight SVGs dynamically calculated and drawn on the fly based on the depreciation schedule array. This avoided the overhead of importing something like Chart.js or Recharts, shaving off nearly 150kb from the final JS bundle.

Tech Stack and Optimization

  • Frontend: Next.js (Static Export) for bulletproof SEO and instant initial page loads.
  • Styling: Tailwind CSS for a utility-first, responsive design that works beautifully on mobile screens.
  • Hosting: Vercel edge network for near-zero latency worldwide.

The result is a clean, single-page application that gives users an instant, downloadable PDF or CSV of their depreciation schedule in less than three clicks.

I’d love to hear your thoughts on the client-side math implementation, or if you have any ideas on how to optimize the dynamic SVG rendering further! Feel free to check it out at mydepreciation.org.

Top comments (0)