A full-stack personal finance and expense tracking web application built with Python (Flask), Vanilla JavaScript, and MongoDB Atlas.
🔗 Live Demo: expensetracker
- Real-Time Expense Tracking: Log expenses instantly with item name, amount, and date.
- Dynamic Ledger & History: Automatically calculates total expenditures and renders a responsive transaction table.
- Dual Persistence Architecture: Powered by MongoDB Atlas cloud database on the backend with client-side
localStoragecaching for zero latency and instant page loads. - Serverless Ready: Fully configured for continuous deployment on Vercel with zero-configuration local fallbacks.
The application uses a decoupled client-server architecture with dual-layer persistence:
- Frontend (Vanilla HTML5 / CSS3 / JavaScript): Handles user input, dynamic table manipulation, running total calculation, and local cache synchronization.
- Backend (Flask REST API): Manages API routes (
/add_expense,/get_expenses,/api/status), handles JSON serialization, and interacts with MongoDB Atlas viapymongo.
graph TD
Client[Vanilla JS Client / UI] -->|POST /add_expense| Server[Flask REST API]
Client -->|GET /get_expenses| Server
Client <-->|Instant Cache & Fallback| LocalStorage[(Browser localStorage)]
Server <-->|Cloud Persistence / pymongo| MongoDB[(MongoDB Atlas Cloud DB)]
Server -.->|Local Dev Fallback| JSONFile[(expenses.json)]
- Frontend: HTML5, CSS3, Vanilla JavaScript (ES6+), Fetch API, LocalStorage API
- Backend: Python 3.10+, Flask, PyMongo, DNS-Python
- Database: MongoDB Atlas (Cloud NoSQL), Local JSON Fallback
- Deployment: Vercel Serverless Functions (
@vercel/python)
| Variable Name | Required | Description |
|---|---|---|
MONGODB_URI |
Optional (Prod) | MongoDB connection string (e.g. mongodb+srv://<user>:<password>@cluster0.xxx.mongodb.net/expense_tracker?retryWrites=true&w=majority). If omitted, app falls back to local storage. |
- Python 3.10+
pip(Python package manager)
-
Clone the repository:
git clone https://github.com/athishio/Expense-Tracker.git cd Expense-Tracker -
Install dependencies:
pip install -r requirements.txt
-
(Optional) Configure Environment Variables: Set
MONGODB_URIin your terminal or create a.envfile:export MONGODB_URI="your_mongodb_connection_string"
-
Run the application:
python server.py
-
Open your browser and navigate to
http://localhost:5000.
- Import your GitHub repository to Vercel.
- Add your
MONGODB_URIunder Project Settings > Environment Variables. - In MongoDB Atlas Network Access, ensure IP
0.0.0.0/0is allowed. - Deploy! Vercel will automatically build and serve the application using the configuration in
vercel.json.