Skip to content

feat(digest): implement weekly financial digest (#121)#642

Open
DeekRoumy wants to merge 1 commit intorohitdash08:mainfrom
DeekRoumy:feat/weekly-digest-121
Open

feat(digest): implement weekly financial digest (#121)#642
DeekRoumy wants to merge 1 commit intorohitdash08:mainfrom
DeekRoumy:feat/weekly-digest-121

Conversation

@DeekRoumy
Copy link

Summary

Closes #121

Implements a complete weekly financial digest feature that generates summaries highlighting trends and actionable insights for any given week.

What's included

Backend

  • New service: packages/backend/app/services/digest.py
    • _heuristic_digest(): rule-based weekly summary (no API key needed)
    • _gemini_digest(): AI-enhanced insights via Gemini (optional)
    • weekly_digest(): public API with graceful fallback if Gemini fails
  • New route: GET /insights/weekly-digest
    • Optional ?week=YYYY-MM-DD (any day in the week; defaults to current week)
    • X-Gemini-Api-Key / X-Insight-Persona headers respected
    • Returns: week_start, week_end, total_expenses, total_income, net_flow, week_over_week_change_pct, previous_week_expenses, top_categories, daily_breakdown, insights, method
  • OpenAPI: fully documented with schema, parameters and examples
  • Tests: 6 test cases covering normal flow, week param, invalid param, net flow, Gemini path, and Gemini fallback

Frontend

  • New page: app/src/pages/WeeklyDigest.tsx
    • Summary cards: total expenses (with WoW % change), income, net flow, previous week
    • Top spending categories
    • Day-by-day spending breakdown
    • Insights panel (rule-based or Gemini AI)
    • Week date picker + optional Gemini API key field
  • New API type: WeeklyDigest + getWeeklyDigest() in api/insights.ts
  • Route: /weekly-digest (protected)
  • Navbar: 'Weekly Digest' link

Acceptance Criteria

  • ✅ Production-ready implementation with full error handling and graceful fallbacks
  • ✅ Tests included (6 backend test cases)
  • ✅ Documentation updated (OpenAPI spec + inline docstrings)

/claim #121

Add a weekly financial digest feature that generates summaries
highlighting trends and insights for any given week.

Backend changes:
- New service: packages/backend/app/services/digest.py
  - _heuristic_digest: rules-based weekly summary (no API key required)
  - _gemini_digest: AI-enhanced insights using Gemini API
  - weekly_digest(): public API with graceful fallback
- New route: GET /insights/weekly-digest
  - Optional ?week=YYYY-MM-DD query param (defaults to current week)
  - X-Gemini-Api-Key / X-Insight-Persona headers supported
  - Returns: week_start, week_end, total_expenses, total_income,
    net_flow, wow_change_pct, top_categories, daily_breakdown, insights
- OpenAPI: fully documented new endpoint with schema and examples
- Tests: packages/backend/tests/test_digest.py (6 test cases)

Frontend changes:
- New page: app/src/pages/WeeklyDigest.tsx
  - Summary cards: expenses, income, net flow, previous week
  - Top spending categories table
  - Day-by-day breakdown list
  - Insights panel (AI-powered or heuristic)
  - Week picker + optional Gemini API key input
- New API type: WeeklyDigest + getWeeklyDigest() in api/insights.ts
- New route: /weekly-digest (protected)
- Navbar: 'Weekly Digest' link added

Acceptance criteria:
✅ Production-ready implementation with error handling + fallbacks
✅ Tests included (6 backend test cases)
✅ Documentation updated (OpenAPI spec + inline docstrings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smart digest with weekly financial summary

1 participant