Skip to content

Split PPP savings service into adapter, calculator, and email template boundaries #240

Description

@brycejohnson1417

Why this exists

ppp-savings-service.ts remains a large mixed-responsibility service at roughly 1,100 lines. It combines external data access, local runtime lookup, pricing math, discount logic, and email HTML generation.

Intended outcome

Separate stable boundaries without changing calculated outputs or generated email content.

Scope

  • Extract external data access into a dedicated adapter boundary.
  • Extract email HTML generation into a focused template module.
  • Keep pricing/discount calculations covered by deterministic tests before moving them.
  • Preserve existing API response shape and UI behavior.

Non-goals

  • No Nabis writes or live provider mutations.
  • No pricing rule changes.
  • No schema, auth/RLS, credential, or secret changes.

Acceptance criteria

  • Deterministic tests prove existing pricing and email output behavior is preserved.
  • Existing verification passes.
  • Boundaries make it possible to test pricing math without external provider calls.
  • Any live-provider validation remains read-only and explicitly documented.

Source

Created from #32 refactor triage of closed PR #1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:mediumUseful but not urgenttype:taskBounded maintenance docs CI or operational work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions