Skip to content

kamalsharma001/SpendSense

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’ฐ SpendSense โ€” AI Expense Tracker

An AI-assisted expense tracking system with intelligent categorization and real-time financial insights.

SpendSense is a full-stack AI-assisted expense tracking application that helps users manage and analyze their finances intelligently. It combines machine learning with interactive dashboards to provide automatic expense categorization and meaningful insights into spending habits.


๐Ÿš€ Live Demo

๐ŸŒ Frontend: SpendSense App
๐Ÿ”— Backend API: API Endpoint

The application is fully deployed and accessible through the live demo links above.


๐Ÿ“ธ Screenshots

๐Ÿ” Authentication Page

Auth

๐Ÿ“Š Dashboard

Dashboard

๐Ÿงพ Expenses Page

Expenses

๐Ÿ“ˆ Insights

Insights


๐Ÿ› ๏ธ Tech Stack

Frontend

  • HTML
  • CSS
  • JavaScript
  • React (CDN)
  • Chart.js

Backend

  • Python (Flask)
  • REST API architecture
  • JWT Authentication

Database

  • PostgreSQL (Render โ€” Production)
  • SQLite (Local Development)

Machine Learning

  • Scikit-learn
  • TF-IDF Vectorizer
  • Naive Bayes Classifier

โœจ Features

  • ๐Ÿ” User Authentication (Signup / Login)
  • ๐Ÿ’ฐ Add, Edit, Delete Expenses
  • ๐Ÿ”Ž Search & Filter Expenses
  • ๐Ÿค– AI-assisted Expense Categorization
  • ๐Ÿ“Š Interactive Dashboard & Charts
  • ๐Ÿ“ˆ Spending Insights & Analytics
  • โ˜๏ธ Fully Deployed (Frontend + Backend + Database)

๐Ÿ”Œ REST API Overview

All endpoints require the header:

Authorization: Bearer <token>

except authentication routes.


๐Ÿ” Authentication

Method Endpoint Description
POST /api/auth/signup Register a new user
POST /api/auth/login Login and receive JWT token

Example signup request:

{
  "name": "Jane",
  "email": "jane@example.com",
  "password": "secret123"
}

Example login request:

{
  "email": "jane@example.com",
  "password": "secret123"
}

Example response:

{
  "token": "<jwt>",
  "user": {
    "id": 1,
    "name": "Jane",
    "email": "jane@example.com"
  }
}

๐Ÿ’ฐ Expenses

Method Endpoint Description
GET /api/expenses List all expenses
POST /api/expenses Add a new expense
PUT /api/expenses/<id> Update an expense
DELETE /api/expenses/<id> Delete an expense
POST /api/expenses/categorize Get AI category suggestion
GET /api/expenses/insights Spending insights and analytics

Example expense request:

{
  "title": "Lunch at Zomato",
  "amount": 350.00,
  "category": "",
  "date": "2024-01-15",
  "notes": "Team lunch"
}

Example insights response:

{
  "total": 12500.00,
  "count": 45,
  "by_category": [
    {
      "category": "Food & Dining",
      "amount": 4200.00,
      "percent": 33.6
    }
  ],
  "monthly": [
    {
      "month": "2024-01",
      "amount": 6200.00
    }
  ]
}

๐Ÿง  AI Workflow

Expense Title โ†’ TF-IDF Vectorization โ†’ Naive Bayes Model โ†’ Category Prediction โ†’ Confidence Check

  • If confidence โ‰ฅ 40% โ†’ ML prediction used
  • If confidence < 40% โ†’ Rule-based fallback categorization

โš™๏ธ Project Structure

spendsense/
โ”‚
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ app.py                      # Flask application entry point
โ”‚   โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”‚   โ”œโ”€โ”€ expenses.db                 # SQLite database (auto-created on first run)
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ models/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ models.py               # SQLAlchemy models (User, Expense)
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ”œโ”€โ”€ auth.py                 # Authentication APIs (signup, login)
โ”‚   โ”‚   โ””โ”€โ”€ expenses.py             # Expense CRUD operations & insights APIs
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ”œโ”€โ”€ categorizer.py          # Rule-based expense categorization logic
โ”‚       โ”œโ”€โ”€ train_model.py          # Script to train ML categorization model
โ”‚       โ””โ”€โ”€ model.pkl               # Trained machine learning model
โ”‚
โ”œโ”€โ”€ frontend/
โ”‚   โ””โ”€โ”€ index.html                  # Single-page React interface (CDN-based)
โ”‚
โ”œโ”€โ”€ screenshots/                    # UI screenshots for README
โ”‚   โ”œโ”€โ”€ auth.png
โ”‚   โ”œโ”€โ”€ dashboard.png
โ”‚   โ”œโ”€โ”€ expenses.png
โ”‚   โ””โ”€โ”€ insights.png
โ”‚
โ”œโ”€โ”€ .gitignore                      # Ignored files (venv, cache, env files)
โ””โ”€โ”€ README.md                       # Project documentation

๐Ÿ”ง Setup Instructions (Local)

Follow these steps to run the project locally.


1๏ธโƒฃ Clone the Repository

git clone https://github.com/kamalsharma001/spendsense.git
cd spendsense

2๏ธโƒฃ Backend Setup

Navigate to the backend folder and create a virtual environment.

cd backend
python -m venv venv

Activate the virtual environment.

Windows

venv\Scripts\activate

Mac / Linux

source venv/bin/activate

Install dependencies and start the backend server.

pip install -r requirements.txt
python utils/train_model.py
python app.py

The backend will start at:

http://127.0.0.1:5000

3๏ธโƒฃ Run the Frontend

Open a new terminal and run:

cd frontend
python -m http.server 3000

Then open your browser and go to:

http://localhost:3000

The application should now be running locally.


๐Ÿš€ Deployment

  • Frontend: Netlify
  • Backend: Render
  • Database: PostgreSQL (Render)

โš ๏ธ Limitations

  • Free database has limited lifetime on free tier
  • Backend may experience cold start delay
  • ML model accuracy depends on training dataset

๐Ÿ”ฎ Future Improvements

  • ๐Ÿ“ฑ Mobile application version
  • ๐Ÿ”” Budget alerts & notifications
  • ๐Ÿ“ค Export reports (PDF / Excel)
  • ๐Ÿง  Advanced ML categorization models
  • ๐Ÿ‘ฅ Multi-user financial analytics

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

Kamal Sharma
B.E. Computer Science Engineering (AI & ML)
Chandigarh University

๐Ÿ“ง sharmakamal1210@gmail.com
๐ŸŒ GitHub: kamalsharma001

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors