Skip to content

feat: Add weekly financial digest with smart insights#253

Open
DebuggingMax wants to merge 1 commit intorohitdash08:mainfrom
DebuggingMax:feature/weekly-digest
Open

feat: Add weekly financial digest with smart insights#253
DebuggingMax wants to merge 1 commit intorohitdash08:mainfrom
DebuggingMax:feature/weekly-digest

Conversation

@DebuggingMax
Copy link

Summary

This PR implements issue #121: Smart digest with weekly financial summary.

Features Added

New Endpoints

  • GET /digest/weekly - Comprehensive weekly financial digest
  • GET /digest/weekly/summary - Condensed summary for dashboard widgets

Weekly Digest Contents

  • Period Info: Week start/end dates, ISO week number, year
  • Summary: Total income, expenses, net flow, transaction count
  • Trends: Week-over-week comparison (expense/income change %)
  • Category Breakdown: Spending by category with percentages and transaction counts
  • Daily Breakdown: Day-by-day spending pattern (Monday through Sunday)
  • Upcoming Bills: Bills due within the week with totals
  • Top Transactions: Largest expenses for quick review
  • AI Insights: Smart tips generated via Gemini API (graceful fallback to heuristics)

Technical Implementation

  • packages/backend/app/services/digest.py - Core digest generation logic
  • packages/backend/app/routes/digest.py - API endpoints with validation and caching
  • packages/backend/tests/test_digest.py - 11 comprehensive tests
  • Updated OpenAPI spec with new endpoints and schemas
  • Updated README with feature documentation

Caching

  • Results cached for 5 minutes to reduce database load
  • Cache keys include user ID and week start date

Testing

  • Added 11 test cases covering:
    • Complete response structure validation
    • Transactions and category breakdowns
    • Week parameter handling and validation
    • Week-over-week trend calculations
    • Bills integration
    • Daily breakdown structure
    • Insights generation (heuristic mode)
    • Empty week handling

Acceptance Criteria Met

  • ✅ Production ready implementation
  • ✅ Includes tests (11 test cases)
  • ✅ Documentation updated (README + OpenAPI)

Closes #121

Implements a comprehensive weekly financial summary digest feature with:

- GET /digest/weekly - Full weekly digest with all data
- GET /digest/weekly/summary - Condensed summary for widgets

Features:
- Week period info (start, end, week number)
- Summary: income, expenses, net flow, transaction count
- Week-over-week trends with percentage changes
- Category breakdown with percentages and counts
- Daily breakdown (Mon-Sun) for spending patterns
- Upcoming bills due within the week
- Top transactions for quick review
- AI-powered insights via Gemini (falls back to heuristics)
- Caching for performance (5 min TTL)

Files added:
- packages/backend/app/services/digest.py - Core digest logic
- packages/backend/app/routes/digest.py - API endpoints
- packages/backend/tests/test_digest.py - Comprehensive tests

Updated:
- OpenAPI spec with new endpoints and schemas
- README with feature documentation
- Routes __init__.py to register blueprint

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