Expense Manager CLI is a database-powered command-line application that allows users to manage:
- ✅ Income records
- ✅ Expense records
- ✅ Total balance calculation
- ✅ Category-wise expense summary
Unlike the previous JSON-based version, this project uses MongoDB for permanent, scalable storage.
📌 This project introduces students to real-world database usage in CLI apps.
Project_31_Expense_Manager_DB/
│
├── main.py # Main CLI application
└── requirements.txt # Python dependencies
- Add income entries
- Add expense entries with category & notes
- Automatic date recording
- View total income, expenses & balance
- Category-wise expense summary (table)
- MongoDB-based persistent storage
- Rich-powered colorful CLI interface
-
Python 3.10+
-
MongoDB
- Local MongoDB OR
- MongoDB Atlas
-
Basic knowledge of CLI & Python functions
mongodb://localhost:27017- Create a cluster
- Create database user
- Whitelist IP
- Copy connection string
Update in main.py:
MONGO_URI = "your_mongodb_connection_string"git clone https://github.com/yourusername/expense-manager-db.git
cd expense-manager-dbpython -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windowspip install rich pymongopython main.py====== Budget Tracker CLI ======
1. Add Income
2. Add Expense
3. View Balance
4. Expense Summary
5. Exit
All records are stored in one collection using a type field.
{
"type": "i",
"amount": 5000,
"source": "Salary",
"date": "2025-01-12"
}{
"type": "e",
"amount": 500,
"source": "Food",
"note": "Lunch",
"date": "2025-01-12"
}┌───────────┬────────┐
│ Category │ Amount │
├───────────┼────────┤
│ Food │ 1200 │
│ Travel │ 800 │
│ Shopping │ 1500 │
└───────────┴────────┘
-
MongoDB CRUD operations
-
PyMongo (
insert_one,find) -
Data aggregation using Python
-
CLI menu loop
-
Rich:
- Tables
- Prompts
- Styled output
-
Date handling (
datetime) -
Database-backed application design
| Feature | Project 30 | Project 31 |
|---|---|---|
| Storage | JSON File | MongoDB |
| Scalability | ❌ Limited | ✅ High |
| Database Skills | ❌ No | ✅ Yes |
| Real-world Ready | ✅ |
- Monthly reports
- Date range filters
- User-based expenses
- Export to CSV
- FastAPI + Web UI version
- Authentication layer
📘 CodeShiksha – Python Mastery Course 🎯 Beginner-friendly real-world database project