Skip to content

Add Path to Freedom — dividend-income projection feature#179

Merged
fleveque merged 1 commit into
mainfrom
feat/path-to-freedom
May 26, 2026
Merged

Add Path to Freedom — dividend-income projection feature#179
fleveque merged 1 commit into
mainfrom
feat/path-to-freedom

Conversation

@fleveque

Copy link
Copy Markdown
Owner

Summary

  • Motivational calculator that takes the user's current portfolio, monthly contribution, dividend goal and estimated inflation and projects year-by-year until passive income covers the objective. Inputs are real (today's money); both the goal and contributions inflate during the projection so the ETA is honest.
  • Three discovery surfaces: dedicated /freedom page (auth) + /demo/freedom, a PathToFreedomMini widget on the logged-in dashboard, and a PathToFreedomShowcase banner on the anon homepage. New /demo lands on a logged-in-style DemoDashboardHome so anonymous visitors see the feature in context.
  • Server-side caching: MotivationProjectionService precomputes the summary per user and stores it via Rails.cache (6h TTL, invalidated on motivation input / preferred currency / Holding changes), so the dashboard mini never re-runs the math on visit.

What's in the page

  • Inputs card: monthly contribution, monthly dividend goal, inflation, optional yield override, year-started-investing (auto-suggested from earliest dividend if available); debounced PATCH-on-edit
  • Starting Point hero card: portfolio value, yield used, current monthly dividend
  • Insight stat cards: time to goal, portfolio at goal (nominal + today's money), total yield earned
  • Progress bar: current monthly dividends vs goal (today's money)
  • Growth chart: cumulative contributions vs total portfolio. Past portion uses an annuity model (c = portfolioValue · y / ((1+y)^N − 1)) so portfolio > contributions whenever yield > 0, and both lines meet at $0 at the user's start year.
  • Dividend income chart: monthly dividend trajectory vs the inflating monthly goal; their crossing is the "freedom moment"
  • Collapsible per-year table for the curious

Backend

  • Migration: motivation_monthly_invest, motivation_monthly_objective, motivation_inflation_pct, motivation_yield_override_pct, motivation_start_year columns on users
  • PortfolioStatsService now also returns displayMarketValue (needed for the projection's starting value in preferred currency)
  • ProfilesController accepts/serves the new fields + a precomputed motivationSummary
  • TS twin (app/frontend/lib/motivation.ts) for live in-page interactivity

Test plan

  • bundle exec rspec — 706 examples pass (existing + new model/controller/service specs)
  • npx tsc --noEmit clean
  • npx vite build clean
  • bin/rubocop and bin/brakeman clean
  • Manual: sign in, visit /freedom, fill inputs, observe live chart updates
  • Manual: reload — values persist via profile API
  • Manual: visit /PathToFreedomMini shows progress bar + ETA without recomputing
  • Manual: log out, visit /PathToFreedomShowcase card renders with working signup CTA
  • Manual: visit /demo — anonymous tour lands on the dashboard with a curated motivationSummary
  • Manual: switch to Spanish — all new strings localised, no ambiguous abbreviations

🤖 Generated with Claude Code

Motivational calculator that turns the user's current portfolio, monthly
contribution, dividend goal and estimated inflation into a year-by-year
projection until passive income covers the objective. Inputs are real
(today's money); both contributions and the goal inflate during the
simulation so the ETA is honest.

Backend:
- Migration adds motivation_* columns on users (monthly invest, objective,
  inflation, optional yield override, start year)
- MotivationProjectionService: pure projection math + Rails.cache wrapper
  (6h TTL, invalidated on motivation_*, preferred_currency, or Holding
  changes) so the dashboard mini doesn't run the math per visit
- PortfolioStatsService now also returns displayMarketValue
- ProfilesController accepts/serves the new inputs and a precomputed summary

Frontend:
- /freedom page (auth + /demo/freedom): inputs card with auto-suggested
  start year from earliest dividend, four insight stat cards, progress
  bar, two stacked charts (portfolio growth + dividend income vs the
  inflating goal), and a per-year breakdown table
- Past portion uses an annuity model so portfolio > contributions whenever
  yield > 0, and both lines meet at $0 at the user's start year
- PathToFreedomMini on the logged-in dashboard, reading the cached summary
- PathToFreedomShowcase on the anon homepage; Top-Scored moved below the
  showcase banners so all pitches come before live community data
- DemoDashboardHome at /demo — logged-in-style tour with a curated profile
  (motivationSummary included in the demo bundle)
- Bilingual (en + es); Spanish ETA renders full words to avoid ambiguity

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fleveque fleveque merged commit bae07e7 into main May 26, 2026
5 checks passed
@fleveque fleveque deleted the feat/path-to-freedom branch May 26, 2026 17:11
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