Skip to content

feat: Smart weekly financial digest with trends & insights (bounty #121)#939

Open
alexanderxfgl-bit wants to merge 1 commit intorohitdash08:mainfrom
alexanderxfgl-bit:bounty/121-digest
Open

feat: Smart weekly financial digest with trends & insights (bounty #121)#939
alexanderxfgl-bit wants to merge 1 commit intorohitdash08:mainfrom
alexanderxfgl-bit:bounty/121-digest

Conversation

@alexanderxfgl-bit
Copy link
Copy Markdown

Bounty Claim: $500 — Issue #121

Implementation

Production-ready smart digest system with weekly/monthly financial summaries, trend detection, and auto-generated insights.

Backend Changes

Model (app/models.py):

  • WeeklyDigest: user_id, period_start, period_end, period_type, total_spent, category_breakdown (JSON), trends (JSON), insights (JSON), generated_at

Service (app/services/digest.py):

  • generate_digest() — aggregate expenses by category for current/previous period
  • _category_breakdown() — convert query results to {category: total} dict
  • _detect_trends() — compare current vs previous, flag >15% changes as significant
  • _generate_insights() — produce human-readable insights: top category, spending spikes, overall change
  • _period_bounds() — compute week/month date ranges (Monday-based weeks, 1st-based months)
  • Upsert logic — updates existing digest or creates new one
  • get_digest_history() — paginated historical digest listing with period filter

Routes (app/routes/digest.py):

  • GET /digest?period=weekly|monthly — generate/retrieve current period digest
  • GET /digest/history?limit=10&period=weekly — list historical digests
  • POST /digest/generate — force generate for specific period/date

Schema (app/db/schema.sql):

  • weekly_digests table with JSONB columns for breakdown/trends/insights
  • Unique index on (user_id, period_start, period_end) for upsert

Tests

11 tests covering:

  • Weekly and monthly digest generation
  • Invalid period parameter validation
  • Digest with actual expenses (category breakdown)
  • History endpoint with limit and period filters
  • Force generation with reference date
  • Invalid date/period validation
  • Trend detection for spending changes

Closes #121

Implements a production-ready smart digest system that generates
weekly/monthly financial summaries with trend analysis and insights.

- WeeklyDigest model with category breakdowns, trends, and insights (JSON)
- DigestService: period aggregation, trend detection (>15% = significant),
  auto-generated human-readable insights, upsert logic for digest records
- REST API: GET /digest, GET /digest/history, POST /digest/generate
- PostgreSQL schema with unique index on user+period
- 11 tests covering CRUD, validation, trend detection, force generation

Closes rohitdash08#121
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.

Smart digest with weekly financial summary

1 participant