A robust, Object-Oriented command-line application built in Python for managing users and tasks.
This program was developed with a strong focus on Defensive Programming, Data Integrity, and Clean Code Architecture, strictly adhering to modern Python standards and Ruff linter compliance.
- Defensive Programming & Validation: Comprehensive input sanitisation and validation. Handles edge cases such as delimiter collisions (preventing CSV corruption from rogue commas), enforces alphanumeric-only usernames, and validates strict date formats using
try-except-elsecontrol flows. - Object-Oriented Design (OOP): Deeply modular architecture separating concerns into distinct classes (
User,Admin,Task) and data managers (UserManager,TaskManager) to encapsulate logic and state. - Modular Refactoring: Transitioned from a monolithic script to a professional multi-module architecture, improving maintainability and testability.
- Linter & Standard Compliance: The codebase passes strict Ruff linting, specifically engineered to maintain low McCabe Cyclomatic Complexity (C901), avoid Boolean Traps (FBT), and implement clean early-return/break logic (RET).
- Safe File I/O: Utilises Python's modern
pathlibfor cross-platform compatibility and explicitly enforcesutf-8encoding to prevent character crashes across different operating systems. - Secure CLI Experience: Integrates the
getpassmodule to obfuscate passwords in the terminal and uses dynamic string formatting (f-stringswith alignment padding andtextwrap) to generate pixel-perfect, responsive statistics tables.
The program is split into specialised modules to ensure a Separation of Concerns:
main.py: The entry point. Uses a lightweight execution loop and dictionary-based dispatching for menu actions to keep the code flat and readable.models.py: Contains core data structures (User,Admin,Task). Utilises inheritance to manage different user permission levels.managers.py: Orchestrates data persistence. Handles the lifecycle of loading, instantiating, and saving objects to the data source.actions.py: The business logic layer. Contains the high-level functions for registering users, managing tasks, and generating reports.utils.py: A dedicated toolbox for reusable helper functions, specifically focused on recursive validation and CLI formatting.constants.py: Centralised configuration for file paths, date formats, and UI styling.
While the current version is a robust CLI tool, the following architectural enhancements are planned to improve scalability and performance:
- Current State: Data is stored in comma-separated
.txtfiles. - The Goal: Transition to a Relational Database Management System (RDBMS) using SQLite.
- Why:
- Data Integrity: Enforce strict relationships between Users and Tasks using Foreign Keys.
- Concurrency: Better handling of simultaneous read/write operations.
- Performance: Replace O(n) file parsing with indexed SQL queries for faster data retrieval as the task count grows.
- Current State: Passwords are stored in plain text.
- The Goal: Implement the
hashliborbcryptlibrary to store salted SHA-256 hashes. - Why: To ensure industry-standard security practices and protect user credentials in the event of a data breach.
- The Goal: Implement a comprehensive test suite using
pytest. - Why: To ensure that new features or refactors (like the SQLite transition) do not introduce regressions into the core business logic.
Prerequisites: Python 3.x installed on your machine.
-
Clone this repository:
git clone https://github.com/WaleedMatheson/task_manager.git
-
Navigate to the project directory:
cd task_manager -
Run the program:
python src/main.py
Note: The program requires a data/user.txt file with at least one admin user to function. It will automatically generate data/tasks.txt upon first run if missing.
- Language: Python 3
- Libraries:
pathlib,datetime,getpass,textwrap,sys - Code Quality: Ruff (Linter)