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.
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.
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:
- 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.
-
Transparent Data Structures:
Unlike hidden database layers, the application's storage system remains fully inspectable. Users can open
expenses.csvdirectly and observe precisely how structured financial records are represented and manipulated programmatically. - 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.
- 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.
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 |
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
- Ensure you have Python 3.8 or above installed locally.
- Clone or download this repository:
git clone https://github.com/Sheikh-H/LedgerFlow.git
- Navigate into the project directory:
cd LedgerFlow
- No external dependencies are required β the project operates entirely using Python standard libraries.
- Run commands directly through the integrated CLI interface.
LedgerFlow operates through a modular subcommand architecture powered by argparse.
Create a brand-new financial transaction entry:
python expense-tracker.py add --description "Coffee" --amount 4.50 --category "Food" --date 23-05-2026
Display every stored expense record:
python expense-tracker.py view
Query expenses using targeted filtering parameters:
python expense-tracker.py view --category Food
python expense-tracker.py view --date 23-05-2026
python expense-tracker.py view --month May
python expense-tracker.py view --year 2026
python expense-tracker.py view --description Coffee
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
Delete records by ID:
python expense-tracker.py delete --id 5
Or by description:
python expense-tracker.py delete --description Coffee
The application is separated into modular operational blocks responsible for command parsing, data persistence, record transformation, and user interaction workflows.
-
on_load(): Initialises the command-line interface, configures all argparse subcommands, builds validation rules, and dynamically parses runtime user arguments.
-
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.
-
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.
-
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.
-
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.
All financial records are stored inside expenses.csv using a structured column-based format:
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
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
- Python Runtime: version 3.8 or above.
-
Internal Standard Modules:
os,sys,csv,time,argparse,datetime. - External Libraries: None.
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.