Problem Statement
Money is the one thing software cannot get wrong, yet JavaScript makes it dangerously easy to: floating-point drift (0.1 + 0.2), inconsistent locale formatting, mishandling the smallest unit (cents vs naira vs satoshis), and reinventing loan/interest math in every project. Most apps scatter ad-hoc money helpers across the codebase, untested and locale-naive — especially painful in fintech and in African markets that need NGN/KES support and crypto.
Proposed Solution
Monie Utils is a single, type-safe, zero-dependency, tree-shakeable TypeScript library that consolidates everything money-related: currency formatting (incl. compact and crypto), validation, conversion, percentage formatting, locale rules, and financial calculations (interest, loans, investments) plus business utilities (payments, subscriptions, analytics).
Full Solution Details
- Formatting —
formatCurrency(rich result object: formatted string, amount, currency, locale, isCompact),formatMoney(simple string),formatCents(from smallest unit — handles USD cents and BTC satoshis),formatCompactCurrency($1.5M,$2.5B). - Percentages —
formatPercentage(0.1525)→15.25%, with precision + locale. - Localization —
formatCurrencyByLocale,getLocaleCurrencyInfo(e.g.de-DE→1.234,56 €). - Validation —
isValidAmount(rejects NaN),isValidCurrency(incl. crypto like BTC). - Financial calculations — interest, loan amortization, investment tracking, subscription billing.
- 20+ currencies with explicit focus on African markets (NGN, KES) alongside USD/EUR and crypto.
Technical Documentation
Pure TypeScript, zero runtime dependencies, tree-shakeable (import only the functions you use), MIT-licensed, published to npm with a dedicated docs site. 100% type coverage; comprehensive test suite. The API favors rich return objects for the heavy formatters (so callers get amount + locale + flags, not just a string) while keeping ergonomic string-only variants (formatMoney) for the common case. Smallest-unit handling is first-class (formatCents) so financial code never juggles ×100 / ×1e8 conversions by hand.
Tech Stack
TypeScript, npm distribution, tree-shaking (ESM), Intl/locale APIs; zero third-party dependencies.
System Design
monie-utils (zero-dep, tree-shakeable)
├── formatting/ formatCurrency · formatMoney · formatCents · formatCompactCurrency
├── percentage/ formatPercentage
├── locale/ formatCurrencyByLocale · getLocaleCurrencyInfo
├── validation/ isValidAmount · isValidCurrency (fiat + crypto)
├── calculations/ interest · loans · investments
└── business/ payments · subscriptions · analytics
every export individually importable → minimal bundle impact
Smart Architectural Decisions
- Zero dependencies + tree-shaking. A money library you can drop into any fintech bundle without dragging in transitive deps or bloating the build — each util is independently importable.
- Smallest-unit as a first-class concept.
formatCentshandling both cents and satoshis encodes the correct mental model for money (store integers, format late), preventing a whole class of rounding bugs. - Rich-object + simple-string dual API. Power users get structured results (locale, flags, parsed amount); simple call sites get a string — ergonomics without losing information.
- African-market + crypto coverage fills a real gap: most money libs assume USD/EUR; this one ships NGN/KES and BTC validation, matching the author's fintech focus.
Impacts
5,000+ npm downloads; used in real fintech products. Gives any TypeScript project correct, locale-aware, well-tested money handling — including African currencies and crypto — without writing (and mis-testing) it from scratch.
Demonstrated Skills
Library/API design (dual ergonomic surfaces, rich result types); financial domain correctness (smallest-unit handling, amortization/interest math); i18n/locale formatting; zero-dependency + tree-shakeable packaging; TypeScript types; OSS testing, docs, and npm release discipline.