Skip to content

feat: Multi-account financial overview dashboard#862

Open
inventelpk-cell wants to merge 1 commit intorohitdash08:mainfrom
inventelpk-cell:feat/multi-account-dashboard
Open

feat: Multi-account financial overview dashboard#862
inventelpk-cell wants to merge 1 commit intorohitdash08:mainfrom
inventelpk-cell:feat/multi-account-dashboard

Conversation

@inventelpk-cell
Copy link
Copy Markdown

@inventelpk-cell inventelpk-cell commented Apr 13, 2026

Summary

Adds multi-account support to FinMind, allowing users to manage multiple financial accounts (checking, savings, credit, investment) and view aggregated financial data across all accounts in a unified dashboard.

Closes #132

Changes

New Account Model

  • Account model with fields: id, user_id, name, account_type (CHECKING/SAVINGS/CREDIT/INVESTMENT), balance, currency, is_default, is_active (soft delete), created_at, updated_at
  • AccountType enum for type safety
  • Nullable account_id FK added to Expense model for backward compatibility

API Endpoints

  • POST /accounts — Create account (first account auto-defaults)
  • GET /accounts — List user's active accounts (cached, 5min TTL)
  • GET /accounts/<id> — Account detail
  • PATCH /accounts/<id> — Update account fields
  • DELETE /accounts/<id> — Soft delete with automatic default promotion
  • GET /accounts/<id>/summary?month=YYYY-MM — Per-account expense summary with category breakdown
  • GET /dashboard/overview?month=YYYY-MM — Aggregated view across all accounts (total balance, per-account income/expenses/net flow)
  • GET /dashboard/summary?account_id=N — Existing dashboard now supports optional account filtering
  • GET /expenses?account_id=N — Existing expense list now supports account filtering

Database

  • Idempotent migration: packages/backend/app/db/migrations/001_add_accounts.sql
  • Schema compatibility patch in __init__.py for existing deployments
  • Updated schema.sql with accounts table and expense FK

Caching & Invalidation

  • New Redis cache keys: user:{id}:accounts, user:{id}:account_summary:{acct}:{ym}, user:{id}:dashboard_overview:{ym}
  • Account mutations invalidate all related caches including dashboard summaries

Tests

  • 8 pytest tests covering: full CRUD lifecycle, input validation, default account logic, per-account summaries, dashboard overview aggregation, dashboard filtering, expense filtering, 404 handling

Backward Compatibility

  • account_id on expenses is nullable — existing expenses without accounts continue to work
  • Existing /dashboard/summary endpoint behavior is unchanged when account_id param is omitted
  • Migration is idempotent (IF NOT EXISTS / IF NOT EXISTS)

Test Plan

  • Run pytest tests/test_accounts.py — 8 new tests
  • Run pytest tests/ — all 30 tests pass (existing tests unaffected)
  • Verify accounts CRUD via API manually
  • Verify /dashboard/overview aggregates correctly across accounts
  • Verify /dashboard/summary?account_id=N filters correctly
  • Verify soft delete promotes next account to default

- Add Account model (checking/savings/credit/investment types)
- Add account_id FK to Expense model (nullable for backward compat)
- Add accounts CRUD endpoints with soft delete and default promotion
- Add per-account expense summary endpoint
- Add dashboard overview endpoint aggregating all accounts
- Add account_id filter to existing dashboard summary and expenses list
- Add Redis cache keys and invalidation for account-related data
- Add idempotent SQL migration for accounts table
- Add schema compatibility patch for existing deployments
- Add 8 pytest tests covering accounts CRUD, validation, summaries
- Update README with accounts API documentation

Closes rohitdash08#132
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-account financial overview dashboard

2 participants