# douglasendrew/fake-bank-api architecture

> Architecture diagram of the GitHub repository douglasendrew/fake-bank-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/douglasendrew/fake-bank-api
- Repository: https://github.com/douglasendrew/fake-bank-api

## Overview

Fake Bank API is a Hyperf financial-services API. Clients authenticate or request account, deposit and PIX operations; status and statement endpoints expose progress and results. The documented asynchronous path queues account creation, deposits and confirmed PIX transfers for Kafka consumers, which apply domain changes through repositories. The graph preserves documented account, audit/security and PIX-key capabilities. Some use cases, consumers and integrations were not excerpted, so their links rely on README claims or SOURCE INDEX references rather than inspected implementation details.

Main entry points: [`config/routes.php`](https://github.com/douglasendrew/fake-bank-api/blob/main/config/routes.php) (API Routes), [`app/Infrastructure/Kafka/Producer/KafkaEventProducer.php`](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Kafka/Producer/KafkaEventProducer.php) (Event Producer), [`app/Interfaces/Http/Controllers/PixController.php`](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Interfaces/Http/Controllers/PixController.php) (PIX API), [`app/Domain/Account/Entities/Account.php`](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Domain/Account/Entities/Account.php) (Account and Transaction Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP and Security"]
  node_routes["API Routes<br/>[routes.php]"]
  node_account_api["Account API"]
  node_auth_api["Authentication API<br/>[AuthController.php]"]
  node_deposit_api["Deposit API"]
  node_pix_api["PIX API<br/>[PixController.php]"]
  node_jwt["JWT Service<br/>[JwtService.php]"]
end

subgraph group_application["Financial Workflows"]
  node_auth["Login Use Case"]
  node_accounts["Account Use Cases"]
  node_statement["Statement Use Case"]
  node_deposits["Deposit Use Cases"]
  node_pix_create["PIX Creation"]
  node_pix_send["PIX Confirmation"]
  node_pix_keys["PIX Key Use Cases"]
end

subgraph group_async["Async Processing"]
  node_producer["Event Producer"]
  node_account_worker["Account Consumer"]
  node_deposit_worker["Deposit Consumer"]
  node_pix_worker["PIX Consumer"]
  node_account_handler["Account Handler"]
  node_deposit_handler["Deposit Handler"]
  node_pix_handler["PIX Handler"]
end

subgraph group_domain["Domain and Persistence"]
  node_domain["Account and Transaction Model<br/>[Account.php]"]
  node_repositories["Persistence Repositories"]
  node_database[("PostgreSQL")]
  node_redis[("Redis Rate Limit and Cache")]
end

node_client(("API Client"))

node_client -->|"sends requests"| node_routes
node_routes -->|"routes account requests"| node_account_api
node_routes -->|"routes login"| node_auth_api
node_routes -->|"routes deposits"| node_deposit_api
node_routes -->|"routes PIX"| node_pix_api
node_auth_api -->|"executes"| node_auth
node_auth -->|"issues tokens"| node_jwt
node_routes -->|"protects routes"| node_jwt
node_account_api -->|"executes"| node_accounts
node_account_api -->|"executes"| node_statement
node_deposit_api -->|"executes"| node_deposits
node_pix_api -->|"creates transfer"| node_pix_create
node_pix_api -->|"confirms transfer"| node_pix_send
node_pix_api -->|"manages keys"| node_pix_keys
node_accounts -->|"publishes event"| node_producer
node_pix_send -->|"publishes event"| node_producer
node_deposits -.->|"queues deposit"| node_producer
node_producer -.->|"dispatches account event"| node_account_worker
node_producer -.->|"dispatches deposit event"| node_deposit_worker
node_producer -.->|"dispatches PIX event"| node_pix_worker
node_account_worker -.->|"processes event"| node_account_handler
node_deposit_worker -.->|"processes event"| node_deposit_handler
node_pix_worker -.->|"processes event"| node_pix_handler
node_account_handler -->|"creates account"| node_domain
node_deposit_handler -->|"updates balance"| node_domain
node_pix_handler -->|"settles transfer"| node_domain
node_accounts -.->|"uses account model"| node_domain
node_statement -.->|"reads activity"| node_repositories
node_repositories -->|"persists records"| node_database
node_pix_handler -.->|"saves balances and transactions"| node_repositories
node_routes -.->|"rate limits"| node_redis

click node_routes "https://github.com/douglasendrew/fake-bank-api/blob/main/config/routes.php"
click node_account_api "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Interfaces/Http/Controllers/AccountController.php"
click node_auth_api "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Interfaces/Http/Controllers/AuthController.php"
click node_deposit_api "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Interfaces/Http/Controllers/DepositController.php"
click node_pix_api "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Interfaces/Http/Controllers/PixController.php"
click node_jwt "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Security/JwtService.php"
click node_auth "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Auth/AuthenticateUserUseCase.php"
click node_accounts "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Account/CreateAccountUseCase.php"
click node_statement "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Account/GetAccountStatementUseCase.php"
click node_deposits "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Deposit/DepositMoneyUseCase.php"
click node_pix_create "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Pix/CreatePixTransferUseCase.php"
click node_pix_send "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Pix/SendPixTransferUseCase.php"
click node_pix_keys "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Pix/RegisterPixKeyUseCase.php"
click node_producer "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Kafka/Producer/KafkaEventProducer.php"
click node_account_worker "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Kafka/Consumer/AccountCreationConsumer.php"
click node_deposit_worker "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Kafka/Consumer/DepositTransactionConsumer.php"
click node_pix_worker "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Kafka/Consumer/PixTransferConsumer.php"
click node_account_handler "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/Handlers/ProcessAccountCreationHandler.php"
click node_deposit_handler "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/Handlers/ProcessDepositHandler.php"
click node_pix_handler "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/Handlers/ProcessPixTransferHandler.php"
click node_domain "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Domain/Account/Entities/Account.php"
click node_repositories "https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Persistence/Repositories/AccountRepository.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_routes,node_account_api,node_auth_api,node_deposit_api,node_pix_api,node_jwt,node_client toneBlue
class node_auth,node_accounts,node_statement,node_deposits,node_pix_create,node_pix_send,node_pix_keys toneAmber
class node_producer,node_account_worker,node_deposit_worker,node_pix_worker,node_account_handler,node_deposit_handler,node_pix_handler toneMint
class node_domain,node_repositories,node_database,node_redis toneRose
```

## Components

### HTTP and Security

- [API Routes](https://github.com/douglasendrew/fake-bank-api/blob/main/config/routes.php): `config/routes.php`
- [Account API](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Interfaces/Http/Controllers/AccountController.php): `app/Interfaces/Http/Controllers/AccountController.php`
- [Authentication API](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Interfaces/Http/Controllers/AuthController.php): `app/Interfaces/Http/Controllers/AuthController.php`
- [Deposit API](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Interfaces/Http/Controllers/DepositController.php): `app/Interfaces/Http/Controllers/DepositController.php`
- [PIX API](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Interfaces/Http/Controllers/PixController.php): `app/Interfaces/Http/Controllers/PixController.php`
- [JWT Service](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Security/JwtService.php): `app/Infrastructure/Security/JwtService.php`

### Financial Workflows

- [Login Use Case](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Auth/AuthenticateUserUseCase.php): `app/Application/UseCases/Auth/AuthenticateUserUseCase.php`
- [Account Use Cases](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Account/CreateAccountUseCase.php): `app/Application/UseCases/Account/CreateAccountUseCase.php`
- [Statement Use Case](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Account/GetAccountStatementUseCase.php): `app/Application/UseCases/Account/GetAccountStatementUseCase.php`
- [Deposit Use Cases](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Deposit/DepositMoneyUseCase.php): `app/Application/UseCases/Deposit/DepositMoneyUseCase.php`
- [PIX Creation](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Pix/CreatePixTransferUseCase.php): `app/Application/UseCases/Pix/CreatePixTransferUseCase.php`
- [PIX Confirmation](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Pix/SendPixTransferUseCase.php): `app/Application/UseCases/Pix/SendPixTransferUseCase.php`
- [PIX Key Use Cases](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/UseCases/Pix/RegisterPixKeyUseCase.php): `app/Application/UseCases/Pix/RegisterPixKeyUseCase.php`

### Async Processing

- [Event Producer](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Kafka/Producer/KafkaEventProducer.php): `app/Infrastructure/Kafka/Producer/KafkaEventProducer.php`
- [Account Consumer](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Kafka/Consumer/AccountCreationConsumer.php): `app/Infrastructure/Kafka/Consumer/AccountCreationConsumer.php`
- [Deposit Consumer](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Kafka/Consumer/DepositTransactionConsumer.php): `app/Infrastructure/Kafka/Consumer/DepositTransactionConsumer.php`
- [PIX Consumer](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Kafka/Consumer/PixTransferConsumer.php): `app/Infrastructure/Kafka/Consumer/PixTransferConsumer.php`
- [Account Handler](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/Handlers/ProcessAccountCreationHandler.php): `app/Application/Handlers/ProcessAccountCreationHandler.php`
- [Deposit Handler](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/Handlers/ProcessDepositHandler.php): `app/Application/Handlers/ProcessDepositHandler.php`
- [PIX Handler](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Application/Handlers/ProcessPixTransferHandler.php): `app/Application/Handlers/ProcessPixTransferHandler.php`

### Domain and Persistence

- [Account and Transaction Model](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Domain/Account/Entities/Account.php): `app/Domain/Account/Entities/Account.php`
- [Persistence Repositories](https://github.com/douglasendrew/fake-bank-api/blob/main/app/Infrastructure/Persistence/Repositories/AccountRepository.php): `app/Infrastructure/Persistence/Repositories/AccountRepository.php`
- **PostgreSQL**
- **Redis Rate Limit and Cache**

### Other components

- **API Client**

## Connections

- API Client → API Routes: sends requests (evidence: `config/routes.php`)
- API Routes → Account API: routes account requests (evidence: `config/routes.php`)
- API Routes → Authentication API: routes login (evidence: `config/routes.php`)
- API Routes → Deposit API: routes deposits (evidence: `config/routes.php`)
- API Routes → PIX API: routes PIX (evidence: `config/routes.php`)
- Authentication API → Login Use Case: executes (evidence: `app/Interfaces/Http/Controllers/AuthController.php`)
- Login Use Case → JWT Service: issues tokens (evidence: `app/Application/UseCases/Auth/AuthenticateUserUseCase.php`)
- API Routes → JWT Service: protects routes (evidence: `config/routes.php`)
- Account API → Account Use Cases: executes (evidence: `app/Interfaces/Http/Controllers/AccountController.php`)
- Account API → Statement Use Case: executes (evidence: `app/Interfaces/Http/Controllers/AccountController.php`)
- Deposit API → Deposit Use Cases: executes (evidence: `app/Interfaces/Http/Controllers/DepositController.php`)
- PIX API → PIX Creation: creates transfer (evidence: `app/Interfaces/Http/Controllers/PixController.php`)
- PIX API → PIX Confirmation: confirms transfer (evidence: `app/Interfaces/Http/Controllers/PixController.php`)
- PIX API → PIX Key Use Cases: manages keys (evidence: `app/Interfaces/Http/Controllers/PixController.php`)
- Account Use Cases → Event Producer: publishes event (evidence: `app/Application/UseCases/Account/CreateAccountUseCase.php`)
- PIX Confirmation → Event Producer: publishes event (evidence: `app/Application/UseCases/Pix/SendPixTransferUseCase.php`)
- Deposit Use Cases → Event Producer: queues deposit
- Event Producer → Account Consumer: dispatches account event
- Event Producer → Deposit Consumer: dispatches deposit event
- Event Producer → PIX Consumer: dispatches PIX event
- Account Consumer → Account Handler: processes event
- Deposit Consumer → Deposit Handler: processes event
- PIX Consumer → PIX Handler: processes event
- Account Handler → Account and Transaction Model: creates account (evidence: `app/Application/Handlers/ProcessAccountCreationHandler.php`)
- Deposit Handler → Account and Transaction Model: updates balance (evidence: `app/Application/Handlers/ProcessDepositHandler.php`)
- PIX Handler → Account and Transaction Model: settles transfer (evidence: `app/Application/Handlers/ProcessPixTransferHandler.php`)
- Account Use Cases → Account and Transaction Model: uses account model (evidence: `app/Application/UseCases/Account/CreateAccountUseCase.php`)
- Statement Use Case → Persistence Repositories: reads activity (evidence: `app/Application/UseCases/Account/GetAccountStatementUseCase.php`)
- Persistence Repositories → PostgreSQL: persists records (evidence: `app/Infrastructure/Persistence/Repositories/AccountRepository.php`)
- PIX Handler → Persistence Repositories: saves balances and transactions (evidence: `app/Application/Handlers/ProcessPixTransferHandler.php`)
- API Routes → Redis Rate Limit and Cache: rate limits
