DEV Community

Salman Mohammad
Salman Mohammad

Posted on

💰 Building Spendwise: The Tech Behind an Intelligent Personal Finance Guard

Why standard budgeting apps fail, and how i combined Flask, MongoDB Atlas, and failover resilience to build a real-time spending guard.


🎯 1. The Problem: Why Traditional Budget Trackers Fail

Most budget management applications act like passive digital receipts. You spend money, manually log expenses hours later, and only realize you've overspent when your bank balance hits zero.

We built Spendwise to flip this paradigm on its head. Instead of just tracking past expenses, Spendwise acts as an active financial guard—evaluating transactions in real-time , providing an emergency safety buffer, and automating periodic budget rollovers.


🛠️ 2. The Technology Stack

To deliver instantaneous UI feedback and 100% backend reliability, we engineered Spendwise using a modular, decoupled architecture:

  • Frontend UI Layer: HTML5, CSS3 Glassmorphism System, Vanilla JavaScript (ES6+), and SWApi REST bridge.

  • Backend REST Engine: Python 3.14, Flask REST API, Gunicorn WSGI server, and APScheduler cron service.

  • Database & Security: MongoDB Atlas Cloud NoSQL, PyMongo, In-Memory RAM Failover Layer, and BCrypt password hashing.

  • Infrastructure: Render Cloud Hosting, Procfile launcher, and HTTPS Multi-Gateway Email Routing over Port 443.


🔄 3. How Spendwise Works: External Flow vs. System Engine

Understanding Spendwise comes down to two perspectives: what the user sees on screen, and what the rules engine computes behind the scenes.

🌐 User Experience (External)

  1. Wallet Setup: Configure your balance, period spending limit, and emergency buffer.

  2. Check Before Spending: Input item price before buying to receive instant approval feedback in <0.1 seconds.

  3. Instant Buy & Sync: Deduct funds and watch remaining limit update live.

  4. Email Summary: Trigger detailed financial reports sent directly to your inbox.

⚙️ System Mechanics (Internal Engine)

  • Rule 1 (Spending Guard): Approves purchase if Item Cost≤Remaining Limit.

  • Rule 2 (Emergency Buffer Fallback): If limit is exceeded, verifies if Item Cost≤Remaining Limit+Emergency Buffer. Consumes buffer reserve and drops remaining limit to $0.00 to prevent further overspending.

  • Rule 3 (Periodic Rollover Engine): Automatically carries over unused budget from previous periods when new cycles start.


💡 4. Real-Life Scenario: Meet Alex

Let's look at how Spendwise protects a real user in practice:

  • Initial Setup: Alex starts with $1,000 Balance, $200 Weekly Limit, and $50 Emergency Buffer.

  • 🟢 Transaction 1 ($40 Headphones): Within limit. Spendwise approves it, leaving $160 limit and $960 balance.

  • 🟡 Transaction 2 ($180 Laptop Charger): Exceeds $160 limit by $20. Spendwise triggers the Emergency Buffer, absorbing $20 from the reserve, setting remaining limit to $0.00, and updating balance to $780.

  • 🔴 Transaction 3 ($100 Smartwatch): Alex tries to buy a smartwatch. Since limit is $0.00 and buffer is $30.00, Spendwise declines the transaction, saving Alex from overspending.

  • 📩 Transaction 4 (Email Summary): Alex clicks "Send Email Report" and receives a summary in his inbox.


🛡️ 5. Technical Highlights & High Availability

  1. Multi-Gateway HTTPS Email Routing (Port 443 Resilience): Cloud platforms like Render block raw TCP SMTP ports (25, 465, 587). Spendwise uses a resilient HTTPS API cascade: Mailtrap⟶Mailjet⟶SendGrid⟶Brevo⟶Resend

  2. Zero-Downtime Hybrid Database Failover: If cloud MongoDB Atlas is starting up or temporarily unreachable, Spendwise seamlessly activates an In-Memory RAM Store, guaranteeing zero 500 errors during testing.


🔗 6. Links & Resources


🎯 6. Key Takeaways

Building Spendwise taught us that great fintech applications aren't just about recording data—they're about protecting user behavior in real-time. By pairing instant UI feedback with resilient serverless architecture, you create a system that users can rely on every day.


Created for the Spendwise Project Documentation.

Top comments (0)