HKU COMP1110 Project - Group F01
Managing personal finances is a common challenge, especially for students and young adults whose spending is spread across categories such as meals, transportation, and subscriptions. Without a systematic way to record and review expenses, it becomes difficult to understand spending behavior and control overspending.
To address this, our project develops a lightweight, text-based Personal Budget and Spending Assistant. The tool helps users record transactions, view spending summaries, and receive rule-based alerts when they approach or exceed predefined budgets.
- Design a clear data model for transactions (date, amount, category, description) and budget rules.
- Implement file I/O using CSV and JSON to store and load data.
- Provide a text menu interface for adding/viewing/filtering transactions, generating summaries, configuring budgets, and reloading data.
- Compute summary statistics (totals by category/period, top categories, simple trends).
- Implement 4-5 rule-based alerts (for example, daily category caps and percentage thresholds).
- Include a test data generator and create 3-4 realistic case studies to demonstrate and evaluate the system.
- Validate user inputs and handle common file errors gracefully.
- Python 3.9+: simple syntax, rich standard library, and suitable for text-based interfaces and file processing.
- CSV for transactions: human-readable, easy to generate and edit.
- JSON for budget rules: supports nested structures and future extensions.
| Entity | Fields |
|---|---|
| Transaction | date (YYYY-MM-DD), amount (float), category (str), description (str), notes (optional) |
| BudgetRule | category (str), period (day/week/month), threshold (float), alert_type (over_threshold/over_ratio) |
A predefined category list is provided (Catering, Transport, Shopping, Entertainment, Housing, Medical, Education, Others), with custom categories loaded from data/category_config.json.
- Validate date format, amount sign, and category existence with immediate re-prompts during input.
- Gracefully handle missing files, malformed headers/rows, malformed JSON, and empty inputs with clear error messages.
- Keep compatibility mapping only inside I/O and validator internals (legacy values map to unified values).
models.py: data classes and category manager.io.py: file read/write and validation.stats.py: summaries and trends.alert.py: rule-based alerts.menu.py: text interface (including transaction filtering, data reload, and auto-alert display in report views).test_data_generator.py: realistic and edge-case test data generation.case_runner.py: reproducible case-study runner.
- Install Python 3.9+.
- Use one virtual environment (
.venv) for this project.
- Create (first time):
python -m venv .venv - Activate in PowerShell:
.\.venv\Scripts\Activate.ps1
- This version uses only Python standard library (no third-party package required).
- Run the CLI application:
python -m src.menu
- Run automated tests:
python -m unittest discover -s test -p "*.py"
- Generate random test transactions:
python -m src.test_data_generator
- Reproduce one case study:
python -m src.case_runner 1
Current menu highlights:
- View/filter transactions (all, by category, by date range).
- Reload transactions and budget rules from files.
- Immediate budget alert check after adding a transaction.
- Consecutive overspend threshold can be configured per daily threshold rule.
- Manual entry vs bank synchronization:
- Chosen: manual entry. Reason: no external API dependency and easier implementation/testing.
- Fixed baseline categories vs unrestricted free-form categories:
- Chosen: fixed baseline with optional extension. Reason: improves validation quality and summary consistency.
- CSV/JSON files vs database backend:
- Chosen: CSV/JSON. Reason: transparent for teaching context and simple for inspection/debugging.
- Rule-based thresholds vs predictive forecasting:
- Chosen: threshold and ratio rules. Reason: deterministic behavior and explainable results for case studies.
- Legacy value compatibility vs strict canonical schema only:
- Chosen: compatibility mapping (
meals,daily,exceed, etc.) into canonical values. Reason: robust against mixed datasets.
- Dynamic "today" anchor vs deterministic data-driven anchor:
- Chosen: deterministic anchor (
start_datefrom rule, otherwise earliest transaction date). Reason: reproducible alerts across runs.
All four case studies include scenario, input files, expected outputs, limitations, and comparison notes:
case_studies/case_1_daily_food_cap.mdcase_studies/case_2_monthly_transport_tracking.mdcase_studies/case_3_subscription_creep.mdcase_studies/case_4_one_off_purchase_spike.md
Input datasets are stored in data/case_studies/ and validated by test/test_case_studies.py.
- Unit tests for core functions (validation, statistics, alerts).
- Integration tests use four predefined case studies with assertion-based expected outputs.
- Edge cases (empty files, missing categories, large amounts) to verify robustness.
- Unified transaction CSV header order is fixed: date, amount, category, description, notes.
- Unified budget rule JSON fields are fixed: category, period, threshold, alert_type.
- Standard initial categories are fixed to 8 items: Catering, Transport, Shopping, Entertainment, Housing, Medical, Education, Others.
- Legacy mappings (meals/transport/shopping, daily/weekly/monthly, exceed/percentage) must be normalized before business logic.
- Module interface contracts should remain stable across roles to reduce integration risk.
- Core responsibilities: project coordination, integration, quality control.
- Key tasks (ordered):
- Run kickoff meeting.
- Maintain Gantt and risk log.
- Managed GitHub PR reviews, conflict resolution, and branch health.
- Oversaw integration testing and resolved development bottlenecks.
- Enforce cross-role interface freeze and technical standard compliance checks.
- Defined scope, milestones and conducted team syncs
- Deliverables: kickoff minutes, Gantt, merged PRs.
- Acceptance criteria: all milestones tracked, PRs reviewed within 48h, technical standards aligned.
- Core responsibilities: define data schemas and interfaces for other modules.
- Key tasks (ordered):
- Produce Transaction/BudgetRule specification.
- Provide sample objects.
- Publish interface document.
- Update on schema changes.
- Ensure BudgetRule fields use period and threshold as canonical names.
- Deliverables: schema document, example CSV/JSON headers, interface README.
- Acceptance criteria: other roles can parse sample files, validation tests pass on schema, and canonical field names are preserved.
- Core responsibilities: file formats, load/save, input validation, error handling.
- Key tasks (ordered):
- Define file formats.
- Implement load/save functions.
- Implement
validate_transactionandvalidate_rule. - Provide sample files.
- Normalize legacy values to unified enums in load functions.
- Deliverables:
load_transactions,save_transactions, validation module, sample files. - Acceptance criteria: functions handle missing/malformed files gracefully, include unit tests for edge cases, and return unified-format dictionaries.
- Core responsibilities: CLI menu, user flows, integration with modules.
- Key tasks (ordered):
- Create CLI skeleton.
- Implement add/view flows.
- Hook to I/O and stats modules.
- Provide usage examples.
- Follow input flow: assemble dict -> validate -> save.
- Deliverables: CLI script, usage README, example session logs.
- Acceptance criteria: menu supports add/view/summaries, handles invalid inputs with clear messages, and does not break module boundaries.
- Core responsibilities: summary computations, trend analysis, alert rules.
- Key tasks (ordered):
- Implement totals and per-period summaries.
- Implement Top N categories.
- Implement trend generator.
- Implement 4 alert rules.
- Compile final report.
- Ensure weekly summary uses
isocalendar()and alert enums use unified names.
- Deliverables: stats module,
check_budget_alerts, final report draft. - Acceptance criteria: outputs match expected values on test datasets, alerts trigger per rules, and over_ratio default threshold behavior is validated, final report assembled on time.
- Core responsibilities: design scenarios, generate test data, run end-to-end tests, demo script.
- Key tasks (ordered):
- Design 3-4 case studies.
- Generate transaction files.
- Run integrated tests.
- Draft demo script and record checklist.
- Provide both unified-format and legacy-format compatibility test data.
- Deliverables: case input files, test reports, demo script.
- Acceptance criteria: case runs reproduce expected summaries/alerts, demo script maps to test data, and compatibility tests are reproducible.
| Task / Milestone | W0 Mar 23 | W1 Mar 24-30 | W2 Mar 31-Apr 6 | W3 Apr 7-13 | W4 Apr 14-20 | W5 Apr 21-27 | W6 Apr 28-May 2 |
|---|---|---|---|---|---|---|---|
| Finalize Project Plan (Role 1 lead) | X | ||||||
| Role 2 publishes schema draft | X | ||||||
| Role 3 confirms file formats | X | ||||||
| Data model implementation (Role 2) | X | X | |||||
| File I/O basic functions load/save (Role 3) | X | X | |||||
| CLI skeleton (Role 4) | X | ||||||
| Statistics core totals, Top N (Role 5) | X | ||||||
| Validation integrated into I/O (Role 3) | X | X | |||||
| Technical standard lock: unified fields and enums across all modules | X | X | |||||
| Unit tests start (Role 5/3) | X | ||||||
| Module integration: CLI + I/O + stats (All) | X | X | |||||
| Interface contract review checkpoint (Role 1 + Role 2 + Role 3 + Role 4 + Role 5) | X | ||||||
| First end-to-end tests + bug log (Role 6) | X | ||||||
| Case study execution (3-4 scenarios, Role 6) | X | X | |||||
| Compatibility regression tests (legacy mapping + unified format) | X | ||||||
| Bug fixes and feature polish (All) | X | ||||||
| Demo recording and report drafting (Role 6 lead; Role 1 compiles) | X | X | |||||
| Finalize unit and integration tests | X | X | |||||
| Final polishing and submission (GitHub cleanup, final report PDF, individual reports, Moodle upload) | X |