Skip to content

Sheikh-H/LedgerFlow-Expense-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’· LedgerFlow: Intelligent Command-Line Expense Management System

A structured, CSV-backed command-line finance tracker engineered for rapid expense logging, filtering, and lifecycle management.
Designed for local-first financial telemetry, persistent storage handling, and extensible multi-parameter query architecture.


πŸ“˜ Project Overview

LedgerFlow is a fully interactive command-line expense tracking system developed as a native Python solution for the Expense Tracker project challenge on roadmap.sh.

The application was engineered to simulate a lightweight personal finance management environment directly inside the terminal. Rather than relying on databases or third-party financial frameworks, LedgerFlow intentionally utilises structured CSV persistence to reinforce practical understanding of local file operations, record management, and transactional state handling.

Built with an extensible architecture and powered by Python's argparse module, the system supports dynamic expense creation, targeted querying, expense mutation, deletion workflows, CSV exporting, and temporal filtering by day, month, year, or exact date values.


🧠 Architectural Philosophy & Design Intent

LedgerFlow was intentionally designed around a local-first persistence model, meaning every financial transaction is stored directly inside a human-readable CSV datastore rather than abstracted behind external database engines.

This design philosophy was implemented for several deliberate technical and educational reasons:

  1. Practical Reinforcement of File Handling: The project was engineered to provide repeated, hands-on exposure to Python file I/O operations, structured CSV manipulation, data serialisation, and runtime persistence management. Every expense insertion, modification, deletion, or export operation directly interacts with the filesystem.
  2. Transparent Data Structures: Unlike hidden database layers, the application's storage system remains fully inspectable. Users can open expenses.csv directly and observe precisely how structured financial records are represented and manipulated programmatically.
  3. CLI-Centric Workflow Optimisation: The application avoids graphical overhead entirely in favour of highly deterministic command execution. This creates an efficient workflow for users comfortable operating inside shell environments and allows for rapid data management through positional arguments and flags.
  4. Scalable Query Foundations: While the current implementation processes one filtering parameter at a time during view operations, the internal architecture already introduces transitional list-based result handling designed to support future multi-filter querying systems.

⚑ Core Features & Project Enhancements

Although the application fulfils the baseline roadmap.sh requirements, LedgerFlow introduces a significantly expanded command architecture and multiple advanced behaviours:

Capability Standard Requirements LedgerFlow Implementation
Expense Persistence Store expenses locally Structured CSV-backed datastore with automatic file creation and persistent financial record indexing
Command Processing Basic terminal argument handling Full argparse integration with subcommands, validation pipelines, mutually exclusive groups, and structured help menus
Expense Querying Simple record viewing Granular temporal filtering by date, month, day, year, category, ID, or description
Export Handling Display results to console Dynamic CSV export pipeline saving filtered results into structured reports
Error Recovery Basic failures terminate execution Structured terminal error sequencing with staged prompts and safe shutdowns
Record Mutability Update expense values Dual-mode mutation engine via ID or description lookup

🧩 Folder Structure

LedgerFlow/
β”‚
β”œβ”€β”€ expense-tracker.py   # Main CLI application and processing engine
β”œβ”€β”€ expenses.csv         # Persistent expense datastore
β”œβ”€β”€ filtered_expense.csv # Exported filtered query reports
└── README.md            # Project documentation

πŸš€ How to Run

  1. Ensure you have Python 3.8 or above installed locally.
  2. Clone or download this repository:
    git clone https://github.com/Sheikh-H/LedgerFlow.git
  3. Navigate into the project directory:
    cd LedgerFlow
  4. No external dependencies are required β€” the project operates entirely using Python standard libraries.
  5. Run commands directly through the integrated CLI interface.

πŸ–₯️ Detailed Usage & Command Manual

LedgerFlow operates through a modular subcommand architecture powered by argparse.


1. Adding New Expenses

Create a brand-new financial transaction entry:

python expense-tracker.py add --description "Coffee" --amount 4.50 --category "Food" --date 23-05-2026

2. Viewing All Expenses

Display every stored expense record:

python expense-tracker.py view

3. Filtering Expenses

Query expenses using targeted filtering parameters:

Filter By Category

python expense-tracker.py view --category Food

Filter By Date

python expense-tracker.py view --date 23-05-2026

Filter By Month

python expense-tracker.py view --month May

Filter By Year

python expense-tracker.py view --year 2026

Filter By Description

python expense-tracker.py view --description Coffee

4. Updating Existing Expenses

Modify existing expense records using either an ID or description lookup:

python expense-tracker.py update --id 3 --amount 12.99

Example updating multiple fields simultaneously:

python expense-tracker.py update --description Coffee --newdescription "Costa Coffee" --amount 5.20 --category Drinks

5. Deleting Expenses

Delete records by ID:

python expense-tracker.py delete --id 5

Or by description:

python expense-tracker.py delete --description Coffee

βš™οΈ Code Architecture & Function Breakdown

The application is separated into modular operational blocks responsible for command parsing, data persistence, record transformation, and user interaction workflows.


CLI Bootloader & Argument Engine

  • on_load(): Initialises the command-line interface, configures all argparse subcommands, builds validation rules, and dynamically parses runtime user arguments.

Persistence & File Management

  • load_file(): Automatically creates the expense datastore if missing, loads structured CSV rows into memory, and returns a manipulatable list structure.
  • save_data(DATA): Serialises active runtime expense records directly back into the CSV datastore while preserving field consistency.

Expense Lifecycle Controllers

  • add_expense(): Generates unique IDs, validates date structures, normalises category formatting, and appends new expenses into persistent storage.
  • update_expense(): Handles selective record mutation using either unique IDs or description references while preserving untouched fields.
  • delete_expense(): Removes expense records safely while handling duplicate description conflicts through guided user feedback.

Query & Filtering System

  • view_all(): Renders the complete expense ledger to the terminal.
  • view_by(): Processes dynamic expense filtering across multiple financial dimensions including temporal queries, categories, IDs, and textual descriptions.
  • export_to_csv(): Exports filtered query results into a standalone CSV report for external analysis or archival storage.

System Utilities

  • clear_screen(): Performs operating-system aware terminal clearing for cleaner UI presentation.
  • error_messages(): Displays staged runtime alerts with timed delays before safely terminating the application.

πŸ“‚ Local Data Architecture

All financial records are stored inside expenses.csv using a structured column-based format:

Sample Datastore Layout

ID,Date,Description,Amount,Category
1,2026-05-23,Coffee,4.50,FOOD
2,2026-05-24,Train Ticket,18.20,TRANSPORT
3,2026-05-25,Netflix,10.99,ENTERTAINMENT

πŸ§ͺ Current Limitations & Future Improvements

The current query engine processes one filter parameter at a time. A future architectural redesign is planned to support multi-condition filtering.

The intended future implementation involves generating a temporary in-memory results list containing all expense records before progressively eliminating entries that fail to match layered filter conditions.

This would allow advanced query combinations such as:

python expense-tracker.py view --category Food --month May --year 2026

Additional planned improvements include:

  • Multi-parameter query chaining
  • Summary statistics and spending analytics
  • Budget threshold monitoring
  • Coloured terminal rendering
  • SQLite backend migration
  • Advanced report generation

🧰 Requirements & Dependencies

  • Python Runtime: version 3.8 or above.
  • Internal Standard Modules: os, sys, csv, time, argparse, datetime.
  • External Libraries: None.

πŸ“„ Licence

This project is licensed under the MIT Licence β€” see the LICENCE file for details.

MIT Licence

Copyright (c) 2026 Sheikh Hussain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Footnote

πŸ—£οΈ Feel free to follow, connect, and chat!

GitHub LinkedIn Gmail Portfolio

⭐ If you like this project, please give it a star on GitHub!

About

LedgerFlow is a Python CLI expense tracker that lets users add, update, delete, and filter expenses stored in a CSV file. It features a structured argparse interface, persistent local storage, and flexible querying by date, category, ID, and more for efficient terminal-based finance management.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages