AI-Powered Personal Finance Tracker
A full-stack, production-grade personal finance management application with AI-powered insights, predictions, and financial advisory.
┌─────────────────────────────────────────────────────────┐
│ Client (Browser) │
├─────────────────────────────────────────────────────────┤
│ Next.js + Tailwind │
├─────────────────────────────────────────────────────────┤
│ Nginx (Reverse Proxy) │
├──────────────────────┬──────────────────────────────────┤
│ Frontend :3000 │ Backend :5000 │
│ (Next.js/React) │ (Express.js/MongoDB) │
├──────────────────────┼──────────────────────────────────┤
│ │ AI Service :5001 │
│ │ (Python/Flask + ML) │
├──────────────────────┴──────────────────────────────────┤
│ MongoDB (Database) │
└─────────────────────────────────────────────────────────┘
Layer
Technology
Frontend
Next.js 14, React 18, TypeScript, Tailwind CSS
Backend
Node.js, Express.js, Socket.IO
Database
MongoDB with Mongoose ODM
AI/ML
Python, Flask, scikit-learn, Pandas
Auth
JWT, bcrypt, Google OAuth
Security
Helmet, CORS, Rate Limiting, Input Validation
Real-time
WebSockets (Socket.IO)
Testing
Jest (Backend), pytest (AI), Supertest
Deploy
Docker, Docker Compose, Nginx
finance-tracker/
├── backend/ # Express.js API server
│ ├── src/
│ │ ├── config/ # DB config, constants
│ │ ├── controllers/ # Route handlers
│ │ ├── middleware/ # Auth, validation, upload
│ │ ├── models/ # Mongoose schemas
│ │ ├── routes/ # API routes
│ │ ├── utils/ # Email, export, scheduler
│ │ └── app.js # Express entry point
│ ├── tests/
│ ├── Dockerfile
│ └── package.json
├── frontend/ # Next.js application
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── context/ # Auth, Theme context
│ │ ├── hooks/ # Custom hooks
│ │ ├── pages/ # Pages (login, dashboard)
│ │ ├── services/ # API client
│ │ ├── styles/ # Tailwind globals
│ │ └── types/ # TypeScript types
│ ├── Dockerfile
│ └── package.json
├── ai/ # Python AI microservice
│ ├── app.py # Flask endpoints
│ ├── requirements.txt
│ ├── Dockerfile
│ └── tests/
├── docker-compose.yml # Multi-service orchestration
├── nginx.conf # Reverse proxy config
└── .env.example
Field
Type
Description
name
String
Full name
email
String
Unique email (lowercase)
password
String
bcrypt hashed (select: false)
googleId
String
Google OAuth ID
currency
String
Default currency (USD, EUR, INR...)
preferences
Object
Dark mode, notifications
emailVerified
Boolean
Email verification flag
Transactions (Income & Expenses)
Field
Type
Description
user
ObjectId
Reference to User
type
Enum
'income' or 'expense'
amount
Number
Transaction amount (>=0)
category
String
Expense or Income category
description
String
Optional description
date
Date
Transaction date
currency
String
Transaction currency
tags
[String]
Custom tags
receipt
Object
Uploaded receipt URL
isRecurring
Boolean
Recurring transaction flag
source
Enum
manual, voice, ocr, import
Field
Type
Description
user
ObjectId
Reference to User
category
String
Budget category
amount
Number
Budget limit
period
Enum
weekly, monthly, yearly
alertsEnabled
Boolean
Overspend alerts
alertThreshold
Number
% threshold for alerts
Field
Type
Description
user
ObjectId
Reference to User
type
Enum
Alert types
title
String
Notification title
message
String
Notification body
severity
Enum
info, warning, danger, success
read
Boolean
Read status
Method
Endpoint
Description
POST
/api/auth/register
Register new user
POST
/api/auth/login
Login user
POST
/api/auth/google
Google OAuth
GET
/api/auth/profile
Get user profile
PUT
/api/auth/profile
Update profile
PUT
/api/auth/change-password
Change password
POST
/api/auth/forgot-password
Send reset email
POST
/api/auth/reset-password/:token
Reset password
Method
Endpoint
Description
GET
/api/expenses
List expenses (paginated, filterable)
GET
/api/expenses/:id
Get single expense
POST
/api/expenses
Create expense
PUT
/api/expenses/:id
Update expense
DELETE
/api/expenses/:id
Delete expense
POST
/api/expenses/scan-receipt
OCR receipt scanning
Method
Endpoint
Description
GET
/api/income
List income records
POST
/api/income
Add income
PUT
/api/income/:id
Update income
DELETE
/api/income/:id
Delete income
Method
Endpoint
Description
GET
/api/budget
Get budgets with spending
POST
/api/budget
Create budget
PUT
/api/budget/:id
Update budget
DELETE
/api/budget/:id
Delete budget
GET
/api/budget/report
Budget performance report
Method
Endpoint
Description
GET
/api/reports/dashboard
Dashboard stats
GET
/api/reports/monthly
Monthly report
GET
/api/reports/yearly
Yearly report
Method
Endpoint
Description
POST
/api/ai/predict
Expense predictions
GET
/api/ai/saving-advice
Saving recommendations
GET
/api/ai/financial-health
Health score
POST
/api/ai/chat
AI chatbot
POST
/api/ai/voice-expense
Voice expense entry
Method
Endpoint
Description
GET
/api/notifications
List notifications
PATCH
/api/notifications/:id/read
Mark as read
POST
/api/notifications/read-all
Mark all as read
DELETE
/api/notifications/:id
Delete notification
Email/password registration with JWT
Google OAuth integration
Password hashing (bcrypt, 12 rounds)
Password reset via email
Rate-limited auth endpoints
Real-time income vs expense tracking
Interactive pie charts (Chart.js)
Monthly trend lines
Financial health score (0-100)
Expense Prediction: Random Forest model predicts 7 and 30 day expenses
Saving Advisor: Analyzes spending patterns, generates personalized tips
Financial Health Score: Multi-factor scoring (savings rate, spending behavior, budget discipline, consistency)
AI Chatbot: NLP-based financial assistant with intent recognition
Category-wise budget limits
Real-time spending tracking
Overspend alerts (WebSocket + DB)
Budget rollover support
Monthly/yearly breakdowns
Bar chart visualizations
PDF and Excel export
Category-wise analysis
Tesseract.js integration
Auto-extracts amount and store name
NLP-based voice command parsing
Natural language support: "Spent 25 dollars on food"
Node.js 20+
Python 3.11+
MongoDB 7+ (or Docker)
npm or yarn
cd backend
cp .env.example .env # Edit with your values
npm install
npm run dev
cd frontend
cp .env.example .env.local
npm install
npm run dev
cd ai
pip install -r requirements.txt
python app.py
# Clone and configure
git clone < repo>
cd finance-tracker
cp .env.example .env
# Start all services
docker-compose up -d --build
# Verify
curl http://localhost:5000/api/health
curl http://localhost:5001/health
VPS (DigitalOcean, AWS EC2, Linode)
# 1. SSH into server
ssh user@your-server-ip
# 2. Install Docker
curl -fsSL https://get.docker.com | sh
# 3. Clone project
git clone https://github.com/yourusername/finance-tracker.git
cd finance-tracker
# 4. Configure SSL (Let's Encrypt)
docker run -it --rm -p 80:80 -p 443:443 \
-v $PWD /ssl:/etc/letsencrypt \
certbot/certbot certonly --standalone \
-d yourdomain.com
# 5. Start
docker-compose up -d --build
Kubernetes (GKE, EKS, AKS)
# Deploy to Kubernetes
kubectl apply -f k8s/
Layer
Tool
Focus
Backend Unit
Jest
Controllers, models, middleware
Backend Integration
Supertest
API endpoints, auth flow
AI Unit
pytest
Predictions, chat, data prep
E2E
Cypress
User flows, edge cases
Load
k6
API performance, rate limiting
JWT Authentication with Bearer token scheme
Password Hashing (bcrypt, 12 salt rounds)
Rate Limiting on auth and API endpoints
Helmet.js security headers
CORS configured for frontend origin only
Input Validation with express-validator
XSS Protection via Content-Security-Policy
File Upload validation (type, size limits)
MongoDB Injection protection via Mongoose
Horizontal: Stateless backend behind Nginx load balancer
Caching: In-memory caching (Map) for API responses
Database: MongoDB indexes on user, date, type
Real-time: Socket.IO for live updates
AI: Separate microservice for ML workloads
CDN: Static assets served via Nginx with cache headers
Next.js static generation for landing pages
React lazy loading for dashboard components
MongoDB compound indexes for query performance
Response compression via Nginx
API pagination (default 20 items)
Debounced search inputs
Optimistic UI updates