# pqkkkkk/tsbank architecture

> Architecture diagram of the GitHub repository pqkkkkk/tsbank, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pqkkkkk/tsbank
- Repository: https://github.com/pqkkkkk/tsbank

## Overview

##### Project type and purpose
- This is a layered, full‑stack “online banking” system implemented in Java/Maven, following Clean Architecture (aka Hexagonal/Ports‑and‑Adapters).
- Core features: account creation, deposit/withdrawal, transfers, transaction history, event publishing (Kafka), persistence (in‑memory/SQL Server), and a REST API.

##### File structure
- Top‑level modules (Maven multimodule):
- entity: domain entities (BankAccount, Customer, Transaction, TransactionType)
- usecase: business‑logic services (BankAccountService, TransactionService) + use‑case interfaces (IBankAccountService, ITransactionService) + DAO ports (IBankAccountDao, ICustomerDao, ITransactionDao)
- infrastructure‑dao‑inmemory & infrastructure‑dao‑sqlserver: outbound adapters implementing DAO interfaces, one in‑memory, one JDBC/SQLServer (with DataSourceConfig, row‑mappers, SQL scripts)
- infrastructure‑kafka: outbound adapter for event publishing/handling via Kafka (IEventPublisher, IEventHandler, KafkaConfig, event types)
- infrastructure‑restapi: inbound adapter (Spring Boot REST controllers, DTOs, application.properties, tests)
- A root pom.xml aggregates these modules.

##### README
- Confirms: “Core functions of online banking system. Build according Clean architecture.”

##### Detailed checklist
- Center: Domain Entities (BankAccount, Customer, Transaction)
- Next ring: Use‑Case Services (BankAccountService, TransactionService), DAO Ports (IBankAccountDao, ITransactionDao, ICustomerDao), Event Port (IEventPublisher)
- Outer ring:
- infrastructure‑dao‑inmemory: implements DAO Ports → in‑memory store
- infrastructure‑dao‑sqlserver: implements DAO Ports → SQLServer DB
- infrastructure‑kafka: implements IEventPublisher & IEventHandler → Kafka Broker
- infrastructure‑restapi: Controllers (AccountController), DTOs → calls Use‑Case
- External: SQL Server instance, Kafka cluster, REST clients (Postman, Web UI)
- REST Client → REST API controller
- Controller → Use‑Case interface
- Use‑Case → DAO port
- DAO adapter → Database or in‑memory store
- Use‑Case / Controller → Kafka publisher → Kafka broker
- Kafka broker → Kafka event handler adapter → Use‑Case (if applicable)

## Diagram (Mermaid)

```mermaid
graph TB
subgraph "Center"
 Domain["Domain Entities\n(BankAccount, Customer, Transaction)"]:::domain
end

subgraph "Use-Case Layer"
 Services["Services\n(BankAccountService,\nTransactionService)"]:::usecase
 DAOPorts["DAO Ports\n(IBankAccountDao,\nITransactionDao,\nICustomerDao)"]:::interface
 EventPort["Event Port\n(IEventPublisher)"]:::interface
end

subgraph "Adapters"
 subgraph "In-Memory DAO Adapter"
  InMemoryDAO["In-Memory DAO Adapter"]:::adapter
 end
 subgraph "SQLServer DAO Adapter"
  SQLServerDAO["SQLServer DAO Adapter"]:::adapter
  DataSourceConfig["DataSourceConfig.java"]:::adapter
  RowMappers["Row Mappers"]:::adapter
  SQLScripts["SQL Scripts"]:::adapter
  SQLServerDAO --> DataSourceConfig
  SQLServerDAO --> RowMappers
  SQLServerDAO --> SQLScripts
 end
 subgraph "Kafka Adapter"
  KafkaAdapter["Kafka Adapter"]:::adapter
  KafkaInterfaces["Interfaces\n(IEventPublisher, IEventHandler)"]:::interface
  KafkaConfig["KafkaConfig.java"]:::adapter
  KafkaImpl["Impl\n(KafkaEventPublisherV1,\nKafkaEventHandlerV1)"]:::adapter
  KafkaModels["Event Models"]:::adapter
  KafkaAdapter --> KafkaInterfaces
  KafkaAdapter --> KafkaConfig
  KafkaAdapter --> KafkaImpl
  KafkaAdapter --> KafkaModels
 end
 subgraph "REST API Adapter"
  RESTAPI["REST API Adapter\n(Spring Boot Controllers,\nDTOs)"]:::adapter
  AppEntry["InfrastructureRestapiApplication.java"]:::adapter
  Controllers["AccountController.java"]:::adapter
  DTOReq["DTOs Request"]:::adapter
  DTORes["DTOs Response"]:::adapter
  Prop["application.properties"]:::adapter
  RESTAPI --> AppEntry
  RESTAPI --> Controllers
  RESTAPI --> DTOReq
  RESTAPI --> DTORes
  RESTAPI --> Prop
 end
end

subgraph "External Systems"
 RestClient["REST Clients\n(Postman, UI)"]:::external
 SQLDB["SQL Server DB"]:::external
 KafkaBroker["Kafka Broker"]:::external
end

RestClient --> RESTAPI
RESTAPI --> Services
Services --> DAOPorts
DAOPorts --> InMemoryDAO
DAOPorts --> SQLServerDAO
SQLServerDAO --> SQLDB
Services --> KafkaAdapter
KafkaAdapter --> KafkaBroker
KafkaBroker --> KafkaAdapter
KafkaAdapter --> Services

click Domain "https://github.com/pqkkkkk/tsbank/tree/main/entity/src/main/java/com/example/entity"
click Services "https://github.com/pqkkkkk/tsbank/tree/main/usecase/src/main/java/com/example/usecase"
click DAOPorts "https://github.com/pqkkkkk/tsbank/tree/main/usecase/src/main/java/com/example/usecase/dao"
click InMemoryDAO "https://github.com/pqkkkkk/tsbank/tree/main/infrastructure-dao-inmemory/src/main/java/com/example/infrastructure/dao/inmemory"
click SQLServerDAO "https://github.com/pqkkkkk/tsbank/tree/main/infrastructure-dao-sqlserver/src/main/java/com/example/infrastructure/dao/sqlserver"
click DataSourceConfig "https://github.com/pqkkkkk/tsbank/blob/main/infrastructure-dao-sqlserver/src/main/java/com/example/infrastructure/dao/sqlserver/config/DataSourceConfig.java"
click RowMappers "https://github.com/pqkkkkk/tsbank/tree/main/infrastructure-dao-sqlserver/src/main/java/com/example/infrastructure/dao/sqlserver/rowmapper"
click SQLScripts "https://github.com/pqkkkkk/tsbank/tree/main/infrastructure-dao-sqlserver/src/main/resources"
click KafkaInterfaces "https://github.com/pqkkkkk/tsbank/blob/main/infrastructure-kafka/src/main/java/com/example/infrastructure/kafka/IEventPublisher.java"
click KafkaConfig "https://github.com/pqkkkkk/tsbank/blob/main/infrastructure-kafka/src/main/java/com/example/infrastructure/kafka/KafkaConfig.java"
click KafkaImpl "https://github.com/pqkkkkk/tsbank/blob/main/infrastructure-kafka/src/main/java/com/example/infrastructure/kafka/KafkaEventPublisherV1.java"
click KafkaModels "https://github.com/pqkkkkk/tsbank/tree/main/infrastructure-kafka/src/main/java/com/example/infrastructure/kafka/event"
click AppEntry "https://github.com/pqkkkkk/tsbank/blob/main/infrastructure-restapi/src/main/java/com/example/InfrastructureRestapiApplication.java"
click Controllers "https://github.com/pqkkkkk/tsbank/blob/main/infrastructure-restapi/src/main/java/com/example/controller/AccountController.java"
click DTOReq "https://github.com/pqkkkkk/tsbank/tree/main/infrastructure-restapi/src/main/java/com/example/dto/request"
click DTORes "https://github.com/pqkkkkk/tsbank/tree/main/infrastructure-restapi/src/main/java/com/example/dto/response"
click Prop "https://github.com/pqkkkkk/tsbank/blob/main/infrastructure-restapi/src/main/resources/application.properties"
click RestClient "https://github.com/pqkkkkk/tsbank/blob/main/pom.xml"

classDef domain fill:#e0f7e9,stroke:#333,stroke-width:1px
classDef usecase fill:#e0f7e9,stroke:#333,stroke-width:1px
classDef adapter fill:#d0eaff,stroke:#333,stroke-width:1px
classDef interface stroke-dasharray: 5 5,fill:#ffffff,stroke:#333
classDef external fill:#f0f0f0,stroke:#333,stroke-width:1px
```
