Skip to content

Feat/weekly financial digest#383

Open
robotica4us-collab wants to merge 2 commits intorohitdash08:mainfrom
robotica4us-collab:feat/weekly-financial-digest
Open

Feat/weekly financial digest#383
robotica4us-collab wants to merge 2 commits intorohitdash08:mainfrom
robotica4us-collab:feat/weekly-financial-digest

Conversation

@robotica4us-collab
Copy link

Summary

  • What changed:
  • Why:

Validation

  • Frontend lint: cd app && npm run lint
  • Frontend tests: cd app && npm test -- --runInBand
  • Backend tests: ./scripts/test-backend.ps1
  • Updated docs if needed

Security and Ownership

  • PR opened from a fork (not direct push to main)
  • CODEOWNERS review requested

Checklist

  • No secrets added
  • No unrelated files changed
  • Breaking changes documented

Implements a production-ready background job system that wraps APScheduler
with automatic retry, dead-letter tracking, and full observability.

Features:
- Configurable exponential backoff retry (per-job RetryPolicy)
- Dead-letter queue for permanently failed jobs with admin reset
- Per-job execution history with timing and error details
- Prometheus metrics (executions, retries, dead-letters, duration)
- Redis-backed state persistence for crash recovery
- Admin API endpoints (/jobs/status, /jobs/dead-letters, /jobs/<id>/reset)
- Unauthenticated health check (/jobs/health) for monitoring systems
- Automatic Flask app context injection for job functions

The reminder processing job is wired up as the first managed job,
replacing the manual /reminders/run endpoint with automatic processing.

Includes 17 tests covering:
- RetryPolicy exponential backoff and delay capping
- JobState history capping
- Job registration and status reporting
- Dead-letter detection and reset
- Flask integration (health endpoint, admin auth)
- Successful execution resets attempts
- Failing jobs retry then dead-letter
- Transient failures recover on retry
- Redis persistence and crash recovery

Closes rohitdash08#130
Implements weekly financial summaries with spending trends, category
breakdowns, anomaly detection, and actionable insights.

Features:
- Weekly spending summary (expenses, income, net flow, transaction count)
- Week-over-week comparison with percentage change
- Category breakdown with percentages and counts
- Daily spending data for sparkline/chart visualization
- Anomaly detection (spending spikes >30%, drops >20%, large transactions)
- Upcoming bills for next 7 days
- AI-enhanced narrative via Gemini (optional, with heuristic fallback)
- Plain-text email rendering for digest delivery
- Automated weekly delivery (Monday 9:00 AM UTC) via background job manager
- Email preview endpoint for testing

API Endpoints:
- GET /digest/weekly — generate digest (supports week_of param)
- GET /digest/weekly/email-preview — digest + formatted email body

Includes 25 tests covering:
- Week bounds calculation (Monday-Sunday)
- Category breakdown grouping and percentages
- Daily spending aggregation
- Anomaly detection (spikes, drops, large txns, no data)
- Heuristic tip generation
- Email body rendering
- Full integration with DB (empty week, with expenses, WoW change)
- Route integration (both endpoints)

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.

1 participant