# cjmaybe/next-pay architecture

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

- Interactive diagram: https://gitdiagram.com/cjmaybe/next-pay
- Repository: https://github.com/cjmaybe/next-pay

## Overview

OffPay is an Android app for initiating UPI payments and balance checks through carrier USSD flows, with QR scanning, session feedback, history, settings, and onboarding. The visible workflow is user entry through the app, payment-form submission, and domain/platform execution; the source excerpts do not show the full ViewModel-to-USSD runtime chain. The graph preserves documented screens and platform capabilities, but omits uncertain links where the sampled source does not establish a caller.

Main entry points: [`offpay_ref/OffPayApplication.kt`](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/OffPayApplication.kt) (Dependency wiring), [`offpay_ref/presentation/navigation/MainScaffold.kt`](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/navigation/MainScaffold.kt) (App navigation), [`offpay_ref/presentation/screens/onboarding/OnboardingFlow.kt`](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/onboarding/OnboardingFlow.kt) (Onboarding), [`offpay_ref/domain/ActionRunner.kt`](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/ActionRunner.kt) (Action runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["App experience"]
  node_scaffold["App navigation<br/>[MainScaffold.kt]"]
  node_onboarding["Onboarding<br/>[OnboardingFlow.kt]"]
  node_pay["Pay screen<br/>[PayScreen.kt]"]
  node_balance["Balance screen<br/>[BalanceScreen.kt]"]
  node_scan["QR scanning screen<br/>[ScanScreen.kt]"]
  node_history_ui["History screen<br/>[HistoryScreen.kt]"]
  node_settings["Settings screen<br/>[SettingsScreen.kt]"]
  node_faq_legal["Help and legal"]
  node_pay_vm["Payment state<br/>[PayViewModel.kt]"]
  node_balance_vm["Balance state"]
  node_history_vm["History state"]
end

subgraph group_domain["Payment domain"]
  node_action_runner["Action runner<br/>[ActionRunner.kt]"]
  node_actions["Payment actions<br/>[Actions.kt]"]
  node_validation["Input validation<br/>[InputValidator.kt]"]
  node_mode_router["Mode routing<br/>[ModeRouter.kt]"]
  node_upi_parser["UPI parsing<br/>[UpiParser.kt]"]
  node_session["Session state<br/>[SessionState.kt]"]
end

subgraph group_platform["Android platform"]
  node_ussd_engine["USSD engine<br/>[UssdEngine.kt]"]
  node_accessibility["USSD accessibility"]
  node_overlay["Session overlay"]
  node_qr_manager["QR scanner"]
  node_carrier["Carrier detection<br/>[CarrierDetector.kt]"]
  node_application["Dependency wiring"]
end

subgraph group_data["Persistence"]
  node_history_repo["History repository"]
  node_preferences["Preferences"]
  node_database[("Transaction database<br/>[AppDatabase.kt]")]
  node_transaction_dao["Transaction DAO<br/>[TransactionDao.kt]"]
  node_transaction_entity["Transaction records"]
end

node_user(("User"))

node_user -->|"opens app"| node_scaffold
node_scaffold -->|"shows first launch"| node_onboarding
node_onboarding -->|"saves completion"| node_preferences
node_scaffold -->|"routes to"| node_balance
node_pay -->|"submits payment"| node_pay_vm
node_application -->|"creates"| node_database
node_application -->|"creates"| node_history_repo
node_application -->|"creates"| node_preferences
node_application -->|"creates"| node_overlay
node_application -->|"creates with overlay"| node_ussd_engine
node_application -->|"creates"| node_carrier
node_application -->|"creates"| node_qr_manager
node_application -->|"creates with engine"| node_action_runner
node_action_runner -->|"uses"| node_ussd_engine

click node_scaffold "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/navigation/MainScaffold.kt"
click node_onboarding "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/onboarding/OnboardingFlow.kt"
click node_pay "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/PayScreen.kt"
click node_balance "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/BalanceScreen.kt"
click node_scan "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/ScanScreen.kt"
click node_history_ui "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/HistoryScreen.kt"
click node_settings "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/SettingsScreen.kt"
click node_faq_legal "https://github.com/cjmaybe/next-pay/tree/main/offpay_ref/presentation/screens"
click node_pay_vm "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/PayViewModel.kt"
click node_balance_vm "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/BalanceViewModel.kt"
click node_history_vm "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/HistoryViewModel.kt"
click node_action_runner "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/ActionRunner.kt"
click node_actions "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/Actions.kt"
click node_validation "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/InputValidator.kt"
click node_mode_router "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/ModeRouter.kt"
click node_upi_parser "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/UpiParser.kt"
click node_session "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/SessionState.kt"
click node_ussd_engine "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/platform/UssdEngine.kt"
click node_accessibility "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/platform/UssdAccessibilityService.kt"
click node_overlay "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/platform/OverlayControllerImpl.kt"
click node_qr_manager "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/platform/QrScannerManager.kt"
click node_carrier "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/platform/CarrierDetector.kt"
click node_application "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/OffPayApplication.kt"
click node_history_repo "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/data/HistoryRepository.kt"
click node_preferences "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/data/PreferencesRepository.kt"
click node_database "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/data/AppDatabase.kt"
click node_transaction_dao "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/data/TransactionDao.kt"
click node_transaction_entity "https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/data/TransactionEntity.kt"

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_scaffold,node_onboarding,node_pay,node_balance,node_scan,node_history_ui,node_settings,node_faq_legal,node_pay_vm,node_balance_vm,node_history_vm,node_user toneBlue
class node_action_runner,node_actions,node_validation,node_mode_router,node_upi_parser,node_session toneAmber
class node_ussd_engine,node_accessibility,node_overlay,node_qr_manager,node_carrier,node_application toneMint
class node_history_repo,node_preferences,node_database,node_transaction_dao,node_transaction_entity toneRose
```

## Components

### App experience

- [App navigation](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/navigation/MainScaffold.kt): `offpay_ref/presentation/navigation/MainScaffold.kt`
- [Onboarding](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/onboarding/OnboardingFlow.kt): `offpay_ref/presentation/screens/onboarding/OnboardingFlow.kt`
- [Pay screen](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/PayScreen.kt): `offpay_ref/presentation/screens/PayScreen.kt`
- [Balance screen](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/BalanceScreen.kt): `offpay_ref/presentation/screens/BalanceScreen.kt`
- [QR scanning screen](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/ScanScreen.kt): `offpay_ref/presentation/screens/ScanScreen.kt`
- [History screen](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/HistoryScreen.kt): `offpay_ref/presentation/screens/HistoryScreen.kt`
- [Settings screen](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/screens/SettingsScreen.kt): `offpay_ref/presentation/screens/SettingsScreen.kt`
- [Help and legal](https://github.com/cjmaybe/next-pay/tree/main/offpay_ref/presentation/screens): `offpay_ref/presentation/screens`
- [Payment state](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/PayViewModel.kt): `offpay_ref/presentation/PayViewModel.kt`
- [Balance state](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/BalanceViewModel.kt): `offpay_ref/presentation/BalanceViewModel.kt`
- [History state](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/presentation/HistoryViewModel.kt): `offpay_ref/presentation/HistoryViewModel.kt`

### Payment domain

- [Action runner](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/ActionRunner.kt): `offpay_ref/domain/ActionRunner.kt`
- [Payment actions](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/Actions.kt): `offpay_ref/domain/Actions.kt`
- [Input validation](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/InputValidator.kt): `offpay_ref/domain/InputValidator.kt`
- [Mode routing](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/ModeRouter.kt): `offpay_ref/domain/ModeRouter.kt`
- [UPI parsing](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/UpiParser.kt): `offpay_ref/domain/UpiParser.kt`
- [Session state](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/domain/SessionState.kt): `offpay_ref/domain/SessionState.kt`

### Android platform

- [USSD engine](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/platform/UssdEngine.kt): `offpay_ref/platform/UssdEngine.kt`
- [USSD accessibility](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/platform/UssdAccessibilityService.kt): `offpay_ref/platform/UssdAccessibilityService.kt`
- [Session overlay](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/platform/OverlayControllerImpl.kt): `offpay_ref/platform/OverlayControllerImpl.kt`
- [QR scanner](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/platform/QrScannerManager.kt): `offpay_ref/platform/QrScannerManager.kt`
- [Carrier detection](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/platform/CarrierDetector.kt): `offpay_ref/platform/CarrierDetector.kt`
- [Dependency wiring](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/OffPayApplication.kt): `offpay_ref/OffPayApplication.kt`

### Persistence

- [History repository](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/data/HistoryRepository.kt): `offpay_ref/data/HistoryRepository.kt`
- [Preferences](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/data/PreferencesRepository.kt): `offpay_ref/data/PreferencesRepository.kt`
- [Transaction database](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/data/AppDatabase.kt): `offpay_ref/data/AppDatabase.kt`
- [Transaction DAO](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/data/TransactionDao.kt): `offpay_ref/data/TransactionDao.kt`
- [Transaction records](https://github.com/cjmaybe/next-pay/blob/main/offpay_ref/data/TransactionEntity.kt): `offpay_ref/data/TransactionEntity.kt`

### Other components

- **User**

## Connections

- User → App navigation: opens app
- App navigation → Onboarding: shows first launch (evidence: `offpay_ref/presentation/navigation/MainScaffold.kt`)
- Onboarding → Preferences: saves completion
- App navigation → Balance screen: routes to (evidence: `offpay_ref/presentation/navigation/MainScaffold.kt`)
- Pay screen → Payment state: submits payment (evidence: `offpay_ref/presentation/screens/PayScreen.kt`)
- Dependency wiring → Transaction database: creates (evidence: `offpay_ref/OffPayApplication.kt`)
- Dependency wiring → History repository: creates (evidence: `offpay_ref/OffPayApplication.kt`)
- Dependency wiring → Preferences: creates (evidence: `offpay_ref/OffPayApplication.kt`)
- Dependency wiring → Session overlay: creates (evidence: `offpay_ref/OffPayApplication.kt`)
- Dependency wiring → USSD engine: creates with overlay (evidence: `offpay_ref/OffPayApplication.kt`)
- Dependency wiring → Carrier detection: creates (evidence: `offpay_ref/OffPayApplication.kt`)
- Dependency wiring → QR scanner: creates (evidence: `offpay_ref/OffPayApplication.kt`)
- Dependency wiring → Action runner: creates with engine (evidence: `offpay_ref/OffPayApplication.kt`)
- Action runner → USSD engine: uses
