Priority: Medium
Level of Effort: Large (5-8 days)
Summary
Add expense tracking capability following the same pattern as calorie and workout tracking. Users can log expenses with categories, amounts, and notes; the agent can provide summaries and spending insights.
Scope
- New module:
src/blacki/expenses/
- Storage:
PostgresExpenseStorage (table: expenses, extends PostgresStorage base)
- Data model:
amount (Decimal, required — supports precision for currency)
category (str, required — e.g., "food", "transport", "entertainment", "utilities", "shopping")
description (str, optional)
currency (str, default "INR", configurable)
spent_at (datetime UTC, auto-set to current time if not provided)
spent_date (date local, for daily aggregation)
- Tools:
log_expense — record an expense with amount, category, and optional description
get_expense_summary — daily summary or multi-day range with category breakdown and total
edit_expense — update an existing expense entry
delete_expense — remove an expense entry
set_expense_budget — set a daily/weekly/monthly budget goal (stored in preferences)
list_expenses — list recent expenses with optional date range and category filter
get_spending_insights — compare spending to budget, highlight top categories, identify trends
- Preferences: Budget goal stored in
PostgresPreferencesStorage under keys like expense_budget_monthly, expense_budget_weekly
- Date support: Use existing
dateparser integration from src/blacki/utils/dates.py for natural language dates
- Pattern: Follow existing storage + tools patterns from
calories/ and workouts/
Sources
- Calorie storage:
src/blacki/calories/storage.py (model pattern)
- Calorie tools:
src/blacki/calories/tools.py (tool pattern, summary aggregation)
- Workout storage:
src/blacki/workouts/storage.py
- Storage base class:
src/blacki/storage/base.py
- Preferences storage:
src/blacki/utils/preferences.py
- Date utilities:
src/blacki/utils/dates.py
- Tool registry:
src/blacki/registry.py
- DI container:
src/blacki/container.py
- Agent prompt:
src/blacki/prompt.py
- AGENTS.md tool design principles
Passing Criteria
Priority: Medium
Level of Effort: Large (5-8 days)
Summary
Add expense tracking capability following the same pattern as calorie and workout tracking. Users can log expenses with categories, amounts, and notes; the agent can provide summaries and spending insights.
Scope
src/blacki/expenses/PostgresExpenseStorage(table:expenses, extendsPostgresStoragebase)amount(Decimal, required — supports precision for currency)category(str, required — e.g., "food", "transport", "entertainment", "utilities", "shopping")description(str, optional)currency(str, default "INR", configurable)spent_at(datetime UTC, auto-set to current time if not provided)spent_date(date local, for daily aggregation)log_expense— record an expense with amount, category, and optional descriptionget_expense_summary— daily summary or multi-day range with category breakdown and totaledit_expense— update an existing expense entrydelete_expense— remove an expense entryset_expense_budget— set a daily/weekly/monthly budget goal (stored in preferences)list_expenses— list recent expenses with optional date range and category filterget_spending_insights— compare spending to budget, highlight top categories, identify trendsPostgresPreferencesStorageunder keys likeexpense_budget_monthly,expense_budget_weeklydateparserintegration fromsrc/blacki/utils/dates.pyfor natural language datescalories/andworkouts/Sources
src/blacki/calories/storage.py(model pattern)src/blacki/calories/tools.py(tool pattern, summary aggregation)src/blacki/workouts/storage.pysrc/blacki/storage/base.pysrc/blacki/utils/preferences.pysrc/blacki/utils/dates.pysrc/blacki/registry.pysrc/blacki/container.pysrc/blacki/prompt.pyPassing Criteria
uv run ruff checkpasses with no errorsuv run ruff formatpasses with no changes neededuv run mypy .passes with no errorsuv run pytest tests/expenses/ --cov=src/blacki/expensespasses with 100% coverage on expenses moduleuv run pytestfull suite passeslog_expensecorrectly stores expense entry scoped to user_id with all fieldsget_expense_summaryreturns correct daily totals and category breakdownsget_expense_summarysupports multi-day ranges with aggregationedit_expenseupdates fields correctly and returns updated recorddelete_expenseremoves the record and returns confirmationset_expense_budgetpersists budget preference and returns confirmationget_spending_insightscompares spending to budget and highlights top categorieslist_expensessupports filtering by date range and categoryAppContainerandregistry.pydateparserintegration