# arguv/laravel-wallet-service architecture

> Architecture diagram of the GitHub repository arguv/laravel-wallet-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arguv/laravel-wallet-service
- Repository: https://github.com/arguv/laravel-wallet-service

## Overview

Wallet service accepts REST requests from users and gRPC calls from internal services, then exposes wallet creation, deposits, transfers, balances, transaction lookups, and history. Transfer processing applies ledger rules and idempotency before recording postings and updating wallet state in PostgreSQL; audit is also persisted. The README documents these capabilities and the application/storage-port boundary. Some routes and unsampled subsystems are represented at directory or module level; their internal wiring is omitted where the excerpts do not establish it.

Main entry points: [`app/Application/UseCases/TransferMoney.php`](https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/UseCases/TransferMoney.php) (Transfer operation), [`app/Application/Queries`](https://github.com/arguv/laravel-wallet-service/tree/main/app/Application/Queries) (Ledger queries), [`app/Application/Ports/WalletRepository.php`](https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/Ports/WalletRepository.php) (Wallet repository), [`app/Http/Controllers/Api/V1/TransferController.php`](https://github.com/arguv/laravel-wallet-service/blob/main/app/Http/Controllers/Api/V1/TransferController.php) (Transfer API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_adapters["Client interfaces"]
  node_rest_wallets["Wallet API"]
  node_rest_deposit["Deposit API"]
  node_rest_transfer["Transfer API"]
  node_rest_history["History API"]
  node_grpc["Ledger gRPC<br/>[LedgerService.php]"]
end

subgraph group_application["Application services"]
  node_wallet_usecases["Wallet operations<br/>[CreateWallet.php]"]
  node_deposit_usecase["Deposit operation<br/>[Deposit.php]"]
  node_transfer_usecase["Transfer operation<br/>[TransferMoney.php]"]
  node_queries["Ledger queries"]
  node_idempotency["Idempotent execution"]
  node_audit["Audit recording<br/>[RecordAudit.php]"]
  node_wallet_repo["Wallet repository"]
  node_ledger_repo["Ledger repository"]
end

subgraph group_domain["Ledger domain"]
  node_wallet_domain["Wallet rules<br/>[Wallet.php]"]
  node_money["Money and currency<br/>[Money.php]"]
  node_posting["Ledger postings<br/>[Posting.php]"]
end

subgraph group_infrastructure["Persistence and operations"]
  node_wallet_store["Wallet persistence"]
  node_ledger_store["Ledger persistence"]
  node_audit_store["Audit persistence<br/>[DbAuditWriter.php]"]
  node_idempotency_store["Idempotency persistence"]
  node_postgres[("PostgreSQL")]
  node_rate_limit["Transfer rate limiting"]
end

node_users(("REST clients"))
node_services(("Internal services"))

node_users -->|"submits REST"| node_rest_transfer
node_users -->|"requests REST"| node_rest_wallets
node_users -->|"submits REST"| node_rest_deposit
node_users -->|"requests history"| node_rest_history
node_services -->|"calls gRPC"| node_grpc
node_rest_transfer -->|"calls"| node_transfer_usecase
node_rest_transfer -->|"looks up transfer"| node_queries
node_rest_wallets -->|"creates wallet"| node_wallet_usecases
node_rest_wallets -->|"reads wallets"| node_queries
node_rest_deposit -->|"calls"| node_deposit_usecase
node_grpc -->|"calls"| node_transfer_usecase
node_grpc -->|"reads ledger"| node_queries
node_transfer_usecase -->|"executes idempotently"| node_idempotency
node_transfer_usecase -->|"uses wallet port"| node_wallet_repo
node_transfer_usecase -->|"records transfer"| node_ledger_repo
node_transfer_usecase -->|"builds postings"| node_posting
node_transfer_usecase -->|"validates amounts"| node_money
node_transfer_usecase -->|"checks wallets"| node_wallet_domain
node_wallet_usecases -.->|"uses wallet port"| node_wallet_repo
node_deposit_usecase -.->|"uses wallet port"| node_wallet_repo
node_queries -.->|"reads ledger"| node_ledger_repo
node_queries -.->|"reads wallets"| node_wallet_repo
node_idempotency -.->|"stores keys"| node_idempotency_store
node_idempotency -.->|"records audit"| node_audit
node_wallet_repo -->|"implemented by"| node_wallet_store
node_ledger_repo -->|"implemented by"| node_ledger_store
node_wallet_store -->|"reads and writes"| node_postgres
node_ledger_store -->|"reads and writes"| node_postgres
node_audit_store -.->|"writes audit"| node_postgres
node_idempotency_store -.->|"stores keys"| node_postgres
node_rest_transfer -.->|"may be rate-limited"| node_rate_limit

click node_rest_wallets "https://github.com/arguv/laravel-wallet-service/blob/main/app/Http/Controllers/Api/V1/WalletController.php"
click node_rest_deposit "https://github.com/arguv/laravel-wallet-service/blob/main/app/Http/Controllers/Api/V1/DepositController.php"
click node_rest_transfer "https://github.com/arguv/laravel-wallet-service/blob/main/app/Http/Controllers/Api/V1/TransferController.php"
click node_rest_history "https://github.com/arguv/laravel-wallet-service/blob/main/app/Http/Controllers/Api/V1/WalletHistoryController.php"
click node_grpc "https://github.com/arguv/laravel-wallet-service/blob/main/app/Grpc/LedgerService.php"
click node_wallet_usecases "https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/UseCases/CreateWallet.php"
click node_deposit_usecase "https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/UseCases/Deposit.php"
click node_transfer_usecase "https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/UseCases/TransferMoney.php"
click node_queries "https://github.com/arguv/laravel-wallet-service/tree/main/app/Application/Queries"
click node_idempotency "https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/Idempotency/IdempotentExecutor.php"
click node_audit "https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/Audit/RecordAudit.php"
click node_wallet_domain "https://github.com/arguv/laravel-wallet-service/blob/main/app/Domain/Wallet/Wallet.php"
click node_money "https://github.com/arguv/laravel-wallet-service/blob/main/app/Domain/Money/Money.php"
click node_posting "https://github.com/arguv/laravel-wallet-service/blob/main/app/Domain/Ledger/Posting.php"
click node_wallet_repo "https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/Ports/WalletRepository.php"
click node_ledger_repo "https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/Ports/LedgerRepository.php"
click node_wallet_store "https://github.com/arguv/laravel-wallet-service/blob/main/app/Infrastructure/Persistence/EloquentWalletRepository.php"
click node_ledger_store "https://github.com/arguv/laravel-wallet-service/blob/main/app/Infrastructure/Persistence/EloquentLedgerRepository.php"
click node_audit_store "https://github.com/arguv/laravel-wallet-service/blob/main/app/Infrastructure/Persistence/DbAuditWriter.php"
click node_idempotency_store "https://github.com/arguv/laravel-wallet-service/blob/main/app/Infrastructure/Persistence/PostgresIdempotencyStore.php"
click node_rate_limit "https://github.com/arguv/laravel-wallet-service/blob/main/app/Infrastructure/Redis/FixedWindowCounter.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_rest_wallets,node_rest_deposit,node_rest_transfer,node_rest_history,node_grpc,node_users toneBlue
class node_wallet_usecases,node_deposit_usecase,node_transfer_usecase,node_queries,node_idempotency,node_audit,node_wallet_repo,node_ledger_repo toneAmber
class node_wallet_domain,node_money,node_posting toneMint
class node_wallet_store,node_ledger_store,node_audit_store,node_idempotency_store,node_postgres,node_rate_limit toneRose
class node_services toneIndigo
```

## Components

### Client interfaces

- [Wallet API](https://github.com/arguv/laravel-wallet-service/blob/main/app/Http/Controllers/Api/V1/WalletController.php): `app/Http/Controllers/Api/V1/WalletController.php`
- [Deposit API](https://github.com/arguv/laravel-wallet-service/blob/main/app/Http/Controllers/Api/V1/DepositController.php): `app/Http/Controllers/Api/V1/DepositController.php`
- [Transfer API](https://github.com/arguv/laravel-wallet-service/blob/main/app/Http/Controllers/Api/V1/TransferController.php): `app/Http/Controllers/Api/V1/TransferController.php`
- [History API](https://github.com/arguv/laravel-wallet-service/blob/main/app/Http/Controllers/Api/V1/WalletHistoryController.php): `app/Http/Controllers/Api/V1/WalletHistoryController.php`
- [Ledger gRPC](https://github.com/arguv/laravel-wallet-service/blob/main/app/Grpc/LedgerService.php): `app/Grpc/LedgerService.php`

### Application services

- [Wallet operations](https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/UseCases/CreateWallet.php): `app/Application/UseCases/CreateWallet.php`
- [Deposit operation](https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/UseCases/Deposit.php): `app/Application/UseCases/Deposit.php`
- [Transfer operation](https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/UseCases/TransferMoney.php): `app/Application/UseCases/TransferMoney.php`
- [Ledger queries](https://github.com/arguv/laravel-wallet-service/tree/main/app/Application/Queries): `app/Application/Queries`
- [Idempotent execution](https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/Idempotency/IdempotentExecutor.php): `app/Application/Idempotency/IdempotentExecutor.php`
- [Audit recording](https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/Audit/RecordAudit.php): `app/Application/Audit/RecordAudit.php`
- [Wallet repository](https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/Ports/WalletRepository.php): `app/Application/Ports/WalletRepository.php`
- [Ledger repository](https://github.com/arguv/laravel-wallet-service/blob/main/app/Application/Ports/LedgerRepository.php): `app/Application/Ports/LedgerRepository.php`

### Ledger domain

- [Wallet rules](https://github.com/arguv/laravel-wallet-service/blob/main/app/Domain/Wallet/Wallet.php): `app/Domain/Wallet/Wallet.php`
- [Money and currency](https://github.com/arguv/laravel-wallet-service/blob/main/app/Domain/Money/Money.php): `app/Domain/Money/Money.php`
- [Ledger postings](https://github.com/arguv/laravel-wallet-service/blob/main/app/Domain/Ledger/Posting.php): `app/Domain/Ledger/Posting.php`

### Persistence and operations

- [Wallet persistence](https://github.com/arguv/laravel-wallet-service/blob/main/app/Infrastructure/Persistence/EloquentWalletRepository.php): `app/Infrastructure/Persistence/EloquentWalletRepository.php`
- [Ledger persistence](https://github.com/arguv/laravel-wallet-service/blob/main/app/Infrastructure/Persistence/EloquentLedgerRepository.php): `app/Infrastructure/Persistence/EloquentLedgerRepository.php`
- [Audit persistence](https://github.com/arguv/laravel-wallet-service/blob/main/app/Infrastructure/Persistence/DbAuditWriter.php): `app/Infrastructure/Persistence/DbAuditWriter.php`
- [Idempotency persistence](https://github.com/arguv/laravel-wallet-service/blob/main/app/Infrastructure/Persistence/PostgresIdempotencyStore.php): `app/Infrastructure/Persistence/PostgresIdempotencyStore.php`
- **PostgreSQL**
- [Transfer rate limiting](https://github.com/arguv/laravel-wallet-service/blob/main/app/Infrastructure/Redis/FixedWindowCounter.php): `app/Infrastructure/Redis/FixedWindowCounter.php`

### Other components

- **REST clients**
- **Internal services**

## Connections

- REST clients → Transfer API: submits REST (evidence: `README.md`)
- REST clients → Wallet API: requests REST (evidence: `README.md`)
- REST clients → Deposit API: submits REST (evidence: `README.md`)
- REST clients → History API: requests history (evidence: `README.md`)
- Internal services → Ledger gRPC: calls gRPC (evidence: `README.md`)
- Transfer API → Transfer operation: calls (evidence: `app/Http/Controllers/Api/V1/TransferController.php`)
- Transfer API → Ledger queries: looks up transfer (evidence: `app/Http/Controllers/Api/V1/TransferController.php`)
- Wallet API → Wallet operations: creates wallet (evidence: `app/Http/Controllers/Api/V1/WalletController.php`)
- Wallet API → Ledger queries: reads wallets (evidence: `app/Http/Controllers/Api/V1/WalletController.php`)
- Deposit API → Deposit operation: calls (evidence: `app/Http/Controllers/Api/V1/DepositController.php`)
- Ledger gRPC → Transfer operation: calls (evidence: `app/Grpc/LedgerService.php`)
- Ledger gRPC → Ledger queries: reads ledger (evidence: `app/Grpc/LedgerService.php`)
- Transfer operation → Idempotent execution: executes idempotently (evidence: `app/Application/UseCases/TransferMoney.php`)
- Transfer operation → Wallet repository: uses wallet port (evidence: `app/Application/UseCases/TransferMoney.php`)
- Transfer operation → Ledger repository: records transfer (evidence: `app/Application/UseCases/TransferMoney.php`)
- Transfer operation → Ledger postings: builds postings (evidence: `app/Application/UseCases/TransferMoney.php`)
- Transfer operation → Money and currency: validates amounts (evidence: `app/Application/UseCases/TransferMoney.php`)
- Transfer operation → Wallet rules: checks wallets (evidence: `app/Application/UseCases/TransferMoney.php`)
- Wallet operations → Wallet repository: uses wallet port (evidence: `app/Application/UseCases/CreateWallet.php`)
- Deposit operation → Wallet repository: uses wallet port (evidence: `app/Application/UseCases/Deposit.php`)
- Ledger queries → Ledger repository: reads ledger
- Ledger queries → Wallet repository: reads wallets
- Idempotent execution → Idempotency persistence: stores keys
- Idempotent execution → Audit recording: records audit
- Wallet repository → Wallet persistence: implemented by (evidence: `app/Providers/LedgerServiceProvider.php`)
- Ledger repository → Ledger persistence: implemented by (evidence: `app/Providers/LedgerServiceProvider.php`)
- Wallet persistence → PostgreSQL: reads and writes (evidence: `app/Infrastructure/Persistence/EloquentWalletRepository.php`)
- Ledger persistence → PostgreSQL: reads and writes (evidence: `app/Infrastructure/Persistence/EloquentLedgerRepository.php`)
- Audit persistence → PostgreSQL: writes audit
- Idempotency persistence → PostgreSQL: stores keys
- Transfer API → Transfer rate limiting: may be rate-limited
