TheSmartCalc
Multilingual Financial Calculator Platform
- Type
- Full Stack Web Application
- Role
- System Architecture, Backend Development, Frontend Development, SEO, Deployment
- Stack
- Next.js, React, TypeScript, Prisma, MongoDB
- Links
- Live ↗
A bilingual financial calculator platform with a secure admin CMS, multilingual blog system, and SEO-first architecture.
02 / Overview
About the project
- What it is
- A multilingual financial calculator platform providing free financial tools alongside a CMS-driven educational blog.
- Who it’s for
- Individuals, students, investors, and anyone needing quick financial calculations without creating an account.
- Why it exists
- To simplify everyday financial calculations while making educational financial content available in both English and Arabic.
03 / My role
What I built
- 01
Full Stack Development
Designed and implemented both frontend and backend architecture.
- 02
Calculator Engine
Built reusable financial calculation modules with TypeScript.
- 03
Internationalization
Implemented complete bilingual support including RTL layouts.
- 04
SEO
Implemented structured metadata, JSON-LD and multilingual SEO.
04 / Capabilities
What it can do
- 0112 Financial Calculators
- 02Admin Dashboard
- 03Bilingual Blog
- 04Password Reset
05 / Under the hood
Engineering deep dive
JWT tokens are issued on login and stored in HTTP-only cookies — never accessible to JavaScript. The admin middleware verifies and decodes the token server-side on every protected route, rejecting expired or tampered tokens before any page data is fetched. Passwords are hashed with bcrypt before storage.
06 / Decisions
Challenges and trade-offs
- 01
Challenge
How to handle financial arithmetic without floating-point errors in JavaScript
Decision
Replaced native JavaScript Number arithmetic with the decimal.js library across all 12 calculator modules. Every intermediate value in a multi-step calculation (e.g. monthly rate derivation inside loan amortization) is kept as a Decimal instance and only converted to a primitive string for display.
Trade-off
Adds a dependency and slightly more verbose code, but eliminates the class of bugs where 0.1 + 0.2 === 0.30000000000000004 — critical for a platform where users trust the numbers.
- 02
Challenge
How to serve bilingual content without a third-party translation API at runtime
Decision
Stored all UI strings and calculator labels in flat JSON message files per locale (en.json, ar.json) loaded at build time. Next.js middleware maps each incoming request to the correct locale and the message file is imported statically in Server Components.
Trade-off
Translations must be maintained manually in the JSON files — there is no auto-sync with a translation platform — but page load has zero network round-trip overhead for i18n.
- 03
Challenge
How to monetize a free calculator platform without degrading performance
Decision
Google AdSense ad units are loaded lazily via a dynamic import behind an IntersectionObserver. The ad script is deferred until the ad slot enters the viewport, so it never blocks the main thread during initial page load.
Trade-off
Ads appear slightly later than on platforms that load them eagerly, but Core Web Vitals scores (LCP, CLS) are not impacted by ad loading weight.
- 04
Challenge
Loan amortization schedules for long tenures (30-year mortgages) were generating tables with 360 rows, causing noticeable render lag on low-end devices.
Solution
Implemented virtual pagination on the amortization table: only the first 12 rows are rendered on mount, with a 'Load more' button that appends the next 12 rows. The full schedule is computed once and held in a ref, so pagination is pure DOM addition with no recomputation.
Result
Initial render time dropped from ~400ms to under 50ms for a 30-year schedule while keeping the full data available without a round-trip.
- 05
Challenge
RTL layout required more than a CSS direction flip — form inputs, number formatting, and error message alignment all had to adapt to Arabic reading order.
Solution
Created a useLocale hook that exposes the current locale and a dir value. Components that need direction-aware styles consume dir and apply conditional class names. Number formatting uses Intl.NumberFormat with the locale string so Arabic numerals render correctly in ar locale.
Result
The Arabic version of the site is a full RTL experience — inputs, labels, error states, and number outputs all respect Arabic reading order without any hardcoded LTR overrides.
07 / Architecture
System design
- 01
Next.js App Router with locale-prefixed routes (/en, /ar) and a middleware that reads the Accept-Language header and redirects bare paths to the correct locale
- 02
Pure TypeScript calculator modules — each calculator is a pure function that accepts typed inputs and returns a typed result object; no shared state between calculators
- 03
Prisma ORM targeting MongoDB for the CMS blog system; the admin dashboard performs CRUD on articles through a set of Server Actions
- 04
JWT authentication stored in HTTP-only cookies; the admin middleware verifies the token on every request to /admin routes before rendering the page
- 05
Next.js generateMetadata and generateStaticParams used to pre-render all calculator pages and blog articles at build time for maximum SEO performance
08 / Performance
What makes it fast
- Static Generation
- all calculator and blog pages are pre-rendered at build time; zero server computation per visitor request
- React Compiler
- enabled to automatically memoize components, eliminating the need for manual useMemo and useCallback on calculator form components
- Lazy Ad Loading
- Google AdSense units are loaded behind an IntersectionObserver so the ad script never blocks the initial page render
- Image Optimization
- Next.js Image component serves AVIF/WebP with correct srcset and sizes; layout-shift from image loading is prevented with explicit width and height
09 / Security
Security model
- JWT Authentication with HTTP-only cookies
- tokens are never exposed to client-side JavaScript
- bcrypt password hashing with a cost factor of 12 applied to all admin account passwords
- Admin middleware runs server-side on every /admin route before any page data is fetched or rendered
- Rate limiting on the login endpoint prevents brute-force attacks on the admin account
10 / Deployment
How it ships
- 01
VPS — self-hosted on a Linux VPS; the Next.js server runs as a long-lived process managed by PM2
- 02
PM2 — process manager keeps the server alive across crashes, restarts on file change in development, and provides a startup script for server reboots
- 03
Nginx — reverse proxy sitting in front of the Next.js server, handling SSL termination, HTTP-to-HTTPS redirect, and static asset caching headers
11 / Gallery
Screens
Architecture diagrams
12 / Links
See it for yourself
[ Next project ]
InPlace AIInstant In-Place Text Formatter & Tone Enhancer