A simple command-line expense tracker application built with Python. This project helps you manage your personal expenses by allowing you to add, list, update, delete, and analyze your spending habits.
This project is based on the Expense Tracker challenge from roadmap.sh.
- ✅ Add expenses with description, amount, and category
- ✅ List all expenses or filter by category
- ✅ Update existing expenses by ID
- ✅ Delete expenses by ID
- ✅ View summaries of total expenses (overall or by month)
- ✅ Export expenses to CSV format
- ✅ Category-based expense tracking
- ✅ Automatic expense ID generation
- ✅ Data persistence using JSON storage
-
Clone the repository:
git clone https://github.com/jmlc643/expense-tracker.git cd expense-tracker -
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
The application uses a command-line interface with different subcommands:
python main.py add --description "Lunch at restaurant" --category "Food" --amount 25.50# List all expenses
python main.py list
# List expenses by category
python main.py list --category "Food"python main.py update --id 1 --description "Updated description" --amount 30.00 --category "Food"Note: You can update individual fields by providing only the parameters you want to change.
python main.py delete --id 1# Total summary of all expenses
python main.py summary
# Summary for a specific month (1-12)
python main.py summary --month 7python main.py export --filename "my_expenses.csv"# General help
python main.py --help
# Help for specific commands
python main.py add --help
python main.py list --helpHere are some practical examples of how to use the expense tracker:
# Add some expenses
python main.py add --description "Coffee" --category "Food" --amount 4.50
python main.py add --description "Gas" --category "Transportation" --amount 45.00
python main.py add --description "Movie tickets" --category "Entertainment" --amount 24.00
# List all expenses
python main.py list
# Get summary for current month
python main.py summary --month 8
# Export to CSV
python main.py export --filename "august_expenses.csv"expense-tracker/
│
├── main.py # Main application entry point
├── expenses.json # JSON file storing expense data
├── requirements.txt # Python dependencies
├── README.md # Project documentation
│
└── utils/ # Utility modules
├── add_expense.py # Add expense functionality
├── delete_expense.py # Delete expense functionality
├── export_expense.py # CSV export functionality
├── get_expenses.py # Retrieve expenses from storage
├── get_summary.py # Generate expense summaries
├── list_expenses.py # List and display expenses
├── update_expense.py # Update expense functionality
└── verify_json_file.py # JSON file validation and creation
Expenses are stored in JSON format with the following structure:
[
{
"id": 1,
"description": "Lunch at restaurant",
"amount": 25.50,
"category": "Food",
"date": "2025-08-09T14:30:00.123456"
}
]- Python 3.6 or higher
- argparse (included in Python standard library)
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Create a Pull Request
This project is open source and available under the MIT License.
jmlc643 - GitHub Profile
- This project is based on the Expense Tracker challenge from roadmap.sh
- Thanks to the roadmap.sh community for providing excellent learning resources
Built as part of the Backend Development learning path on roadmap.sh