Skip to content

Repository files navigation

๐Ÿ’ฐ Smart Expense Tracker (C++ Edition)

License Language Build Status

A production-ready command-line expense tracker built in C++17 with a SQLite backend. Track daily spending, organize expenses by category, and get automatic insights โ€” category breakdowns, monthly reports, and smart budget warnings.

โœจ Perfect for learning: OOP design patterns, database management, and CLI applications in modern C++!

This is a C++ rewrite of an earlier Python/Pandas version, redesigned around object-oriented principles, raw SQL with prepared statements, and a custom in-memory analytics engine (no external data processing libraries).


โšก Key Features

  • โœ… Full CRUD Operations โ€” Add, view, update, and delete expense records with SQLite persistence
  • ๐Ÿ“Š Smart Filtering โ€” Filter expenses by category or date range
  • ๐Ÿ“ˆ Advanced Analytics Engine โ€” Category breakdowns, monthly reports, weekly (ISO week) reports, and summary insights
  • ๐Ÿ’ก Budget Alerts โ€” Set monthly budgets per category and get notifications when you exceed them
  • ๐Ÿ›ก๏ธ Data Validation โ€” Strict validation for amounts, dates, and categories
  • โš™๏ธ Optimized Database โ€” Normalized schema with indexed queries for lightning-fast performance

๐Ÿ—๏ธ Tech Stack

Layer Technology
Language C++17 (Modern C++)
Database SQLite3 (via official C API)
Build System Make + g++
Architecture OOP with Clean Code Principles

๐Ÿ“‚ Project Structure

Expense-Tracker/
โ”œโ”€โ”€ include/
โ”‚   โ”œโ”€โ”€ Expense.h        # Data model for a single expense
โ”‚   โ”œโ”€โ”€ Database.h       # SQLite wrapper - schema, CRUD, queries
โ”‚   โ”œโ”€โ”€ Analytics.h      # Insights engine - breakdowns, reports
โ”‚   โ””โ”€โ”€ Tracker.h        # Application controller / CLI logic
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ Expense.cpp
โ”‚   โ”œโ”€โ”€ Database.cpp
โ”‚   โ”œโ”€โ”€ Analytics.cpp
โ”‚   โ”œโ”€โ”€ Tracker.cpp
โ”‚   โ””โ”€โ”€ main.cpp         # CLI entry point & menu system
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ LICENSE              # MIT License
โ””โ”€โ”€ README.md

๐ŸŽฏ Architecture Overview

  • Expense โ€” Plain data class representing a single transaction (id, amount, category, description, date)
  • Database โ€” Manages SQLite connection, schema creation, and prepared-statement CRUD operations
  • Analytics โ€” Computes category totals, monthly/weekly aggregates, top spending, and budget comparisons
  • Tracker โ€” Controller class that validates input and orchestrates Database & Analytics operations

๐Ÿ—„๏ธ Database Schema

CREATE TABLE categories (
    name         TEXT PRIMARY KEY,
    budget_limit REAL DEFAULT 0
);

CREATE TABLE expenses (
    id          INTEGER PRIMARY KEY AUTOINCREMENT,
    amount      REAL NOT NULL,
    category    TEXT NOT NULL,
    description TEXT,
    date        TEXT NOT NULL,
    FOREIGN KEY (category) REFERENCES categories(name)
);

CREATE INDEX idx_expenses_category ON expenses(category);
CREATE INDEX idx_expenses_date     ON expenses(date);

Default Categories: Food, Transport, Utilities, Entertainment, Health, Shopping, Other


๐Ÿš€ Quick Start

Prerequisites

  • C++17 compiler (g++ 9+ or equivalent)
  • make build tool
  • SQLite3 development headers

Ubuntu/Debian:

sudo apt update
sudo apt install build-essential libsqlite3-dev

macOS (Homebrew):

brew install sqlite3

Build & Run

# Clone the repository
git clone https://github.com/yashkumar3006/Expense-Tracker.git
cd Expense-Tracker

# Build the project
make

# Run the application
./expense_tracker
# or simply: make run

A SQLite database (expenses.db) is created automatically on first run.

Clean Build Artifacts

make clean

๐Ÿ’ก Usage Examples

Interactive Menu

================ SMART EXPENSE TRACKER ================
 1. Add Expense
 2. View All Expenses
 3. View Expenses by Category
 4. View Expenses by Date Range
 5. Update Expense
 6. Delete Expense
 --------------------------------------------------------
 7. Summary Report (full insights)
 8. Category Breakdown
 9. Monthly Report
10. Weekly Report
11. Budget Warnings
 --------------------------------------------------------
12. List Categories
13. Set Category Budget
 0. Exit
=========================================================

Adding an Expense

Select an option: 1
Enter amount: 450
Enter category: Food
Enter description: Lunch at a cafe
Enter date (YYYY-MM-DD): 2026-07-24
โœ“ Expense added successfully.

Sample Summary Report

========== EXPENSE SUMMARY REPORT ==========
Total Spend:    Rs. 3000.00
Total Records:  4
Top Category:   Food

--- Category Breakdown ---
  Entertainment  Rs.     800.00  (26.7%)
  Food           Rs.    2000.00  (66.7%)
  Transport      Rs.     200.00  (6.7%)

--- Monthly Report ---
  2026-06 : Rs. 3000.00

--- Weekly Report ---
  2026-W23 : Rs. 700.00
  2026-W24 : Rs. 2300.00

--- Budget Warnings ---
  Food: Spent Rs. 2000.00 / Budget Rs. 1500.00 โš ๏ธ OVER BUDGET!
==============================================

๐ŸŽ“ Learning Outcomes

This project demonstrates:

  • โœ… Modern C++17 features and best practices
  • โœ… Object-Oriented Design principles
  • โœ… SQL database integration and query optimization
  • โœ… CLI application development
  • โœ… Error handling and validation
  • โœ… Memory management and resource cleanup

Perfect for students and developers looking to strengthen their C++ skills!


๐Ÿ”ฎ Potential Enhancements

  • ๐Ÿ“„ Export reports to CSV/PDF
  • ๐Ÿ‘ฅ Multi-user support with authentication
  • ๐Ÿ”„ Recurring expense management
  • ๐ŸŽจ TUI interface using ncurses
  • ๐Ÿ“ฑ REST API wrapper
  • ๐Ÿ” Data encryption support

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

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

๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.


๐ŸŒŸ Show Your Support

If you find this project helpful, please give it a โญ star on GitHub! It helps increase visibility and lets others discover it.

Have feedback or ideas? Feel free to open an Issue or start a Discussion.


๐Ÿ“ž Connect

  • GitHub: @yashkumar3006
  • Questions? Open an issue or discussion in the repository

Made with โค๏ธ by Yash Kumar

About

๐Ÿš€ A modern C++17 Expense Tracker with SQLite3, Object-Oriented Programming (OOP), interactive CLI, budget tracking, expense analytics, ASCII charts, CSV export, and persistent storage.

Topics

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages