Skip to content

ropa1295/SpendSense

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’° SpendSense

SpendSense is a comprehensive personal finance management application that helps you track expenses, manage budgets, set financial goals, and analyze spending patterns with beautiful visualizations.

SpendSense Dashboard Python Flask License


πŸ“‹ Table of Contents


✨ Features

πŸ’³ Transaction Management

  • Add, Edit, Delete Transactions: Easily manage your financial transactions
  • Categorization: Organize expenses into 20+ predefined categories
  • Date Filtering: View transactions by month and year
  • CSV Export: Download your transaction history for external analysis
  • Real-time Updates: Instant dashboard updates when transactions change

πŸ“Š Budget Planning

  • Monthly Budgets: Set overall and category-specific budgets
  • Budget Tracking: Monitor spending vs. budget in real-time
  • Visual Alerts: Get warnings when approaching or exceeding budgets
  • Budget Analysis: Comprehensive budget performance metrics
  • Multi-period Comparison: Compare budget performance across months

🎯 Financial Goals

  • Goal Setting: Define savings goals with target amounts and deadlines
  • Progress Tracking: Visual progress bars and percentage completion
  • Goal Icons: Customize goals with emoji icons
  • Contribution Management: Add contributions and track goal milestones
  • Achievement System: Mark goals as complete when reached

πŸ“ˆ Analytics & Visualizations

  • Spending Breakdown: Pie charts showing category distribution
  • Top Categories: Bar charts highlighting biggest spending areas
  • Monthly Trends: Line graphs tracking spending over time
  • Historical Analysis: 6-month historical spending overview
  • Financial Health Meter: Visual gauge of overall financial position

🎨 User Interface

  • Modern Design: Clean, intuitive dashboard with card-based layout
  • Responsive: Works seamlessly on desktop and mobile devices
  • Dark Mode Ready: Professional color scheme with teal accents
  • Interactive Charts: Dynamic visualizations using Matplotlib and Canvas
  • Tab Navigation: Easy switching between Transactions, Goals, and History

πŸŽ₯ Demo

Main Dashboard

The dashboard provides an at-a-glance view of your financial health:

  • Net position indicator
  • Average daily spending
  • Active savings goals
  • Recent transactions
  • Category breakdowns

Budget Management

Set and track budgets with visual progress indicators:

  • Total budget vs. actual spending
  • Category-level budget tracking
  • Budget utilization percentage
  • Over/under budget alerts

Goal Tracking

Create and monitor financial goals:

  • Multiple concurrent goals
  • Progress visualization
  • Deadline tracking
  • Contribution history

πŸ›  Tech Stack

Backend

  • Python 3.8+: Core programming language
  • Flask 2.0+: Web framework
  • Flask-RESTX: REST API with Swagger documentation
  • Flask-CORS: Cross-origin resource sharing

Data Visualization

  • Matplotlib: Chart generation
  • NumPy: Statistical calculations

Frontend

  • HTML5/CSS3: Modern web standards
  • JavaScript (ES6+): Interactive functionality
  • Canvas API: Custom chart rendering
  • LocalStorage: Client-side goal persistence

Architecture

  • MVC Pattern: Model-View-Controller separation
  • RESTful API: Standard HTTP methods
  • Component-based: Modular controller design

πŸš€ Installation

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)
  • Virtual environment (recommended)

Step 1: Clone the Repository

git clone https://github.com/ropa1295/SpendSense.git
cd SpendSense

Step 2: Create Virtual Environment

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate

# On Windows:
venv\Scripts\activate

Step 3: Install Dependencies

pip install flask flask-restx flask-cors matplotlib numpy

Step 4: Run the Application

# Initialize with sample data and start server
python src/main.py

# Or run the Flask app directly
python src/web_app.py

Step 5: Access the Application

Open your web browser and navigate to:

http://localhost:5000

πŸ“– Usage

Adding a Transaction

  1. Click the "+ New Expense" button or "Quick Add" in the sidebar
  2. Fill in the transaction details:
    • Amount
    • Category (select from dropdown)
    • Date
    • Description (optional)
  3. Click "Add Expense" to save

Setting a Budget

  1. Navigate to the Transactions tab
  2. Use the month selector to choose the budget period
  3. Enter the budget amount
  4. Select a category (leave empty for total budget)
  5. Click "Set Budget"

Creating a Goal

  1. Switch to the Goals tab
  2. Click "+ Set New Goal"
  3. Enter goal details:
    • Goal name
    • Target amount
    • Current amount
    • Target date
    • Icon
  4. Click "Create Goal"

Viewing Analytics

  1. Go to the History tab
  2. View 6-month trends
  3. Analyze spending patterns
  4. Export reports for external analysis

Exporting Data

  • Click the CSV export button on any transaction view
  • Downloaded file includes all transaction details
  • Compatible with Excel, Google Sheets, and other tools

πŸ§ͺ Testing

SpendSense includes a comprehensive test suite to ensure code quality and reliability.

Test Coverage

The test suite includes:

  • Unit Tests: Model and controller tests
  • Integration Tests: API endpoint tests
  • Coverage: 60+ test cases across 5 test files

Running Tests

Run All Tests

# Using the test runner script
python run_tests.py

# Or using unittest directly
python -m unittest discover tests

Run Specific Test File

# Using the test runner
python run_tests.py --file test_transaction_model.py

# Using unittest
python -m unittest tests.test_transaction_model

Verbose Output

python run_tests.py --verbose

Quiet Output

python run_tests.py --quiet

Test Structure

tests/
β”œβ”€β”€ __init__.py
β”œβ”€β”€ test_transaction_model.py      # Transaction model tests (11 cases)
β”œβ”€β”€ test_budget_model.py            # Budget model tests (9 cases)
β”œβ”€β”€ test_spend_controller.py        # Spend controller tests (14 cases)
β”œβ”€β”€ test_sense_controller.py        # Sense controller tests (12 cases)
└── test_api_endpoints.py           # API integration tests (20+ cases)

Test Categories

Model Tests (test_transaction_model.py, test_budget_model.py)

  • Data model creation and validation
  • Property access and immutability
  • Edge cases and error handling
  • Data serialization (to_dict)

Controller Tests (test_spend_controller.py, test_sense_controller.py)

  • CRUD operations (Create, Read, Update, Delete)
  • Business logic validation
  • Filtering and search functionality
  • CSV export functionality
  • Budget calculations and analysis

API Tests (test_api_endpoints.py)

  • HTTP endpoint testing
  • Request/response validation
  • Error handling (404, 400, etc.)
  • Integration between layers
  • CORS and content-type headers

Writing Tests

When adding new features, include corresponding tests:

import unittest
from controllers.spend_controller import SpendController

class TestNewFeature(unittest.TestCase):
    def setUp(self):
        self.controller = SpendController()
    
    def test_new_functionality(self):
        result = self.controller.new_method()
        self.assertEqual(result, expected_value)

Continuous Integration

Tests can be integrated into CI/CD pipelines:

# Exit with code 0 if tests pass, 1 if they fail
python run_tests.py

πŸ“ Project Structure

SpendSense/
β”‚
β”œβ”€β”€ src/                          # Source code
β”‚   β”œβ”€β”€ main.py                  # Application entry point
β”‚   β”œβ”€β”€ web_app.py               # Flask application & routes
β”‚   β”œβ”€β”€ api.py                   # REST API endpoints
β”‚   β”‚
β”‚   β”œβ”€β”€ controllers/             # Business logic
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ spend_controller.py  # Transaction management
β”‚   β”‚   └── sense_controller.py  # Budget management
β”‚   β”‚
β”‚   β”œβ”€β”€ models/                  # Data models
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ transaction.py       # Transaction model
β”‚   β”‚   └── budget_plan.py       # Budget model
β”‚   β”‚
β”‚   β”œβ”€β”€ views/                   # View layer
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ transaction_display.py  # Transaction UI
β”‚   β”‚   β”œβ”€β”€ visual_analytics.py     # Chart generation
β”‚   β”‚   β”œβ”€β”€ expense_view.py         # Legacy wrapper
β”‚   β”‚   └── chart_view.py           # Legacy wrapper
β”‚   β”‚
β”‚   └── utils/                   # Utility functions
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ csv_handler.py       # CSV export
β”‚       └── data_validator.py    # Input validation
β”‚
β”œβ”€β”€ tests/                       # Test suite
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ test_transaction_model.py    # Transaction model tests
β”‚   β”œβ”€β”€ test_budget_model.py         # Budget model tests
β”‚   β”œβ”€β”€ test_spend_controller.py     # Spend controller tests
β”‚   β”œβ”€β”€ test_sense_controller.py     # Sense controller tests
β”‚   └── test_api_endpoints.py        # API integration tests
β”‚
β”œβ”€β”€ templates/                   # HTML templates
β”‚   └── index.html              # Main dashboard
β”‚
β”œβ”€β”€ static/                      # Static assets
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── style.css           # Application styles
β”‚   └── js/
β”‚       └── app.js              # Frontend JavaScript
β”‚
β”œβ”€β”€ run_tests.py                 # Test runner script
β”œβ”€β”€ README.md                    # This file
β”œβ”€β”€ WEB_APP.md                  # Web application architecture documentation
β”œβ”€β”€ QUICKSTART.md               # Quick start guide
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ LICENSE                     # MIT License
└── .gitignore                  # Git ignore file

πŸ”Œ API Documentation

SpendSense provides a comprehensive REST API with interactive Swagger documentation.

API Base URL

http://localhost:5000/api

Interactive Documentation

Access Swagger UI at:

http://localhost:5000/api/docs/

Main Endpoints

Transactions

GET    /api/expenses              # List all transactions
POST   /api/expenses              # Create new transaction
GET    /api/expenses/{id}         # Get transaction details
PUT    /api/expenses/{id}         # Update transaction
DELETE /api/expenses/{id}         # Delete transaction
GET    /api/expenses/export/csv   # Export to CSV

Budgets

GET    /api/budgets               # List all budgets
POST   /api/budgets               # Create/update budget
GET    /api/budgets/analysis/{month}  # Get budget analysis
DELETE /api/budgets/{id}          # Delete budget

Analytics

GET    /api/stats                 # Get spending statistics
GET    /api/chart/category        # Category pie chart
GET    /api/chart/budget/{month}  # Budget comparison chart
GET    /api/chart/monthly-trend   # Monthly trend chart

Health Check

GET    /api/health                # Service health status

Example API Calls

Create a Transaction:

curl -X POST http://localhost:5000/api/expenses \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 45.99,
    "category": "Groceries",
    "date": "2025-10-24",
    "description": "Weekly grocery shopping"
  }'

Get Budget Analysis:

curl http://localhost:5000/api/budgets/analysis/2025-10

πŸ“Έ Screenshots

Dashboard View

Main dashboard with financial health meter, spending habits, and recent transactions.

Budget Management

Visual budget tracking with progress bars and category breakdowns.

Goal Tracking

Interactive goal cards showing progress and achievement status.

Historical Analysis

6-month trend charts with spending patterns and top categories.


βš™οΈ Configuration

Port Configuration

Default port is 5000. To change:

# In src/web_app.py or src/main.py
app.run(debug=True, host='0.0.0.0', port=YOUR_PORT)

Sample Data

The application initializes with sample data for demonstration. To disable:

# In src/main.py, comment out:
# initialize_sample_data()

Debug Mode

For production deployment, disable debug mode:

app.run(debug=False, host='0.0.0.0', port=5000)

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/AmazingFeature
  3. Commit your changes
    git commit -m 'Add some AmazingFeature'
  4. Push to the branch
    git push origin feature/AmazingFeature
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guide for Python code
  • Write descriptive commit messages
  • Add comments for complex logic
  • Test thoroughly before submitting
  • Update documentation as needed

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Flask: Micro web framework
  • Matplotlib: Visualization library
  • Font Awesome: Icons (if used)
  • Community: Open source contributors

πŸ“ž Contact

Project Maintainer: ropa1295

Repository: https://github.com/ropa1295/SpendSense

Issues: https://github.com/ropa1295/SpendSense/issues


πŸ—ΊοΈ Roadmap

Upcoming Features

  • Multi-currency support
  • Recurring transaction templates
  • Advanced reporting and analytics
  • Mobile app (React Native)
  • Bank account integration
  • AI-powered spending insights
  • Collaborative budgets (family sharing)
  • Investment tracking
  • Bill reminders and notifications
  • Data backup and sync

πŸ’‘ Tips & Best Practices

Getting the Most Out of SpendSense

  1. Consistent Categorization: Use the same categories for similar expenses
  2. Regular Updates: Record transactions daily for accurate tracking
  3. Set Realistic Budgets: Start conservative and adjust based on actual spending
  4. Use Goals: Break large savings targets into smaller, achievable goals
  5. Review Monthly: Check your History tab at month-end to identify trends
  6. Export Data: Regularly backup your data using CSV export

πŸ› Troubleshooting

Common Issues

Issue: Port 5000 already in use

# Solution: Use a different port
python src/web_app.py --port 5001

Issue: Module not found errors

# Solution: Install missing dependencies
pip install flask flask-restx flask-cors matplotlib numpy

Issue: Charts not displaying

# Solution: Ensure matplotlib backend is set correctly
# In web_app.py, verify:
import matplotlib
matplotlib.use('Agg')

πŸ“š Additional Resources


Made with ❀️ by the SpendSense Team

⭐ Star us on GitHub if you find this helpful!

About

Intelligent, self-hosted web app for tracking and analyzing personal expenses to foster smarter spending habits.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors