# payu-intrepos/payu-cli architecture

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

- Interactive diagram: https://gitdiagram.com/payu-intrepos/payu-cli
- Repository: https://github.com/payu-intrepos/payu-cli

## Overview

PayU-CLI is a command-line client for PayU OneAPI. A user invokes a command, the registered command module validates options and selects a PayUClient operation, the client obtains OAuth headers and makes an HTTP request, then command-specific formatters present the returned data. The CLI also manages named credential profiles and reports. README documents payment links, invoices, transactions, refunds, settlements, and reports; some of those command implementations were not sampled, so their internal links are shown only where documented. The root-level legacy modules are omitted. Evidence is limited to the README and indexed excerpts; unsampled implementation details are not inferred.

Main entry points: [`payu_cli/main.py`](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/main.py) (Command registry), [`payu_cli/api.py`](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/api.py) (OneAPI HTTP client), [`payu_cli/formatters.py`](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/formatters.py) (Rich formatters), [`payu_cli/commands/payments.py`](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/payments.py) (Payment commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI entry"]
  node_root["Command registry<br/>[main.py]"]
  node_profiles["Profile commands<br/>[main.py]"]
  node_cli_group["Command group behavior<br/>[cli_group.py]"]
end

subgraph group_domains["Payment operations"]
  node_payment_cmd["Payment commands<br/>[payments.py]"]
  node_txn_cmd["Transaction commands<br/>[transactions.py]"]
  node_refund_cmd["Refund commands<br/>[refunds.py]"]
  node_settlement_cmd["Settlement commands<br/>[settlements.py]"]
  node_report_cmd["Report commands<br/>[reports.py]"]
end

subgraph group_core["API and identity"]
  node_config[("Credential profiles<br/>[config.py]")]
  node_keyring[("OS keyring")]
  node_auth["OAuth token manager<br/>[auth.py]"]
  node_client["OneAPI HTTP client<br/>[api.py]"]
end

subgraph group_presentation["Output"]
  node_formatters["Rich formatters<br/>[formatters.py]"]
end

node_user(("CLI user"))
node_payu{{"PayU OneAPI"}}

node_user -->|"invokes"| node_root
node_root -->|"registers"| node_payment_cmd
node_root -->|"registers"| node_txn_cmd
node_root -->|"registers"| node_refund_cmd
node_root -->|"registers"| node_settlement_cmd
node_root -->|"registers"| node_report_cmd
node_root -->|"handles"| node_profiles
node_root -->|"uses"| node_cli_group
node_profiles -->|"reads and saves"| node_config
node_config -->|"stores secrets"| node_keyring
node_payment_cmd -->|"calls"| node_client
node_txn_cmd -->|"calls"| node_client
node_refund_cmd -->|"calls"| node_client
node_settlement_cmd -->|"calls"| node_client
node_report_cmd -->|"calls"| node_client
node_client -->|"gets headers"| node_auth
node_auth -->|"loads profile"| node_config
node_client -->|"sends API requests"| node_payu
node_auth -->|"requests OAuth token"| node_payu
node_payment_cmd -->|"formats results"| node_formatters
node_txn_cmd -->|"formats results"| node_formatters
node_refund_cmd -->|"formats results"| node_formatters
node_settlement_cmd -->|"formats results"| node_formatters
node_report_cmd -->|"formats results"| node_formatters

click node_root "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/main.py"
click node_profiles "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/main.py"
click node_payment_cmd "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/payments.py"
click node_txn_cmd "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/transactions.py"
click node_refund_cmd "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/refunds.py"
click node_settlement_cmd "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/settlements.py"
click node_report_cmd "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/reports.py"
click node_config "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/config.py"
click node_auth "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/auth.py"
click node_client "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/api.py"
click node_formatters "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/formatters.py"
click node_cli_group "https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/cli_group.py"

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_root,node_profiles,node_cli_group,node_user toneBlue
class node_payment_cmd,node_txn_cmd,node_refund_cmd,node_settlement_cmd,node_report_cmd toneAmber
class node_config,node_keyring,node_auth,node_client,node_payu toneMint
class node_formatters toneRose
```

## Components

### CLI entry

- [Command registry](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/main.py): `payu_cli/main.py`
- [Profile commands](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/main.py): `payu_cli/main.py`
- [Command group behavior](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/cli_group.py): `payu_cli/cli_group.py`

### Payment operations

- [Payment commands](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/payments.py): `payu_cli/commands/payments.py`
- [Transaction commands](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/transactions.py): `payu_cli/commands/transactions.py`
- [Refund commands](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/refunds.py): `payu_cli/commands/refunds.py`
- [Settlement commands](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/settlements.py): `payu_cli/commands/settlements.py`
- [Report commands](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/commands/reports.py): `payu_cli/commands/reports.py`

### API and identity

- [Credential profiles](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/config.py): `payu_cli/config.py`
- **OS keyring**
- [OAuth token manager](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/auth.py): `payu_cli/auth.py`
- [OneAPI HTTP client](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/api.py): `payu_cli/api.py`

### Output

- [Rich formatters](https://github.com/payu-intrepos/payu-cli/blob/main/payu_cli/formatters.py): `payu_cli/formatters.py`

### Other components

- **CLI user**
- **PayU OneAPI**

## Connections

- CLI user → Command registry: invokes (evidence: `README.md`)
- Command registry → Payment commands: registers (evidence: `payu_cli/main.py`)
- Command registry → Transaction commands: registers (evidence: `payu_cli/main.py`)
- Command registry → Refund commands: registers (evidence: `payu_cli/main.py`)
- Command registry → Settlement commands: registers (evidence: `payu_cli/main.py`)
- Command registry → Report commands: registers (evidence: `payu_cli/main.py`)
- Command registry → Profile commands: handles (evidence: `payu_cli/main.py`)
- Command registry → Command group behavior: uses (evidence: `payu_cli/main.py`)
- Profile commands → Credential profiles: reads and saves (evidence: `payu_cli/main.py`)
- Credential profiles → OS keyring: stores secrets (evidence: `payu_cli/config.py`)
- Payment commands → OneAPI HTTP client: calls (evidence: `payu_cli/commands/payments.py`)
- Transaction commands → OneAPI HTTP client: calls (evidence: `payu_cli/commands/transactions.py`)
- Refund commands → OneAPI HTTP client: calls (evidence: `payu_cli/commands/refunds.py`)
- Settlement commands → OneAPI HTTP client: calls (evidence: `payu_cli/commands/settlements.py`)
- Report commands → OneAPI HTTP client: calls (evidence: `payu_cli/commands/reports.py`)
- OneAPI HTTP client → OAuth token manager: gets headers (evidence: `payu_cli/api.py`)
- OAuth token manager → Credential profiles: loads profile (evidence: `payu_cli/auth.py`)
- OneAPI HTTP client → PayU OneAPI: sends API requests (evidence: `payu_cli/api.py`)
- OAuth token manager → PayU OneAPI: requests OAuth token (evidence: `payu_cli/auth.py`)
- Payment commands → Rich formatters: formats results (evidence: `payu_cli/commands/payments.py`)
- Transaction commands → Rich formatters: formats results (evidence: `payu_cli/commands/transactions.py`)
- Refund commands → Rich formatters: formats results (evidence: `payu_cli/commands/refunds.py`)
- Settlement commands → Rich formatters: formats results (evidence: `payu_cli/commands/settlements.py`)
- Report commands → Rich formatters: formats results (evidence: `payu_cli/commands/reports.py`)
