# hosung98/bank_tcp_exam architecture

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

- Interactive diagram: https://gitdiagram.com/hosung98/bank_tcp_exam
- Repository: https://github.com/hosung98/bank_tcp_exam

## Overview

This is a bank-protocol TCP simulator project, with byte encoding, length-prefixed framing, shared telegram fields, transaction messages, and simulator-side dispatch. The shown handler implements the receive–dispatch–reply workflow. The README also describes a client, polling, deposits, cancellation, and push notifications, but those modules are absent from the supplied tree and its package layout differs; they are not represented as implemented components. Source excerpts are limited, so unshown runtime connections are omitted.

Main entry points: [`BankSimulatorHandler.java`](https://github.com/hosung98/bank_tcp_exam/blob/main/BankSimulatorHandler.java) (Telegram dispatcher), [`src/main/java/com/example/bank_tcp_exam/protocol/common/ExtraHeader.java`](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/protocol/common/ExtraHeader.java) (Extra header), [`src/main/java/com/example/bank_tcp_exam/simulator/BankSimulatorServer.java`](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/simulator/BankSimulatorServer.java) (Simulator server), [`src/main/java/com/example/bank_tcp_exam/protocol/common/CommonHeader.java`](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/protocol/common/CommonHeader.java) (Common header)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_transport["Transport and dispatch"]
  node_simulator_handler["Telegram dispatcher"]
  node_simulator_server["Simulator server"]
  node_length_framer["Length framer"]
end

subgraph group_protocol["Telegram protocol"]
  node_byte_codec["Byte codec<br/>[ByteCodec.java]"]
  node_common_header["Common header<br/>[CommonHeader.java]"]
  node_extra_header["Extra header<br/>[ExtraHeader.java]"]
  node_telegram_trailer["Telegram trailer"]
end

subgraph group_transactions["Transaction handling"]
  node_polling_messages["Polling messages"]
  node_deposit_messages["Deposit messages"]
  node_polling_handler["Polling handler<br/>[C0001_Handler.java]"]
  node_deposit_handler["Deposit handler<br/>[C2001_Handler.java]"]
  node_tx_handler_contract["Handler contract"]
end

node_client_actor(("Institution client"))
node_bank_actor(("Bank peer"))
node_application["Application entry"]

node_client_actor -.->|"sends telegrams"| node_simulator_server
node_simulator_handler -->|"reads and writes"| node_length_framer
node_simulator_handler -->|"decodes code"| node_byte_codec
node_simulator_handler -->|"dispatches to"| node_tx_handler_contract
node_simulator_server -.->|"handles telegrams"| node_simulator_handler
node_bank_actor -.->|"simulated peer"| node_simulator_server
node_common_header -->|"precedes"| node_extra_header
node_extra_header -->|"telegram layout"| node_telegram_trailer
node_polling_messages -->|"uses layout"| node_common_header
node_polling_messages -->|"uses layout"| node_extra_header
node_deposit_messages -->|"uses layout"| node_common_header
node_deposit_messages -->|"uses layout"| node_extra_header
node_polling_handler -.->|"implements"| node_tx_handler_contract
node_deposit_handler -.->|"implements"| node_tx_handler_contract

click node_simulator_handler "https://github.com/hosung98/bank_tcp_exam/blob/main/BankSimulatorHandler.java"
click node_simulator_server "https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/simulator/BankSimulatorServer.java"
click node_length_framer "https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/framing/LengthPrefixedFramer.java"
click node_byte_codec "https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/codec/ByteCodec.java"
click node_common_header "https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/protocol/common/CommonHeader.java"
click node_extra_header "https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/protocol/common/ExtraHeader.java"
click node_telegram_trailer "https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/protocol/common/TelegramTrailer.java"
click node_polling_messages "https://github.com/hosung98/bank_tcp_exam/tree/main/src/main/java/com/example/bank_tcp_exam/protocol/tx/c0001"
click node_deposit_messages "https://github.com/hosung98/bank_tcp_exam/tree/main/src/main/java/com/example/bank_tcp_exam/protocol/tx/c2001"
click node_polling_handler "https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/simulator/handler/C0001_Handler.java"
click node_deposit_handler "https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/simulator/handler/C2001_Handler.java"
click node_tx_handler_contract "https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/simulator/handler/SimulatorTxHandler.java"
click node_application "https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/BankTcpExamApplication.java"

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_simulator_handler,node_simulator_server,node_length_framer,node_client_actor toneBlue
class node_byte_codec,node_common_header,node_extra_header,node_telegram_trailer toneAmber
class node_polling_messages,node_deposit_messages,node_polling_handler,node_deposit_handler,node_tx_handler_contract toneMint
class node_bank_actor toneIndigo
class node_application toneTeal
```

## Components

### Transport and dispatch

- [Telegram dispatcher](https://github.com/hosung98/bank_tcp_exam/blob/main/BankSimulatorHandler.java): `BankSimulatorHandler.java`
- [Simulator server](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/simulator/BankSimulatorServer.java): `src/main/java/com/example/bank_tcp_exam/simulator/BankSimulatorServer.java`
- [Length framer](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/framing/LengthPrefixedFramer.java): `src/main/java/com/example/bank_tcp_exam/framing/LengthPrefixedFramer.java`

### Telegram protocol

- [Byte codec](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/codec/ByteCodec.java): `src/main/java/com/example/bank_tcp_exam/codec/ByteCodec.java`
- [Common header](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/protocol/common/CommonHeader.java): `src/main/java/com/example/bank_tcp_exam/protocol/common/CommonHeader.java`
- [Extra header](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/protocol/common/ExtraHeader.java): `src/main/java/com/example/bank_tcp_exam/protocol/common/ExtraHeader.java`
- [Telegram trailer](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/protocol/common/TelegramTrailer.java): `src/main/java/com/example/bank_tcp_exam/protocol/common/TelegramTrailer.java`

### Transaction handling

- [Polling messages](https://github.com/hosung98/bank_tcp_exam/tree/main/src/main/java/com/example/bank_tcp_exam/protocol/tx/c0001): `src/main/java/com/example/bank_tcp_exam/protocol/tx/c0001`
- [Deposit messages](https://github.com/hosung98/bank_tcp_exam/tree/main/src/main/java/com/example/bank_tcp_exam/protocol/tx/c2001): `src/main/java/com/example/bank_tcp_exam/protocol/tx/c2001`
- [Polling handler](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/simulator/handler/C0001_Handler.java): `src/main/java/com/example/bank_tcp_exam/simulator/handler/C0001_Handler.java`
- [Deposit handler](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/simulator/handler/C2001_Handler.java): `src/main/java/com/example/bank_tcp_exam/simulator/handler/C2001_Handler.java`
- [Handler contract](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/simulator/handler/SimulatorTxHandler.java): `src/main/java/com/example/bank_tcp_exam/simulator/handler/SimulatorTxHandler.java`

### Other components

- **Institution client**
- **Bank peer**
- [Application entry](https://github.com/hosung98/bank_tcp_exam/blob/main/src/main/java/com/example/bank_tcp_exam/BankTcpExamApplication.java): `src/main/java/com/example/bank_tcp_exam/BankTcpExamApplication.java`

## Connections

- Institution client → Simulator server: sends telegrams
- Telegram dispatcher → Length framer: reads and writes (evidence: `BankSimulatorHandler.java`)
- Telegram dispatcher → Byte codec: decodes code (evidence: `BankSimulatorHandler.java`)
- Telegram dispatcher → Handler contract: dispatches to (evidence: `BankSimulatorHandler.java`)
- Simulator server → Telegram dispatcher: handles telegrams
- Bank peer → Simulator server: simulated peer (evidence: `README.md`)
- Common header → Extra header: precedes (evidence: `README.md`)
- Extra header → Telegram trailer: telegram layout (evidence: `README.md`)
- Polling messages → Common header: uses layout (evidence: `README.md`)
- Polling messages → Extra header: uses layout (evidence: `README.md`)
- Deposit messages → Common header: uses layout (evidence: `README.md`)
- Deposit messages → Extra header: uses layout (evidence: `README.md`)
- Polling handler → Handler contract: implements
- Deposit handler → Handler contract: implements
