mirror of
https://github.com/we-promise/sure.git
synced 2026-05-07 12:54:04 +00:00
Shifts the AI assistant from reactive (users ask questions) to proactive (the system surfaces personalized insights automatically). A nightly job analyzes every family's financial data across 7 insight types, writes natural-language explanations via Claude, and surfaces them in a feed on the dashboard and a standalone /insights page. Feature is behind a flag: off by default, enable with INSIGHTS_ENABLED=1 (or via Setting.insights_enabled in the admin UI). Insight types: - spending_anomaly: category spend >25% above/below 3-month rolling average - cash_flow_warning: projected cash balance drops below $500 in 30 days (uses RecurringTransaction + statistical daily baseline) - net_worth_milestone: crossed a round-number milestone or all-time high - subscription_audit: recurring transaction overdue by 45+ days - savings_rate_change: savings rate changed >5 percentage points vs last month - idle_cash: $5k+ sitting in depository account with no activity in 60 days - budget_at_risk / budget_on_track: spending pace vs monthly budget Architecture: - Insight model with dedup_key unique index (upsert, not re-create daily) - Insight::Generator base class + Insight::GeneratorRegistry orchestrator - LLM used as a writer only — financial math runs in pure Ruby - GenerateInsightsJob runs at 6 AM UTC daily via sidekiq-cron - InsightsController with read/dismiss Turbo Stream actions - Dashboard section gated by Current.user.insights_enabled? https://claude.ai/code/session_014vY9xohpm3abSAxVxRF27a
51 lines
1.7 KiB
YAML
51 lines
1.7 KiB
YAML
import_market_data:
|
|
cron: "0 22 * * 1-5" # 5:00 PM EST / 6:00 PM EDT (NY time) Monday through Friday
|
|
class: "ImportMarketDataJob"
|
|
queue: "scheduled"
|
|
description: "Imports market data daily at 5:00 PM EST (1 hour after market close)"
|
|
args:
|
|
mode: "full"
|
|
clear_cache: false
|
|
|
|
clean_syncs:
|
|
cron: "0 * * * *" # every hour
|
|
class: "SyncCleanerJob"
|
|
queue: "scheduled"
|
|
description: "Cleans up stale syncs"
|
|
|
|
run_security_health_checks:
|
|
cron: "0 2 * * 1-5" # 2:00 AM EST / 3:00 AM EDT (NY time) Monday through Friday
|
|
class: "SecurityHealthCheckJob"
|
|
queue: "scheduled"
|
|
description: "Runs security health checks to detect issues with security data"
|
|
|
|
sync_hourly:
|
|
cron: "0 * * * *" # every hour at the top of the hour
|
|
class: "SyncHourlyJob"
|
|
queue: "scheduled"
|
|
description: "Syncs provider items that opt-in to hourly syncing"
|
|
|
|
clean_data:
|
|
cron: "0 3 * * *" # daily at 3:00 AM
|
|
class: "DataCleanerJob"
|
|
queue: "scheduled"
|
|
description: "Cleans up old data (e.g., expired merchant associations, expired archived exports)"
|
|
|
|
clean_inactive_families:
|
|
cron: "0 4 * * *" # daily at 4:00 AM
|
|
class: "InactiveFamilyCleanerJob"
|
|
queue: "scheduled"
|
|
description: "Archives and destroys families that expired their trial without subscribing (managed mode only)"
|
|
|
|
refresh_demo_family:
|
|
cron: "0 5 * * *" # daily at 5:00 AM UTC
|
|
class: "DemoFamilyRefreshJob"
|
|
queue: "scheduled"
|
|
description: "Refreshes demo family data and emails super admins with daily usage summary"
|
|
|
|
generate_insights:
|
|
cron: "0 6 * * *" # daily at 6:00 AM UTC — after data syncs and nightly cleanup jobs
|
|
class: "GenerateInsightsJob"
|
|
queue: "scheduled"
|
|
description: "Generates proactive financial insights for all families"
|