# cake-tech/cake_wallet architecture

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

- Interactive diagram: https://gitdiagram.com/cake-tech/cake_wallet
- Repository: https://github.com/cake-tech/cake_wallet

## Overview

#### Purpose and Entry Points
Cake Wallet is a non-custodial, privacy-oriented, multi-currency Flutter wallet targeting Android, iOS, macOS, Linux, and Windows. The Dart application starts at `lib/main.dart`, composes dependencies in `lib/di.dart`, and routes UI through `lib/router.dart` and `lib/routes.dart`. Native launchers host Flutter on each platform, including `android/app/src/main/java/com/cakewallet/cake_wallet/MainActivity.java`, `ios/Runner/AppDelegate.swift`, and `linux/main.cc`.

#### Application Composition and State
The app is organized as Flutter presentation code over MobX-style stores and view models. Shared app/session state, settings, wallet selection, nodes, trades, and authentication live under `lib/store/app_store.dart`, `lib/store/settings_store.dart`, and `lib/store/wallet_list_store.dart`. Screen-facing orchestration is concentrated in `lib/view_model/`, such as `lib/view_model/send/send_view_model.dart` and `lib/view_model/wallet_creation_vm.dart`. Reactive lifecycle hooks connect wallet, node, fiat, and authentication changes in `lib/reactions/bootstrap.dart` and `lib/reactions/on_current_wallet_change.dart`.

#### Wallet Domain Boundary
`cw_core` defines chain-agnostic wallet contracts and persistent/domain types: wallet lifecycle, credentials, balances, addresses, transactions, nodes, proxying, and hardware-wallet abstractions. Key boundary paths are `cw_core/lib/wallet_base.dart`, `cw_core/lib/wallet_service.dart`, and `cw_core/lib/wallet_info.dart`. The main app depends on these abstractions rather than directly coupling most UI flows to chain implementations; wallet creation, restoration, loading, and backup are coordinated through `lib/core/wallet_creation_service.dart`, `lib/core/wallet_loading_service.dart`, and `lib/core/backup_service_v3.dart`.

#### Chain Implementations and Network Access
Per-chain Dart packages implement the core interfaces and expose chain-specific signing, syncing, address, token, and transaction behavior. Major implementations include Monero (`cw_monero/lib/monero_wallet_service.dart`, `cw_monero/lib/api/wallet_manager.dart`), UTXO Bitcoin/Litecoin (`cw_bitcoin/lib/bitcoin_wallet_service.dart`, `cw_bitcoin/lib/electrum_wallet.dart`), EVM (`cw_evm/lib/evm_chain_wallet_service.dart`, `cw_evm/lib/clients/evm_chain_client.dart`), and Solana/Tron (`cw_solana/lib/solana_client.dart`, `cw_tron/lib/tron_http_provider.dart`). Default RPC, Electrum, and node endpoints are bundled as assets, e.g. `assets/bitcoin_electrum_server_list.yml`, `assets/ethereum_server_list.yml`, and `assets/solana_node_list.yml`; users can manage endpoint selection via `lib/core/node_switching_service.dart`.

#### User Flows and UI Surfaces
The established UI is screen-oriented under `lib/src/screens/`, with root/authentication, dashboard, send/receive, wallet onboarding, exchange, and settings flows. Representative controllers are `lib/src/screens/root/root.dart`, `lib/src/screens/send/send_page.dart`, and `lib/src/screens/new_wallet/new_wallet_page.dart`. A parallel newer interface resides in `lib/new-ui/`, including `lib/new-ui/new_dashboard.dart`, `lib/new-ui/pages/send_page.dart`, and `lib/new-ui/pages/swap_page.dart`. Both surfaces consume the same stores, view models, wallet services, and route infrastructure.

#### Payments, Swaps, and External Services
Transaction creation flows from UI/view models into the selected wallet implementation and its network client; pending transaction models provide the confirmation/broadcast boundary. Address input is normalized or resolved across DNS/domain and social-address schemes by `lib/core/address_resolver/address_resolver_service.dart`, `lib/core/universal_address_detector.dart`, and `lib/core/lightning_invoice_service.dart`. Third-party integrations are adapter-driven: exchange providers in `lib/exchange/provider/exchange_provider.dart`, fiat on-ramp providers in `lib/buy/buy_provider.dart`, Cake Pay APIs in `lib/cake_pay/src/services/cake_pay_api.dart`, and WalletConnect signing/session support in `lib/src/screens/wallet_connect/services/walletkit_service.dart`.

#### Privacy, Native Dependencies, and Delivery
Network privacy is a first-class cross-cutting boundary: core supports SOCKS/proxy and Tor implementations in `cw_core/lib/utils/proxy_wrapper.dart` and `cw_core/lib/utils/tor/torch.dart`; app startup/settings expose these controls through `lib/view_model/start_tor_view_model.dart`. Secure key/PIN operations bridge to platform facilities via `cw_core/lib/set_app_secure_native.dart`, `ios/CakeWallet/decrypt.swift`, and `macos/CakeWallet/decrypt.swift`. Several chains require native libraries/plugins—Monero, MWEB, Zcash, Decred, and Wownero—built through platform scripts such as `scripts/android/build_monero_all.sh`, `scripts/ios/build_zcash.sh`, and `scripts/linux/build_all.sh`. Docker-based Android builds and CI workflows support reproducible packaging (`scripts/android/docker/build.sh`, `.github/workflows/reusable-build.yml`).

Main entry points: [`lib/view_model/send/send_view_model.dart`](https://github.com/cake-tech/cake_wallet/blob/dev/lib/view_model/send/send_view_model.dart) (View models), [`lib/src/screens/root/root.dart`](https://github.com/cake-tech/cake_wallet/blob/dev/lib/src/screens/root/root.dart) (Established screens), [`cw_core/lib/wallet_service.dart`](https://github.com/cake-tech/cake_wallet/blob/dev/cw_core/lib/wallet_service.dart) (Wallet service contract), [`lib/di.dart`](https://github.com/cake-tech/cake_wallet/blob/dev/lib/di.dart) (Dependency composition)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Flutter application"]
  node_entry["App entry<br/>Flutter bootstrap<br/>[main.dart]"]
  node_composition["Dependency composition<br/>DI<br/>[di.dart]"]
  node_routing["Routes and router<br/>navigation<br/>[router.dart]"]
  node_ui["Established screens<br/>Flutter UI<br/>[root.dart]"]
  node_new_ui["New UI surface<br/>Flutter UI<br/>[new_dashboard.dart]"]
  node_stores["App stores<br/>MobX state<br/>[app_store.dart]"]
  node_view_models["View models<br/>screen orchestration"]
  node_reactions["Reactive lifecycle<br/>MobX reactions<br/>[bootstrap.dart]"]
end

subgraph group_domain["Wallet domain"]
  node_wallet_core{{"Wallet contracts<br/>chain-agnostic domain<br/>[wallet_base.dart]"}}
  node_wallet_service["Wallet service contract<br/>domain service"]
  node_wallet_lifecycle["Wallet lifecycle services<br/>app service"]
  node_address_resolution["Address resolution<br/>payment service"]
  node_node_switching["Node selection<br/>network service"]
end

subgraph group_chains["Chain implementations"]
  node_monero["Monero wallet<br/>chain adapter"]
  node_bitcoin["Bitcoin and Litecoin wallets<br/>UTXO chain adapter"]
  node_evm["EVM wallets<br/>EVM chain adapter"]
  node_solana_tron["Solana and Tron clients<br/>chain clients<br/>[solana_client.dart]"]
end

subgraph group_integrations["External and platform"]
  node_network_endpoints["Bundled endpoints<br/>RPC and Electrum lists"]
  node_provider_adapters["Provider adapters<br/>exchange and on-ramp"]
  node_cake_pay["Cake Pay API<br/>payment integration<br/>[cake_pay_api.dart]"]
  node_walletconnect["WalletConnect<br/>signing sessions"]
  node_privacy["Tor and proxy<br/>privacy transport<br/>[proxy_wrapper.dart]"]
  node_secure_native["Secure native storage<br/>platform security"]
  node_native_build["Native chain builds<br/>platform build scripts"]
  node_delivery["Reproducible delivery<br/>Docker and CI<br/>[build.sh]"]
end

node_entry -->|"initializes"| node_composition
node_composition -->|"configures"| node_routing
node_routing -->|"navigates"| node_ui
node_routing -->|"navigates"| node_new_ui
node_ui -->|"uses"| node_view_models
node_new_ui -->|"uses"| node_view_models
node_view_models -->|"reads and updates"| node_stores
node_reactions -->|"observes"| node_stores
node_composition -->|"starts"| node_reactions
node_stores -->|"coordinates wallets"| node_wallet_lifecycle
node_view_models -->|"onboards and loads"| node_wallet_lifecycle
node_wallet_lifecycle -->|"uses"| node_wallet_service
node_wallet_service -->|"implements domain contract"| node_wallet_core
node_monero -->|"implements"| node_wallet_service
node_bitcoin -->|"implements"| node_wallet_service
node_evm -->|"implements"| node_wallet_service
node_solana_tron -->|"uses contracts"| node_wallet_core
node_view_models -->|"resolves payment input"| node_address_resolution
node_view_models -->|"selects endpoint"| node_node_switching
node_node_switching -->|"loads defaults"| node_network_endpoints
node_monero -.->|"routes through"| node_privacy
node_bitcoin -.->|"routes through"| node_privacy
node_evm -.->|"routes through"| node_privacy
node_ui -->|"initiates swaps and buys"| node_provider_adapters
node_ui -->|"uses"| node_cake_pay
node_ui -->|"manages sessions"| node_walletconnect
node_wallet_core -->|"secures keys and PINs"| node_secure_native
node_native_build -.->|"builds native dependency"| node_monero
node_delivery -->|"packages"| node_native_build

click node_entry "https://github.com/cake-tech/cake_wallet/blob/dev/lib/main.dart"
click node_composition "https://github.com/cake-tech/cake_wallet/blob/dev/lib/di.dart"
click node_routing "https://github.com/cake-tech/cake_wallet/blob/dev/lib/router.dart"
click node_ui "https://github.com/cake-tech/cake_wallet/blob/dev/lib/src/screens/root/root.dart"
click node_new_ui "https://github.com/cake-tech/cake_wallet/blob/dev/lib/new-ui/new_dashboard.dart"
click node_stores "https://github.com/cake-tech/cake_wallet/blob/dev/lib/store/app_store.dart"
click node_view_models "https://github.com/cake-tech/cake_wallet/blob/dev/lib/view_model/send/send_view_model.dart"
click node_reactions "https://github.com/cake-tech/cake_wallet/blob/dev/lib/reactions/bootstrap.dart"
click node_wallet_core "https://github.com/cake-tech/cake_wallet/blob/dev/cw_core/lib/wallet_base.dart"
click node_wallet_service "https://github.com/cake-tech/cake_wallet/blob/dev/cw_core/lib/wallet_service.dart"
click node_wallet_lifecycle "https://github.com/cake-tech/cake_wallet/blob/dev/lib/core/wallet_creation_service.dart"
click node_address_resolution "https://github.com/cake-tech/cake_wallet/blob/dev/lib/core/address_resolver/address_resolver_service.dart"
click node_node_switching "https://github.com/cake-tech/cake_wallet/blob/dev/lib/core/node_switching_service.dart"
click node_monero "https://github.com/cake-tech/cake_wallet/blob/dev/cw_monero/lib/monero_wallet_service.dart"
click node_bitcoin "https://github.com/cake-tech/cake_wallet/blob/dev/cw_bitcoin/lib/bitcoin_wallet_service.dart"
click node_evm "https://github.com/cake-tech/cake_wallet/blob/dev/cw_evm/lib/evm_chain_wallet_service.dart"
click node_solana_tron "https://github.com/cake-tech/cake_wallet/blob/dev/cw_solana/lib/solana_client.dart"
click node_network_endpoints "https://github.com/cake-tech/cake_wallet/blob/dev/assets/bitcoin_electrum_server_list.yml"
click node_provider_adapters "https://github.com/cake-tech/cake_wallet/blob/dev/lib/exchange/provider/exchange_provider.dart"
click node_cake_pay "https://github.com/cake-tech/cake_wallet/blob/dev/lib/cake_pay/src/services/cake_pay_api.dart"
click node_walletconnect "https://github.com/cake-tech/cake_wallet/blob/dev/lib/src/screens/wallet_connect/services/walletkit_service.dart"
click node_privacy "https://github.com/cake-tech/cake_wallet/blob/dev/cw_core/lib/utils/proxy_wrapper.dart"
click node_secure_native "https://github.com/cake-tech/cake_wallet/blob/dev/cw_core/lib/set_app_secure_native.dart"
click node_native_build "https://github.com/cake-tech/cake_wallet/blob/dev/scripts/android/build_monero_all.sh"
click node_delivery "https://github.com/cake-tech/cake_wallet/blob/dev/scripts/android/docker/build.sh"

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_entry,node_composition,node_routing,node_ui,node_new_ui,node_stores,node_view_models,node_reactions toneBlue
class node_wallet_core,node_wallet_service,node_wallet_lifecycle,node_address_resolution,node_node_switching toneAmber
class node_monero,node_bitcoin,node_evm,node_solana_tron toneMint
class node_network_endpoints,node_provider_adapters,node_cake_pay,node_walletconnect,node_privacy,node_secure_native,node_native_build,node_delivery toneRose
```

## Components

### Flutter application

- [App entry](https://github.com/cake-tech/cake_wallet/blob/dev/lib/main.dart): Flutter bootstrap · `lib/main.dart`
- [Dependency composition](https://github.com/cake-tech/cake_wallet/blob/dev/lib/di.dart): DI · `lib/di.dart`
- [Routes and router](https://github.com/cake-tech/cake_wallet/blob/dev/lib/router.dart): navigation · `lib/router.dart`
- [Established screens](https://github.com/cake-tech/cake_wallet/blob/dev/lib/src/screens/root/root.dart): Flutter UI · Root, onboarding, dashboard, send, receive, exchange, and settings. · `lib/src/screens/root/root.dart`
- [New UI surface](https://github.com/cake-tech/cake_wallet/blob/dev/lib/new-ui/new_dashboard.dart): Flutter UI · `lib/new-ui/new_dashboard.dart`
- [App stores](https://github.com/cake-tech/cake_wallet/blob/dev/lib/store/app_store.dart): MobX state · Session, settings, wallets, nodes, trades, and authentication state. · `lib/store/app_store.dart`
- [View models](https://github.com/cake-tech/cake_wallet/blob/dev/lib/view_model/send/send_view_model.dart): screen orchestration · `lib/view_model/send/send_view_model.dart`
- [Reactive lifecycle](https://github.com/cake-tech/cake_wallet/blob/dev/lib/reactions/bootstrap.dart): MobX reactions · `lib/reactions/bootstrap.dart`

### Wallet domain

- [Wallet contracts](https://github.com/cake-tech/cake_wallet/blob/dev/cw_core/lib/wallet_base.dart): chain-agnostic domain · Wallet lifecycle, credentials, balances, addresses, transactions, nodes, proxies, and hardware wallets. · `cw_core/lib/wallet_base.dart`
- [Wallet service contract](https://github.com/cake-tech/cake_wallet/blob/dev/cw_core/lib/wallet_service.dart): domain service · `cw_core/lib/wallet_service.dart`
- [Wallet lifecycle services](https://github.com/cake-tech/cake_wallet/blob/dev/lib/core/wallet_creation_service.dart): app service · Creation, restoration, loading, and backup coordination. · `lib/core/wallet_creation_service.dart`
- [Address resolution](https://github.com/cake-tech/cake_wallet/blob/dev/lib/core/address_resolver/address_resolver_service.dart): payment service · Normalizes domains, social addresses, and Lightning invoices. · `lib/core/address_resolver/address_resolver_service.dart`
- [Node selection](https://github.com/cake-tech/cake_wallet/blob/dev/lib/core/node_switching_service.dart): network service · `lib/core/node_switching_service.dart`

### Chain implementations

- [Monero wallet](https://github.com/cake-tech/cake_wallet/blob/dev/cw_monero/lib/monero_wallet_service.dart): chain adapter · `cw_monero/lib/monero_wallet_service.dart`
- [Bitcoin and Litecoin wallets](https://github.com/cake-tech/cake_wallet/blob/dev/cw_bitcoin/lib/bitcoin_wallet_service.dart): UTXO chain adapter · `cw_bitcoin/lib/bitcoin_wallet_service.dart`
- [EVM wallets](https://github.com/cake-tech/cake_wallet/blob/dev/cw_evm/lib/evm_chain_wallet_service.dart): EVM chain adapter · `cw_evm/lib/evm_chain_wallet_service.dart`
- [Solana and Tron clients](https://github.com/cake-tech/cake_wallet/blob/dev/cw_solana/lib/solana_client.dart): chain clients · `cw_solana/lib/solana_client.dart`

### External and platform

- [Bundled endpoints](https://github.com/cake-tech/cake_wallet/blob/dev/assets/bitcoin_electrum_server_list.yml): RPC and Electrum lists · `assets/bitcoin_electrum_server_list.yml`
- [Provider adapters](https://github.com/cake-tech/cake_wallet/blob/dev/lib/exchange/provider/exchange_provider.dart): exchange and on-ramp · `lib/exchange/provider/exchange_provider.dart`
- [Cake Pay API](https://github.com/cake-tech/cake_wallet/blob/dev/lib/cake_pay/src/services/cake_pay_api.dart): payment integration · `lib/cake_pay/src/services/cake_pay_api.dart`
- [WalletConnect](https://github.com/cake-tech/cake_wallet/blob/dev/lib/src/screens/wallet_connect/services/walletkit_service.dart): signing sessions · `lib/src/screens/wallet_connect/services/walletkit_service.dart`
- [Tor and proxy](https://github.com/cake-tech/cake_wallet/blob/dev/cw_core/lib/utils/proxy_wrapper.dart): privacy transport · `cw_core/lib/utils/proxy_wrapper.dart`
- [Secure native storage](https://github.com/cake-tech/cake_wallet/blob/dev/cw_core/lib/set_app_secure_native.dart): platform security · Bridges key and PIN operations to platform facilities. · `cw_core/lib/set_app_secure_native.dart`
- [Native chain builds](https://github.com/cake-tech/cake_wallet/blob/dev/scripts/android/build_monero_all.sh): platform build scripts · Builds native dependencies for supported chains. · `scripts/android/build_monero_all.sh`
- [Reproducible delivery](https://github.com/cake-tech/cake_wallet/blob/dev/scripts/android/docker/build.sh): Docker and CI · `scripts/android/docker/build.sh`

## Connections

- App entry → Dependency composition: initializes
- Dependency composition → Routes and router: configures
- Routes and router → Established screens: navigates
- Routes and router → New UI surface: navigates
- Established screens → View models: uses
- New UI surface → View models: uses
- View models → App stores: reads and updates
- Reactive lifecycle → App stores: observes
- Dependency composition → Reactive lifecycle: starts
- App stores → Wallet lifecycle services: coordinates wallets
- View models → Wallet lifecycle services: onboards and loads
- Wallet lifecycle services → Wallet service contract: uses
- Wallet service contract → Wallet contracts: implements domain contract
- Monero wallet → Wallet service contract: implements
- Bitcoin and Litecoin wallets → Wallet service contract: implements
- EVM wallets → Wallet service contract: implements
- Solana and Tron clients → Wallet contracts: uses contracts
- View models → Address resolution: resolves payment input
- View models → Node selection: selects endpoint
- Node selection → Bundled endpoints: loads defaults
- Monero wallet → Tor and proxy: routes through
- Bitcoin and Litecoin wallets → Tor and proxy: routes through
- EVM wallets → Tor and proxy: routes through
- Established screens → Provider adapters: initiates swaps and buys
- Established screens → Cake Pay API: uses
- Established screens → WalletConnect: manages sessions
- Wallet contracts → Secure native storage: secures keys and PINs
- Native chain builds → Monero wallet: builds native dependency
- Reproducible delivery → Native chain builds: packages
