# moneyphp/money architecture

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

- Interactive diagram: https://gitdiagram.com/moneyphp/money
- Repository: https://github.com/moneyphp/money

## Overview

Money is a PHP value-object library for exact monetary amounts represented as strings. The principal workflow is creating a Money value, performing arithmetic through a calculator, and optionally parsing, formatting, or exchanging it. Currency repositories supply currency metadata; the README also documents JSON serialization and exchange integrations. The sampled source confirms parser, calculator, indirect-exchange, and ISO-currency behavior; wiring among unsampled components is omitted where uncertain.

Main entry points: [`src/Currencies.php`](https://github.com/moneyphp/money/blob/master/src/Currencies.php) (Currencies API), [`src/Exchange.php`](https://github.com/moneyphp/money/blob/master/src/Exchange.php) (Exchange API), [`src/MoneyParser.php`](https://github.com/moneyphp/money/blob/master/src/MoneyParser.php) (Money parser API), [`src/Money.php`](https://github.com/moneyphp/money/blob/master/src/Money.php) (Money value)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Money values"]
  node_money["Money value<br/>[Money.php]"]
  node_currency["Currency code<br/>[Currency.php]"]
  node_calculator["Arithmetic calculator<br/>[Calculator.php]"]
  node_number["Number utilities<br/>[Number.php]"]
end

subgraph group_currencies["Currency metadata"]
  node_currencies_api["Currencies API<br/>[Currencies.php]"]
  node_iso_currencies["ISO currencies<br/>[ISOCurrencies.php]"]
  node_currency_file["ISO currency data<br/>[currency.php]"]
  node_crypto_currencies["Crypto currencies"]
  node_binance_file["Crypto currency data<br/>[binance.php]"]
  node_cached_currencies["Cached currencies"]
  node_aggregate_currencies["Combined currencies"]
end

subgraph group_io["Parsing and formatting"]
  node_parser_api["Money parser API<br/>[MoneyParser.php]"]
  node_decimal_parser["Decimal parser"]
  node_intl_parser["Intl parser"]
  node_parser_variants["Other parsers"]
  node_formatter_api["Money formatter API<br/>[MoneyFormatter.php]"]
  node_formatters["Money formatters"]
  node_teller["Teller facade<br/>[Teller.php]"]
end

subgraph group_exchange["Currency exchange"]
  node_exchange_api["Exchange API<br/>[Exchange.php]"]
  node_fixed_exchange["Fixed rates<br/>[FixedExchange.php]"]
  node_exchanger_exchange["Exchanger adapter"]
  node_indirect_exchange["Indirect rates"]
  node_swap_exchange["Swap adapter<br/>[SwapExchange.php]"]
end

node_developer(("Library user"))
node_rate_service(("Rate service"))

node_developer -->|"creates and uses"| node_money
node_money -->|"calculates with"| node_calculator
node_calculator -->|"uses"| node_number
node_developer -->|"parses amounts"| node_parser_api
node_parser_api -->|"implemented by"| node_decimal_parser
node_parser_api -->|"implemented by"| node_intl_parser
node_decimal_parser -->|"reads subunits"| node_currencies_api
node_decimal_parser -->|"constructs"| node_money
node_intl_parser -->|"reads subunits"| node_currencies_api
node_intl_parser -->|"constructs"| node_money
node_parser_variants -->|"implements"| node_parser_api
node_developer -->|"formats amounts"| node_formatter_api
node_formatters -->|"implements"| node_formatter_api
node_formatters -->|"reads subunits"| node_currencies_api
node_teller -->|"uses parser"| node_parser_api
node_teller -->|"uses formatter"| node_formatter_api
node_iso_currencies -->|"implements"| node_currencies_api
node_iso_currencies -->|"loads data"| node_currency_file
node_crypto_currencies -->|"implements"| node_currencies_api
node_crypto_currencies -->|"loads data"| node_binance_file
node_cached_currencies -->|"implements"| node_currencies_api
node_aggregate_currencies -->|"implements"| node_currencies_api
node_developer -->|"requests conversion"| node_exchange_api
node_fixed_exchange -->|"implements"| node_exchange_api
node_exchanger_exchange -->|"implements"| node_exchange_api
node_indirect_exchange -->|"implements"| node_exchange_api
node_indirect_exchange -->|"searches currencies"| node_currencies_api
node_indirect_exchange -->|"requests rate quotes"| node_exchange_api
node_swap_exchange -->|"implements"| node_exchange_api
node_exchanger_exchange -.->|"gets rates"| node_rate_service
node_swap_exchange -.->|"gets rates"| node_rate_service

click node_money "https://github.com/moneyphp/money/blob/master/src/Money.php"
click node_currency "https://github.com/moneyphp/money/blob/master/src/Currency.php"
click node_calculator "https://github.com/moneyphp/money/blob/master/src/Calculator.php"
click node_number "https://github.com/moneyphp/money/blob/master/src/Number.php"
click node_currencies_api "https://github.com/moneyphp/money/blob/master/src/Currencies.php"
click node_iso_currencies "https://github.com/moneyphp/money/blob/master/src/Currencies/ISOCurrencies.php"
click node_currency_file "https://github.com/moneyphp/money/blob/master/resources/currency.php"
click node_crypto_currencies "https://github.com/moneyphp/money/blob/master/src/Currencies/CryptoCurrencies.php"
click node_binance_file "https://github.com/moneyphp/money/blob/master/resources/binance.php"
click node_cached_currencies "https://github.com/moneyphp/money/blob/master/src/Currencies/CachedCurrencies.php"
click node_aggregate_currencies "https://github.com/moneyphp/money/blob/master/src/Currencies/AggregateCurrencies.php"
click node_parser_api "https://github.com/moneyphp/money/blob/master/src/MoneyParser.php"
click node_decimal_parser "https://github.com/moneyphp/money/blob/master/src/Parser/DecimalMoneyParser.php"
click node_intl_parser "https://github.com/moneyphp/money/blob/master/src/Parser/IntlMoneyParser.php"
click node_parser_variants "https://github.com/moneyphp/money/tree/master/src/Parser"
click node_formatter_api "https://github.com/moneyphp/money/blob/master/src/MoneyFormatter.php"
click node_formatters "https://github.com/moneyphp/money/tree/master/src/Formatter"
click node_teller "https://github.com/moneyphp/money/blob/master/src/Teller.php"
click node_exchange_api "https://github.com/moneyphp/money/blob/master/src/Exchange.php"
click node_fixed_exchange "https://github.com/moneyphp/money/blob/master/src/Exchange/FixedExchange.php"
click node_exchanger_exchange "https://github.com/moneyphp/money/blob/master/src/Exchange/ExchangerExchange.php"
click node_indirect_exchange "https://github.com/moneyphp/money/blob/master/src/Exchange/IndirectExchange.php"
click node_swap_exchange "https://github.com/moneyphp/money/blob/master/src/Exchange/SwapExchange.php"

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_money,node_currency,node_calculator,node_number,node_developer toneBlue
class node_currencies_api,node_iso_currencies,node_currency_file,node_crypto_currencies,node_binance_file,node_cached_currencies,node_aggregate_currencies toneAmber
class node_parser_api,node_decimal_parser,node_intl_parser,node_parser_variants,node_formatter_api,node_formatters,node_teller toneMint
class node_exchange_api,node_fixed_exchange,node_exchanger_exchange,node_indirect_exchange,node_swap_exchange toneRose
class node_rate_service toneIndigo
```

## Components

### Money values

- [Money value](https://github.com/moneyphp/money/blob/master/src/Money.php): `src/Money.php`
- [Currency code](https://github.com/moneyphp/money/blob/master/src/Currency.php): `src/Currency.php`
- [Arithmetic calculator](https://github.com/moneyphp/money/blob/master/src/Calculator.php): `src/Calculator.php`
- [Number utilities](https://github.com/moneyphp/money/blob/master/src/Number.php): `src/Number.php`

### Currency metadata

- [Currencies API](https://github.com/moneyphp/money/blob/master/src/Currencies.php): `src/Currencies.php`
- [ISO currencies](https://github.com/moneyphp/money/blob/master/src/Currencies/ISOCurrencies.php): `src/Currencies/ISOCurrencies.php`
- [ISO currency data](https://github.com/moneyphp/money/blob/master/resources/currency.php): `resources/currency.php`
- [Crypto currencies](https://github.com/moneyphp/money/blob/master/src/Currencies/CryptoCurrencies.php): `src/Currencies/CryptoCurrencies.php`
- [Crypto currency data](https://github.com/moneyphp/money/blob/master/resources/binance.php): `resources/binance.php`
- [Cached currencies](https://github.com/moneyphp/money/blob/master/src/Currencies/CachedCurrencies.php): `src/Currencies/CachedCurrencies.php`
- [Combined currencies](https://github.com/moneyphp/money/blob/master/src/Currencies/AggregateCurrencies.php): `src/Currencies/AggregateCurrencies.php`

### Parsing and formatting

- [Money parser API](https://github.com/moneyphp/money/blob/master/src/MoneyParser.php): `src/MoneyParser.php`
- [Decimal parser](https://github.com/moneyphp/money/blob/master/src/Parser/DecimalMoneyParser.php): `src/Parser/DecimalMoneyParser.php`
- [Intl parser](https://github.com/moneyphp/money/blob/master/src/Parser/IntlMoneyParser.php): `src/Parser/IntlMoneyParser.php`
- [Other parsers](https://github.com/moneyphp/money/tree/master/src/Parser): `src/Parser`
- [Money formatter API](https://github.com/moneyphp/money/blob/master/src/MoneyFormatter.php): `src/MoneyFormatter.php`
- [Money formatters](https://github.com/moneyphp/money/tree/master/src/Formatter): `src/Formatter`
- [Teller facade](https://github.com/moneyphp/money/blob/master/src/Teller.php): `src/Teller.php`

### Currency exchange

- [Exchange API](https://github.com/moneyphp/money/blob/master/src/Exchange.php): `src/Exchange.php`
- [Fixed rates](https://github.com/moneyphp/money/blob/master/src/Exchange/FixedExchange.php): `src/Exchange/FixedExchange.php`
- [Exchanger adapter](https://github.com/moneyphp/money/blob/master/src/Exchange/ExchangerExchange.php): `src/Exchange/ExchangerExchange.php`
- [Indirect rates](https://github.com/moneyphp/money/blob/master/src/Exchange/IndirectExchange.php): `src/Exchange/IndirectExchange.php`
- [Swap adapter](https://github.com/moneyphp/money/blob/master/src/Exchange/SwapExchange.php): `src/Exchange/SwapExchange.php`

### Other components

- **Library user**
- **Rate service**

## Connections

- Library user → Money value: creates and uses
- Money value → Arithmetic calculator: calculates with
- Arithmetic calculator → Number utilities: uses
- Library user → Money parser API: parses amounts
- Money parser API → Decimal parser: implemented by
- Money parser API → Intl parser: implemented by
- Decimal parser → Currencies API: reads subunits
- Decimal parser → Money value: constructs
- Intl parser → Currencies API: reads subunits
- Intl parser → Money value: constructs
- Other parsers → Money parser API: implements
- Library user → Money formatter API: formats amounts
- Money formatters → Money formatter API: implements
- Money formatters → Currencies API: reads subunits
- Teller facade → Money parser API: uses parser
- Teller facade → Money formatter API: uses formatter
- ISO currencies → Currencies API: implements
- ISO currencies → ISO currency data: loads data
- Crypto currencies → Currencies API: implements
- Crypto currencies → Crypto currency data: loads data
- Cached currencies → Currencies API: implements
- Combined currencies → Currencies API: implements
- Library user → Exchange API: requests conversion
- Fixed rates → Exchange API: implements
- Exchanger adapter → Exchange API: implements
- Indirect rates → Exchange API: implements
- Indirect rates → Currencies API: searches currencies
- Indirect rates → Exchange API: requests rate quotes
- Swap adapter → Exchange API: implements
- Exchanger adapter → Rate service: gets rates
- Swap adapter → Rate service: gets rates
