Skip to content

Jitesh8260/Expensync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

26 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š Expensync โ€” Smart AI-Powered Personal Finance Tracker

License: MIT Status: Active Stack: MERN + Flask Production Ready

Expensync is a full-stack, production-hardened personal finance and expense tracking application built using the MERN stack (MongoDB, Express.js, React, Node.js) paired with a specialized Python Flask Machine Learning microservice. The platform helps users monitor their financial health, track transactions, set category-specific budgets, parse receipt text dynamically, and forecast spending habits with real-time feedback.

๐Ÿ‘‰ Live Demo: https://expensyncj17.vercel.app


๐ŸŒŸ Visual Preview & Layout

๐Ÿ–ฅ๏ธ Dashboard Showcase

Expensync Full Demo

๐ŸŒž Light Mode | ๐ŸŒ™ Dark Mode

Light Theme Layout Dark Theme Layout
Light Dark

๐Ÿš€ Key Features

  • ๐Ÿ” Secure Dual-Token Auth โ€” Stateless JWT authentication flow with automatic silent Access Token refresh interceptors.
  • ๐Ÿง  Behavioral AI Financial Insights โ€” Dynamic assessment of Financial Health Score and Safe Spending Capacity driven by category budgeting and recent transactional velocity.
  • ๐Ÿ“ˆ Smart Forecasting โ€” Linear Regression spending models forecasting next-month categorical expenses.
  • ๐Ÿท๏ธ KNN Category Classifier โ€” Autocompletion and suggestion of categories based on historical transaction titles and contextual merchant normalization.
  • ๐Ÿ’พ Adaptive Learning Memory โ€” Store merchant classification corrections locally to improve autocompletion over time.
  • ๐Ÿ“ Smart Input NLP Parser โ€” Enter transactions in plain English (e.g. "$45 for pizza yesterday at Dominoes") and let the parser extract title, amount, category, and date.
  • ๐Ÿงพ OCR Receipt Scanner โ€” Upload images of receipts to automatically extract transaction details via Tesseract.js.
  • ๐Ÿ“Š Premium Analytics & Visualizations โ€” Highly responsive Pie and Doughnut visualizations comparing category allocations and income-to-expense ratios.
  • โฐ Obligations Tracker โ€” Live scheduler for upcoming, recurring reminders, and debt accounts.
  • ๐Ÿ“ฑ Responsive Mobile-First UI โ€” Fully adaptive dark/light glassmorphic layout using Tailwind CSS.

๐Ÿ› ๏ธ Technology Stack

  • Frontend: React (Vite), Tailwind CSS, Framer Motion, Chart.js, Lucide Icons.
  • Backend: Node.js, Express.js, JWT, Mongoose, Helmet (Security Headers), Express Rate Limit (Brute Force Protection).
  • ML Microservice: Python, Flask, Scikit-Learn (KNN Classifier, Linear Regression), PyMongo.
  • Database: MongoDB Atlas (Cloud NoSQL).
  • Hosting: Vercel (Frontend), Render (Backend & ML Service).

๐Ÿ“ฆ System Architecture Diagram

graph TD
    Client[React Frontend / Vite] <-->|HTTPS / JSON + JWT| API[Express API Server]
    API <-->|Mongoose ORM| DB[(MongoDB Atlas)]
    API <-->|HTTP / JSON + 2s Timeout| ML[Flask ML Service]
    ML <-->|PyMongo Read-only| DB
Loading

๐Ÿ“‚ Project Structure

Expensync/
โ”œโ”€โ”€ client/                 # React Frontend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ api/            # Centralized Axios Client & Interceptors
โ”‚   โ”‚   โ”œโ”€โ”€ components/     # Reusable UI & Layout Components
โ”‚   โ”‚   โ”œโ”€โ”€ context/        # Theme & Global Spinner Context
โ”‚   โ”‚   โ””โ”€โ”€ pages/          # Home, Login, Signup, Landing
โ”‚   โ””โ”€โ”€ vercel.json         # Vercel SPA Routing Configuration
โ”œโ”€โ”€ server/                 # Express API Backend
โ”‚   โ”œโ”€โ”€ controllers/        # Business Logic Modules
โ”‚   โ”œโ”€โ”€ middleware/         # Auth, Upload, Validation Middlewares
โ”‚   โ”œโ”€โ”€ models/             # Mongoose Database Schemas
โ”‚   โ”œโ”€โ”€ routes/             # REST Route Groupings
โ”‚   โ””โ”€โ”€ index.js            # Server Bootstrapper & Middleware Setup
โ”œโ”€โ”€ ml-service/             # Flask Machine Learning Backend
โ”‚   โ”œโ”€โ”€ services/           # KNN Predictor, Linear Forecast, Insights Engines
โ”‚   โ”œโ”€โ”€ utils/              # Configuration & Environment Adapters
โ”‚   โ””โ”€โ”€ app.py              # Flask Route Controllers

โš™๏ธ Environment Configuration

Set up environment variables in their respective project subdirectories.

Client Environment Setup (client/.env)

Create client/.env based on client/.env.example:

VITE_API_URL=http://localhost:5000/api/v1

Server Environment Setup (server/.env)

Create server/.env based on server/.env.example:

PORT=5000
MONGO_URI=mongodb+srv://your_user:your_password@your_cluster.mongodb.net/financeTracker
JWT_SECRET=your_jwt_access_secret_key
REFRESH_TOKEN_SECRET=your_jwt_refresh_secret_key
ML_SERVICE_URL=http://localhost:5050
ALLOWED_ORIGIN=http://localhost:5173

ML Service Environment Setup (ml-service/.env)

Create ml-service/.env based on ml-service/.env.example:

ML_PORT=5050
MONGO_URI=mongodb+srv://your_user:your_password@your_cluster.mongodb.net/financeTracker

๐Ÿš€ Local Installation & Development

1. Prerequisites

Ensure you have the following installed locally:

  • Node.js (v16.x or newer)
  • Python (v3.9.x or newer)
  • A running MongoDB instance (or Atlas account)

2. Set Up the Express Server

cd server
npm install
npm run dev

3. Set Up the ML Microservice

cd ml-service
# Linux/macOS:
python3 -m venv venv
source venv/bin/activate
# Windows:
# python -m venv venv
# venv\Scripts\activate

pip install -r requirements.txt
python app.py

4. Set Up the Client App

cd client
npm install
npm run dev

Open your browser to: http://localhost:5173


๐Ÿ” Security & Production Hardening

The application is structured to meet core industry security and stability guidelines:

  1. CORS Origin Restrictions: Only configured domains (e.g., Vercel host) are authorized to exchange data.
  2. Helmet Security Headers: Protection against cross-site scripting (XSS), clickjacking, and mime-sniffing.
  3. JSON Payload Limits: Enforced 10mb cap on uploads to prevent memory depletion exploits.
  4. Network Resilience: Front-end requests are equipped with a 15-second network timeout; server calls to the Flask microservice use a 2-second circuit-breaking timeout with automated fallback to mathematical calculations if the ML node goes offline.
  5. Brute-Force Rate Limiting: Max 5 sign-in attempts per 15-minute window per IP.

๐Ÿ—„๏ธ Database Schema & Collections Overview

The application utilizes six MongoDB collections modeled via Mongoose to maintain relational constraints:

  • users: Contains account identities, hashed passwords (bcryptjs), and active JWT refresh tokens.
  • transactions: The core ledger holding date, title, amount (negatives represent expenses), category, tag arrays, and user owner association.
  • budgets: Defines monthly category-specific spending caps and overall savings targets.
  • reminders: Scheduled transactions tracking recurring billing events.
  • debts: Outstanding loans or balances owed.
  • merchantrules: Tracks custom classifications created by the user, powering the adaptive category-matching memory.

๐Ÿšข Production Deployment Guide

A. Frontend to Vercel

  1. Select the /client directory in the repository during importing.
  2. Set the build framework to Vite.
  3. Add Environment Variable: VITE_API_URL pointing to your Express API server.
  4. Deployment completes automatically; routing fallbacks are pre-configured inside vercel.json.

B. Express Backend to Render

  1. Select the /server directory.
  2. Set the Environment to Node.
  3. Use the build command npm install.
  4. Use the start command npm start.
  5. Map env variables: MONGO_URI, JWT_SECRET, REFRESH_TOKEN_SECRET, ALLOWED_ORIGIN (your Vercel link), and ML_SERVICE_URL (your Render ML link).

C. Flask ML Microservice to Render

  1. Select the /ml-service directory.
  2. Set the Environment to Python.
  3. Use the build command pip install -r requirements.txt.
  4. Use the start command gunicorn app:app.
  5. Map env variables: MONGO_URI and ML_PORT.

๐Ÿ”ฎ Future Roadmap

  • ๐Ÿ“‰ Advanced Portfolio Analytics: Asset allocation tracking and investment returns integration.
  • ๐Ÿฆ Real-Time Bank Syncing: Secure bank connection via Plaid API for automated ledger updates.
  • ๐Ÿ’ณ Smart Bill Splitting: Group split calculation and peer reminders.

๐Ÿ‘จโ€๐Ÿ’ป Author & Credits


โญ If you found Expensync helpful, please consider starring the repository! โญ

About

Expensync is a full-stack personal finance tracker built with the MERN stack, Tailwind CSS, and Chart.js. This platform helps users track their income, expenses, and budget goals, offering real-time insights and beautiful visualizations for smarter financial decisions.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

โšก