# hmrc/mobile-help-to-save architecture

> Architecture diagram of the GitHub repository hmrc/mobile-help-to-save, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hmrc/mobile-help-to-save
- Repository: https://github.com/hmrc/mobile-help-to-save

## Overview

This is a Play microservice providing mobile-app-specific Help to Save endpoints. The main workflow authenticates and checks a user’s NINO and shuttering status, serves account, transaction, savings-goal and milestone operations, and calculates savings updates and milestones using Help to Save data and persisted state. Startup supplies app-facing status and user information; a sandbox provides sample responses, and test-only routes expose data-management operations. The README and excerpts establish key endpoint and service interactions; links to unsampled implementations are omitted or marked unverified.

Main entry points: [`app/uk/gov/hmrc/mobilehelptosave/services/AccountService.scala`](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/AccountService.scala) (Account and goals), [`app/uk/gov/hmrc/mobilehelptosave/controllers/HelpToSaveController.scala`](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/HelpToSaveController.scala) (Help endpoints), [`app/uk/gov/hmrc/mobilehelptosave/services/MilestonesService.scala`](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/MilestonesService.scala) (Milestone services), [`app/uk/gov/hmrc/mobilehelptosave/services/BalanceMilestonesService.scala`](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/BalanceMilestonesService.scala) (Balance milestones)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_helpcontroller["Help endpoints"]
  node_startupcontroller["Startup endpoint"]
  node_milestonecontroller["Milestone endpoints"]
  node_access["NINO and shutter checks"]
  node_checks["Request and error checks"]
  node_sandboxcontroller["Sandbox endpoints"]
  node_sandboxdata["Sample responses<br/>[SandboxData.scala]"]
end

subgraph group_domain["Savings domain"]
  node_user["User state<br/>[UserService.scala]"]
  node_account["Account and goals"]
  node_updates["Savings updates"]
  node_calculator["Bonus calculator"]
  node_milestones["Milestone services"]
  node_balance["Balance milestones"]
  node_bonusperiod["Bonus-period milestones"]
  node_bonusreached["Bonus-reached milestones"]
end

subgraph group_integrations["External services"]
  node_hts{{"Help to Save service"}}
  node_shuttering{{"Shuttering service"}}
end

subgraph group_state["Persistence"]
  node_goalrepo[("Savings-goal events")]
  node_milestonerepo[("Milestone records")]
  node_balance_repo[("Previous balances")]
  node_eligibility_repo[("Eligibility records")]
end

node_mobile(("Mobile app"))

node_mobile -->|"calls endpoints"| node_helpcontroller
node_mobile -->|"requests startup"| node_startupcontroller
node_mobile -.->|"requests milestones"| node_milestonecontroller
node_helpcontroller -->|"authorizes requests"| node_access
node_helpcontroller -->|"delegates account work"| node_account
node_helpcontroller -->|"uses goal events"| node_goalrepo
node_startupcontroller -->|"authorizes requests"| node_access
node_startupcontroller -->|"fetches user state"| node_user
node_milestonecontroller -->|"requests milestones"| node_milestones
node_milestonecontroller -->|"authorizes requests"| node_access
node_sandboxcontroller -->|"checks shutter status"| node_shuttering
node_sandboxcontroller -->|"returns samples"| node_sandboxdata
node_sandboxcontroller -->|"applies shutter checks"| node_checks
node_account -->|"reads and writes"| node_goalrepo
node_account -.->|"fetches account data"| node_hts
node_account -->|"uses savings calculations"| node_updates
node_account -->|"checks milestones"| node_balance
node_account -->|"checks milestones"| node_bonusperiod
node_account -->|"checks milestones"| node_bonusreached
node_updates -->|"calculates bonus"| node_calculator
node_milestones -.->|"uses balance checks"| node_balance
node_milestones -.->|"uses period checks"| node_bonusperiod
node_milestones -.->|"uses bonus checks"| node_bonusreached
node_balance -->|"reads and writes"| node_milestonerepo
node_balance -->|"reads balances"| node_balance_repo
node_bonusperiod -->|"reads and writes"| node_milestonerepo
node_bonusperiod -->|"reads balances"| node_balance_repo

click node_helpcontroller "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/HelpToSaveController.scala"
click node_startupcontroller "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/StartupController.scala"
click node_milestonecontroller "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/MilestonesController.scala"
click node_access "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/AuthorisedWithIds.scala"
click node_checks "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/ControllerChecks.scala"
click node_sandboxcontroller "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/SandboxController.scala"
click node_user "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/UserService.scala"
click node_account "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/AccountService.scala"
click node_updates "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/SavingsUpdateService.scala"
click node_calculator "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/CalculatorService.scala"
click node_milestones "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/MilestonesService.scala"
click node_balance "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/BalanceMilestonesService.scala"
click node_bonusperiod "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/BonusPeriodMilestonesService.scala"
click node_bonusreached "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/BonusReachedMilestonesService.scala"
click node_goalrepo "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/repository/SavingsGoalEventRepo.scala"
click node_milestonerepo "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/repository/MilestonesRepo.scala"
click node_balance_repo "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/repository/PreviousBalanceRepo.scala"
click node_eligibility_repo "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/repository/EligibilityRepo.scala"
click node_sandboxdata "https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/sandbox/SandboxData.scala"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_helpcontroller,node_startupcontroller,node_milestonecontroller,node_access,node_checks,node_sandboxcontroller,node_sandboxdata toneBlue
class node_user,node_account,node_updates,node_calculator,node_milestones,node_balance,node_bonusperiod,node_bonusreached toneAmber
class node_hts,node_shuttering toneMint
class node_goalrepo,node_milestonerepo,node_balance_repo,node_eligibility_repo toneRose
class node_mobile toneIndigo
```

## Components

### API and access

- [Help endpoints](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/HelpToSaveController.scala): `app/uk/gov/hmrc/mobilehelptosave/controllers/HelpToSaveController.scala`
- [Startup endpoint](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/StartupController.scala): `app/uk/gov/hmrc/mobilehelptosave/controllers/StartupController.scala`
- [Milestone endpoints](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/MilestonesController.scala): `app/uk/gov/hmrc/mobilehelptosave/controllers/MilestonesController.scala`
- [NINO and shutter checks](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/AuthorisedWithIds.scala): `app/uk/gov/hmrc/mobilehelptosave/controllers/AuthorisedWithIds.scala`
- [Request and error checks](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/ControllerChecks.scala): `app/uk/gov/hmrc/mobilehelptosave/controllers/ControllerChecks.scala`
- [Sandbox endpoints](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/controllers/SandboxController.scala): `app/uk/gov/hmrc/mobilehelptosave/controllers/SandboxController.scala`
- [Sample responses](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/sandbox/SandboxData.scala): `app/uk/gov/hmrc/mobilehelptosave/sandbox/SandboxData.scala`

### Savings domain

- [User state](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/UserService.scala): `app/uk/gov/hmrc/mobilehelptosave/services/UserService.scala`
- [Account and goals](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/AccountService.scala): `app/uk/gov/hmrc/mobilehelptosave/services/AccountService.scala`
- [Savings updates](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/SavingsUpdateService.scala): `app/uk/gov/hmrc/mobilehelptosave/services/SavingsUpdateService.scala`
- [Bonus calculator](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/CalculatorService.scala): `app/uk/gov/hmrc/mobilehelptosave/services/CalculatorService.scala`
- [Milestone services](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/MilestonesService.scala): `app/uk/gov/hmrc/mobilehelptosave/services/MilestonesService.scala`
- [Balance milestones](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/BalanceMilestonesService.scala): `app/uk/gov/hmrc/mobilehelptosave/services/BalanceMilestonesService.scala`
- [Bonus-period milestones](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/BonusPeriodMilestonesService.scala): `app/uk/gov/hmrc/mobilehelptosave/services/BonusPeriodMilestonesService.scala`
- [Bonus-reached milestones](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/services/BonusReachedMilestonesService.scala): `app/uk/gov/hmrc/mobilehelptosave/services/BonusReachedMilestonesService.scala`

### External services

- **Help to Save service**
- **Shuttering service**

### Persistence

- [Savings-goal events](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/repository/SavingsGoalEventRepo.scala): `app/uk/gov/hmrc/mobilehelptosave/repository/SavingsGoalEventRepo.scala`
- [Milestone records](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/repository/MilestonesRepo.scala): `app/uk/gov/hmrc/mobilehelptosave/repository/MilestonesRepo.scala`
- [Previous balances](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/repository/PreviousBalanceRepo.scala): `app/uk/gov/hmrc/mobilehelptosave/repository/PreviousBalanceRepo.scala`
- [Eligibility records](https://github.com/hmrc/mobile-help-to-save/blob/main/app/uk/gov/hmrc/mobilehelptosave/repository/EligibilityRepo.scala): `app/uk/gov/hmrc/mobilehelptosave/repository/EligibilityRepo.scala`

### Other components

- **Mobile app**

## Connections

- Mobile app → Help endpoints: calls endpoints
- Mobile app → Startup endpoint: requests startup
- Mobile app → Milestone endpoints: requests milestones
- Help endpoints → NINO and shutter checks: authorizes requests (evidence: `app/uk/gov/hmrc/mobilehelptosave/controllers/HelpToSaveController.scala`)
- Help endpoints → Account and goals: delegates account work (evidence: `app/uk/gov/hmrc/mobilehelptosave/controllers/HelpToSaveController.scala`)
- Help endpoints → Savings-goal events: uses goal events (evidence: `app/uk/gov/hmrc/mobilehelptosave/controllers/HelpToSaveController.scala`)
- Startup endpoint → NINO and shutter checks: authorizes requests (evidence: `app/uk/gov/hmrc/mobilehelptosave/controllers/StartupController.scala`)
- Startup endpoint → User state: fetches user state (evidence: `app/uk/gov/hmrc/mobilehelptosave/controllers/StartupController.scala`)
- Milestone endpoints → Milestone services: requests milestones (evidence: `app/uk/gov/hmrc/mobilehelptosave/controllers/MilestonesController.scala`)
- Milestone endpoints → NINO and shutter checks: authorizes requests (evidence: `app/uk/gov/hmrc/mobilehelptosave/controllers/MilestonesController.scala`)
- Sandbox endpoints → Shuttering service: checks shutter status (evidence: `app/uk/gov/hmrc/mobilehelptosave/controllers/SandboxController.scala`)
- Sandbox endpoints → Sample responses: returns samples (evidence: `app/uk/gov/hmrc/mobilehelptosave/controllers/SandboxController.scala`)
- Sandbox endpoints → Request and error checks: applies shutter checks (evidence: `app/uk/gov/hmrc/mobilehelptosave/controllers/SandboxController.scala`)
- Account and goals → Savings-goal events: reads and writes (evidence: `app/uk/gov/hmrc/mobilehelptosave/services/AccountService.scala`)
- Account and goals → Help to Save service: fetches account data
- Account and goals → Savings updates: uses savings calculations (evidence: `app/uk/gov/hmrc/mobilehelptosave/services/AccountService.scala`)
- Account and goals → Balance milestones: checks milestones (evidence: `app/uk/gov/hmrc/mobilehelptosave/services/AccountService.scala`)
- Account and goals → Bonus-period milestones: checks milestones (evidence: `app/uk/gov/hmrc/mobilehelptosave/services/AccountService.scala`)
- Account and goals → Bonus-reached milestones: checks milestones (evidence: `app/uk/gov/hmrc/mobilehelptosave/services/AccountService.scala`)
- Savings updates → Bonus calculator: calculates bonus (evidence: `app/uk/gov/hmrc/mobilehelptosave/services/SavingsUpdateService.scala`)
- Milestone services → Balance milestones: uses balance checks
- Milestone services → Bonus-period milestones: uses period checks
- Milestone services → Bonus-reached milestones: uses bonus checks
- Balance milestones → Milestone records: reads and writes (evidence: `app/uk/gov/hmrc/mobilehelptosave/services/BalanceMilestonesService.scala`)
- Balance milestones → Previous balances: reads balances (evidence: `app/uk/gov/hmrc/mobilehelptosave/services/BalanceMilestonesService.scala`)
- Bonus-period milestones → Milestone records: reads and writes (evidence: `app/uk/gov/hmrc/mobilehelptosave/services/BonusPeriodMilestonesService.scala`)
- Bonus-period milestones → Previous balances: reads balances (evidence: `app/uk/gov/hmrc/mobilehelptosave/services/BonusPeriodMilestonesService.scala`)
