Skip to content
codeByAmalPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpendWise CLI-Personal Expense Tracker

A beginner-friendly, modular command-line application built in Python to record daily expenses, organize spending by category, and persist records to a local JSON file.


Features

  • Add Expenses: Record new expenses with validated IDs (EXP-001), dates (YYYY-MM-DD), categories, numeric amounts, and comma-separated tags.
  • View All Expenses: List all saved expense entries alongside the total spending amount.
  • Category Summary: Aggregate and display total spending grouped by category.
  • Search by Category: Filter and view expenses matching a specific category name.
  • Persistent JSON Storage: Automatically loads existing records from expenses.json at startup and saves updates on exit, safely handling missing or empty files.

Project Structure

spendwise_project/
│
├── expenses.json   # Automatically generated JSON data store
├── models.py       # Expense and ExpenseTracker data models and logic
├── storage.py      # JSON serialization and file read/write handlers
├── utils.py        # Regex validators and tag parsing helpers
├── main.py         # Interactive CLI loop and match-case menu
└── README.md       # Project documentation

Requirements

  • Python 3.10+ (required for match-case structural pattern matching)
  • Uses only Python standard library modules (json, re) — no external packages required.

How to Run

  1. Open a terminal or command prompt inside the spendwise_project folder.
  2. Run the main script:
    python main.py
  3. Follow the on-screen menu options (1 to 5) to manage your expenses.

Usage Example

===== SpendWise CLI =====
1. Add expense
2. View all expenses
3. View category summary
4. Search expenses by category
5. Save and exit
Enter your choice: 1
Enter expense ID (EXP-001): EXP-100
Enter date (YYYY-MM-DD): 2026-03-22
Enter category: Food
Enter amount: 250.0
Enter tags separated by commas: sandwich, burger, shawarma
Expense added successfully.

Key Concepts Applied

  • Object-Oriented Programming (models.py): Custom Expense and ExpenseTracker classes with to_dict(), @classmethod from_dict(), and __str__() methods.
  • Python Collections:
    • list — Stores sequential Expense objects inside ExpenseTracker.
    • dict — Computes category-wise spending totals (get_category_totals()).
    • set — Stores deduplicated, lowercase tags per expense (parse_tags()).
  • Regular Expressions (utils.py): Validates EXP-XXX IDs (^EXP-[0-9]{3}$) and YYYY-MM-DD dates (^\d{4}-\d{2}-\d{2}$).
  • Exception Handling (storage.py & main.py): Safely catches FileNotFoundError, json.JSONDecodeError, and ValueError without crashing.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages