# samuel255231/bank-account-api architecture

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

- Interactive diagram: https://gitdiagram.com/samuel255231/bank-account-api
- Repository: https://github.com/samuel255231/bank-account-api

## Overview

This is a NestJS bank-account API with endpoints to check balances and withdraw funds. The documented workflow is an HTTP client submitting account details to the accounts controller, which delegates the operation to the accounts service and returns a balance or withdrawal result. The service currently uses initialized in-memory demo accounts; although a PostgreSQL entity and database module exist, the sampled application module does not show them wired into this workflow. The graph reflects that evidence limit.

Main entry points: [`src/accounts/accounts.controller.ts`](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/accounts.controller.ts) (Accounts controller), [`src/database/database.module.ts`](https://github.com/samuel255231/bank-account-api/blob/main/src/database/database.module.ts) (PostgreSQL configuration), [`src/accounts/accounts.service.ts`](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/accounts.service.ts) (Accounts service), [`src/app.module.ts`](https://github.com/samuel255231/bank-account-api/blob/main/src/app.module.ts) (App module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API surface"]
  node_accounts_controller["Accounts controller"]
  node_check_dto["Balance request"]
  node_withdraw_dto["Withdrawal request<br/>[withdraw.dto.ts]"]
  node_balance_response["Balance response"]
  node_withdraw_response["Withdrawal response"]
  node_error_response["Error response"]
end

subgraph group_accounts["Account operations"]
  node_accounts_module["Accounts module<br/>[accounts.module.ts]"]
  node_accounts_service["Accounts service"]
  node_demo_accounts[("Demo account state")]
end

subgraph group_persistence["Data configuration"]
  node_account_entity["Account entity<br/>[account.entity.ts]"]
  node_database_module["PostgreSQL configuration<br/>[database.module.ts]"]
end

subgraph group_runtime["Application runtime"]
  node_app_module["App module<br/>[app.module.ts]"]
  node_main["Nest bootstrap<br/>[main.ts]"]
  node_app_controller["Root controller<br/>[app.controller.ts]"]
  node_app_service["Greeting service<br/>[app.service.ts]"]
end

node_client(("HTTP client"))
node_postgres[("PostgreSQL")]

node_client -->|"sends requests"| node_accounts_controller
node_accounts_controller -->|"delegates operations"| node_accounts_service
node_accounts_controller -->|"uses request"| node_check_dto
node_accounts_controller -->|"uses request"| node_withdraw_dto
node_accounts_controller -->|"documents response"| node_balance_response
node_accounts_controller -->|"documents response"| node_withdraw_response
node_accounts_controller -->|"documents errors"| node_error_response
node_accounts_service -->|"reads and updates"| node_demo_accounts
node_app_module -->|"imports"| node_accounts_module
node_main -->|"bootstraps"| node_app_module
node_database_module -->|"registers entity"| node_account_entity
node_database_module -->|"configures connection"| node_postgres
node_app_controller -->|"calls greeting"| node_app_service

click node_accounts_controller "https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/accounts.controller.ts"
click node_check_dto "https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/dto/check-balance.dto.ts"
click node_withdraw_dto "https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/dto/withdraw.dto.ts"
click node_balance_response "https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/dto/balance-response.dto.ts"
click node_withdraw_response "https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/dto/withdraw-response.dto.ts"
click node_error_response "https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/dto/error-response.dto.ts"
click node_accounts_module "https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/accounts.module.ts"
click node_accounts_service "https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/accounts.service.ts"
click node_demo_accounts "https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/accounts.service.ts"
click node_account_entity "https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/entities/account.entity.ts"
click node_database_module "https://github.com/samuel255231/bank-account-api/blob/main/src/database/database.module.ts"
click node_app_module "https://github.com/samuel255231/bank-account-api/blob/main/src/app.module.ts"
click node_main "https://github.com/samuel255231/bank-account-api/blob/main/src/main.ts"
click node_app_controller "https://github.com/samuel255231/bank-account-api/blob/main/src/app.controller.ts"
click node_app_service "https://github.com/samuel255231/bank-account-api/blob/main/src/app.service.ts"

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_accounts_controller,node_check_dto,node_withdraw_dto,node_balance_response,node_withdraw_response,node_error_response,node_client toneBlue
class node_accounts_module,node_accounts_service,node_demo_accounts,node_postgres toneAmber
class node_account_entity,node_database_module toneMint
class node_app_module,node_main,node_app_controller,node_app_service toneRose
```

## Components

### API surface

- [Accounts controller](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/accounts.controller.ts): `src/accounts/accounts.controller.ts`
- [Balance request](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/dto/check-balance.dto.ts): `src/accounts/dto/check-balance.dto.ts`
- [Withdrawal request](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/dto/withdraw.dto.ts): `src/accounts/dto/withdraw.dto.ts`
- [Balance response](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/dto/balance-response.dto.ts): `src/accounts/dto/balance-response.dto.ts`
- [Withdrawal response](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/dto/withdraw-response.dto.ts): `src/accounts/dto/withdraw-response.dto.ts`
- [Error response](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/dto/error-response.dto.ts): `src/accounts/dto/error-response.dto.ts`

### Account operations

- [Accounts module](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/accounts.module.ts): `src/accounts/accounts.module.ts`
- [Accounts service](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/accounts.service.ts): `src/accounts/accounts.service.ts`
- [Demo account state](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/accounts.service.ts): `src/accounts/accounts.service.ts`

### Data configuration

- [Account entity](https://github.com/samuel255231/bank-account-api/blob/main/src/accounts/entities/account.entity.ts): `src/accounts/entities/account.entity.ts`
- [PostgreSQL configuration](https://github.com/samuel255231/bank-account-api/blob/main/src/database/database.module.ts): `src/database/database.module.ts`

### Application runtime

- [App module](https://github.com/samuel255231/bank-account-api/blob/main/src/app.module.ts): `src/app.module.ts`
- [Nest bootstrap](https://github.com/samuel255231/bank-account-api/blob/main/src/main.ts): `src/main.ts`
- [Root controller](https://github.com/samuel255231/bank-account-api/blob/main/src/app.controller.ts): `src/app.controller.ts`
- [Greeting service](https://github.com/samuel255231/bank-account-api/blob/main/src/app.service.ts): `src/app.service.ts`

### Other components

- **HTTP client**
- **PostgreSQL**

## Connections

- HTTP client → Accounts controller: sends requests (evidence: `README.md`)
- Accounts controller → Accounts service: delegates operations (evidence: `src/accounts/accounts.controller.ts`)
- Accounts controller → Balance request: uses request (evidence: `src/accounts/accounts.controller.ts`)
- Accounts controller → Withdrawal request: uses request (evidence: `src/accounts/accounts.controller.ts`)
- Accounts controller → Balance response: documents response (evidence: `src/accounts/accounts.controller.ts`)
- Accounts controller → Withdrawal response: documents response (evidence: `src/accounts/accounts.controller.ts`)
- Accounts controller → Error response: documents errors (evidence: `src/accounts/accounts.controller.ts`)
- Accounts service → Demo account state: reads and updates (evidence: `src/accounts/accounts.service.ts`)
- App module → Accounts module: imports (evidence: `src/app.module.ts`)
- Nest bootstrap → App module: bootstraps (evidence: `src/main.ts`)
- PostgreSQL configuration → Account entity: registers entity (evidence: `src/database/database.module.ts`)
- PostgreSQL configuration → PostgreSQL: configures connection (evidence: `src/database/database.module.ts`)
- Root controller → Greeting service: calls greeting (evidence: `src/app.controller.ts`)
