A simple, elegant expense tracking application built with Flask. Track your spending, categorize expenses, and stay on budget.
- ✅ Add, view, and delete expenses
- 📊 Filter expenses by category
- 💵 Real-time total calculation
- 📱 Responsive design
- 🔌 REST API endpoints
- ✨ Clean, modern UI
- 🧪 Comprehensive test suite
expense-tracker/
├── app.py # Main Flask application
├── test_app.py # Pytest test suite
├── requirements.txt # Python dependencies
├── templates/
│ └── index.html # Main HTML template
├── static/
│ └── css/
│ └── style.css # CSS styles
└── README.md # This file
- Python 3.8 or higher
- pip (Python package manager)
-
Clone or download this repository
-
Navigate to the project directory
cd expense-tracker -
Install dependencies
pip install -r requirements.txt
-
Start the Flask development server
python app.py
-
Open your browser and visit
http://localhost:5000 -
Start tracking your expenses!
The application includes a comprehensive test suite using pytest.
pytest test_app.py -v# Test only the Expense class
pytest test_app.py::TestExpenseClass -v
# Test only the routes
pytest test_app.py::TestRoutes -v
# Test only the API
pytest test_app.py::TestAPI -vpip install pytest-cov
pytest test_app.py --cov=app --cov-report=htmltest_app.py::TestExpenseClass::test_expense_creation PASSED
test_app.py::TestExpenseClass::test_expense_with_date PASSED
test_app.py::TestRoutes::test_index_route PASSED
test_app.py::TestRoutes::test_add_expense_success PASSED
...
======================== XX passed in X.XXs ========================
- Fill in the amount, category, description, and date
- Click "Add Expense"
- Your expense will appear in the list below
- Use the dropdown menu to filter by category
- Select "All Categories" to view all expenses
- Click the "Delete" button next to any expense
- Confirm the deletion
- Click "Clear All Expenses" at the bottom
- Confirm to remove all data
The application provides REST API endpoints for programmatic access:
GET /api/expensesResponse:
[
{
"id": 1,
"amount": 50.00,
"category": "Food & Dining",
"description": "Lunch",
"date": "2024-02-09"
}
]GET /api/summaryResponse:
{
"by_category": {
"Food & Dining": 75.50,
"Transportation": 30.00
},
"total": 105.50,
"count": 3
}The application supports the following expense categories:
- 🍔 Food & Dining
- 🚗 Transportation
- 🛍️ Shopping
- 🎬 Entertainment
- 💡 Bills & Utilities
- 🏥 Healthcare
- 📦 Other
Currently, the application uses in-memory storage. This means:
- ✅ Fast and simple
- ❌ Data is lost when the server restarts
- 💡 Future enhancement: Add SQLite or PostgreSQL for persistence
The test suite covers:
- Unit Tests - Testing the Expense class
- Route Tests - Testing Flask endpoints
- API Tests - Testing JSON API responses
- Integration Tests - Testing complete workflows
- Validation Tests - Testing input validation and error handling
- ✅ Expense creation and validation
- ✅ Adding expenses (valid and invalid inputs)
- ✅ Deleting expenses
- ✅ Filtering by category
- ✅ Total calculation
- ✅ API responses
- ✅ Error handling
- ✅ Complete user workflows
- Flask - Python web framework
- pytest - Testing framework
- HTML/CSS - Frontend (no JavaScript frameworks needed!)
This project was built using Claude (Anthropic's AI assistant) to demonstrate effective use of AI code generation tools for rapid application development.
- ✅ Clean, readable code with comments
- ✅ Comprehensive test coverage
- ✅ Input validation and error handling
- ✅ RESTful API design
- ✅ Responsive UI design
- ✅ Clear documentation
Potential improvements for the application:
- Persistent storage (SQLite/PostgreSQL)
- User authentication
- Budget setting and alerts
- Monthly/weekly summaries
- Data export (CSV, PDF)
- Charts and visualizations
- Receipt image uploads
- Recurring expense tracking
If port 5000 is already in use, modify app.py:
app.run(debug=True, host='0.0.0.0', port=5001) # Change portMake sure you've installed all dependencies:
pip install -r requirements.txtEnsure you're in the correct directory and have pytest installed:
pip install pytest
pytest test_app.py -vThis project is provided as-is for educational and demonstration purposes.
This is a demonstration project, but feel free to fork and modify for your own use!
For questions or feedback about this project, please reach out through the repository.
Happy expense tracking! 💰