A command-line expense tracking application built with Python that helps you manage your finances, analyze spending patterns, and generate beautiful visualizations.
- ✅ Add, View, and Delete Expenses - Full CRUD operations via command line
- 📊 Spending Analysis - Category-wise breakdown with percentages
- 📈 Data Visualization - Pie charts, bar charts, and trend graphs
- 🗄️ SQLite Database - Persistent data storage with zero configuration
- 🎨 Beautiful Terminal Output - Clean, formatted tables and reports
- 📅 Date Filtering - View expenses by month, week, or custom periods
- 💾 High-Quality Exports - Save charts as 300 DPI PNG images
python main.py add --amount 500 --category food --description "Lunch at restaurant"python main.py viewpython main.py analyze --period monthpython main.py visualize --type pie --period monthexpense-tracker/
├── main.py # CLI interface and command routing
├── database.py # SQLite database operations
├── analytics.py # Data analysis and statistics
├── visualization.py # Chart generation with Matplotlib
├── requirements.txt # Project dependencies
└── README.md # Documentation
The application follows a modular design with separation of concerns:
- main.py - Command-line interface using argparse
- database.py - All SQLite operations (CREATE, INSERT, SELECT, DELETE)
- analytics.py - Business logic for data analysis and calculations
- visualization.py - Chart generation using Matplotlib
- Python 3.7 or higher
- pip (Python package manager)
- Clone the repository
git clone https://github.com/yourusername/expense-tracker.git
cd expense-tracker- Install dependencies
pip install -r requirements.txtOr install manually:
pip install matplotlib- Run the application
python main.py --help# Basic usage
python main.py add --amount 500 --category food --description "Groceries"
# With custom date
python main.py add --amount 200 --category transport --date 2025-11-20# View all expenses
python main.py view
# View expenses for specific month
python main.py view --month 11 --year 2025python main.py delete --id 5# Current month analysis
python main.py analyze --period month
# Last week analysis
python main.py analyze --period week
# All-time analysis
python main.py analyze --period all# Pie chart (spending distribution)
python main.py visualize --type pie --period month
# Trend chart (daily spending over time)
python main.py visualize --type trend --days 30
# Bar chart (category comparison)
python main.py visualize --type bar --period month
# Generate all charts
python main.py visualize --type allpython main.py summarypython main.py compare --period1 month --period2 weekThe application generates three types of professional charts:
Shows spending distribution across categories with percentages.
Line graph displaying daily spending patterns over time.
Category-wise comparison with labeled amounts.
All charts are:
- Saved as high-resolution PNG files (300 DPI)
- Color-coded for easy interpretation
- Professionally formatted with titles and legends
CREATE TABLE expenses (
id INTEGER PRIMARY KEY AUTOINCREMENT,
amount REAL NOT NULL,
category TEXT NOT NULL,
description TEXT,
date TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);# 1. Add some expenses
python main.py add --amount 300 --category food --description "Lunch"
python main.py add --amount 200 --category transport --description "Uber"
python main.py add --amount 1500 --category shopping --description "New clothes"
# 2. View all expenses
python main.py view
# 3. Analyze spending
python main.py analyze --period month
# 4. Generate visualizations
python main.py visualize --type pie
python main.py visualize --type trend --days 30| Technology | Purpose |
|---|---|
| Python 3.x | Core programming language |
| SQLite | Lightweight database (built-in) |
| Matplotlib | Data visualization library |
| Argparse | Command-line interface framework |
Building this project taught me:
- 🗄️ Database Design - Creating schemas, writing SQL queries, managing data integrity
- 📊 Data Analysis - Calculating statistics, grouping data, computing percentages
- 🎨 Data Visualization - Creating professional charts with Matplotlib
- 🏗️ Software Architecture - Modular design, separation of concerns
- 🖥️ CLI Development - Building user-friendly command-line tools with argparse
- 🐛 Error Handling - Validation, exception handling, user feedback
Planned features for future versions:
- Budget limit alerts and notifications
- Export data to Excel/CSV formats
- Recurring expense tracking
- Monthly PDF reports generation
- Multi-currency support
- Machine learning for spending predictions
- Web dashboard interface
- Mobile app integration
Contributions are welcome! Feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
- GitHub: @yourusername
- LinkedIn: Your LinkedIn
- Email: your.email@example.com
- Python community for excellent documentation
- Matplotlib developers for the powerful visualization library
- Stack Overflow community for helpful discussions
ID Date Category Description Amount
==========================================================================
1 2025-11-20 food Lunch ₹300.00
2 2025-11-20 transport Uber ₹200.00
3 2025-11-20 shopping New clothes ₹1,500.00
==========================================================================
TOTAL ₹2,000.00
📊 SPENDING ANALYSIS (MONTH)
============================================================
Category Amount Percentage Count
food ₹500.00 25.0% [2]
shopping ₹1,500.00 75.0% [1]
============================================================
TOTAL ₹2,000.00
⭐ If you find this project helpful, please give it a star! ⭐
None at the moment. If you find any bugs, please open an issue!
If you have any questions or need help, feel free to:
- Open an issue on GitHub
- Reach out via email
- Connect on LinkedIn
Made with ❤️ and Python