# mosamatirmizi/java_interview_test architecture

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

- Interactive diagram: https://gitdiagram.com/mosamatirmizi/java_interview_test
- Repository: https://github.com/mosamatirmizi/java_interview_test

## Overview

1. **Repository split**
   - This repo has three runtime components:
     - a **Spring Boot 3 / Java backend** in the repo root,
     - a **Node/Express exchange-rate API** in `exchange-rate-api`,
     - a small **echo server** in `echo-server`.
   - The architecture is service-oriented: the Spring Boot app is the main system, and the other two services support it as external HTTP dependencies.

2. **Primary backend boundary**
   - The root Gradle project is the main **Banking API** exposed on port **8080**.
   - It provides REST endpoints for banking functionality and is the system under test for the included service tests and REST client samples.

3. **Layered Spring Boot structure**
   - The Java backend is organized into clear layers:
     - `...account` and `...transaction` controllers for HTTP entry points,
     - corresponding services for business logic,
     - repositories for persistence,
     - `domain` objects for core entities,
     - request/response DTOs under each feature’s `model` package.
   - This is a classic controller-service-repository design, with feature-based packaging.

4. **Domain model**
   - The main domain objects are `Account`, `Transaction`, and `PagedResult`.
   - DTOs such as `AccountCreateRequest`, `AccountUpdateRequest`, `TransactionCreateRequest`, and their response counterparts define the API contract separately from persistence/domain types.

5. **Persistence and database**
   - The Spring app persists data to **Postgres** on port **5432**.
   - `AccountRepository` and `TransactionRepository` are the persistence boundary.
   - `src/main/resources/data.sql` suggests initial seed data or local bootstrap data for the database.

6. **Business flow**
   - API requests enter through controllers, move into services, and then into repositories.
   - The transaction area likely coordinates more than one dependency: it manages transaction state internally and may enrich or validate data using exchange-rate information.
   - The presence of `ExchangeRateClient` in the Spring app shows an outbound HTTP dependency from banking logic to the exchange-rate service.

7. **External exchange-rate dependency**
   - `src/main/java/.../exchangerate/ExchangeRateClient.java` is the integration boundary to the separate exchange-rate service.
   - The Node/Express service in `exchange-rate-api` runs on port **8081** and exposes its own Swagger docs.
   - This is a separate deployable unit, not just a library, so architecture diagrams should show it as an external HTTP service.

8. **Support services**
   - `echo-server` runs on port **3000** and is likely a minimal HTTP target for connectivity or integration testing.
   - It is part of the Dockerized environment rather than the main banking domain, so it should be shown as a supporting utility service.

9. **Error handling**
   - `BankingException`, `ApiErrorCode`, and `GlobalExceptionHandler` define a centralized API error boundary.
   - This indicates that domain/service failures are translated into structured HTTP responses at the edge rather than leaking internal exceptions.

10. **API documentation and manual testing**
   - Both APIs expose **Swagger/OpenAPI** UIs, which means the HTTP contract is a first-class part of the system.
   - `rest-client/*.http` contains manual request collections for the banking API and exchange-rate API, which supports interactive testing and local verification.

11. **Runtime and infrastructure**
   - The repo is designed to run either via `./gradlew bootRun` for the Spring app or via `docker compose` for the full stack.
   - Docker Compose orchestrates the runtime dependencies: banking backend, exchange-rate API, echo server, and Postgres.
   - `devcontainer` and Dockerfiles indicate the project is optimized for container-based local development.

12. **Test scope**
   - Tests are concentrated in service-layer classes such as `AccountServiceTest` and `TransactionServiceTest`.
   - That suggests the core correctness boundary is business logic, with controllers and infrastructure treated as thinner adapters.

Main entry points: [`src/main/java/net/mblb/banking/transaction/TransactionService.java`](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/transaction/TransactionService.java) (Transaction Service), [`src/main/java/net/mblb/banking/BankingApplication.java`](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/BankingApplication.java) (Banking API), [`docker-compose.yml`](https://github.com/mosamatirmizi/java_interview_test/blob/main/docker-compose.yml) (Docker Compose), [`src/main/java/net/mblb/banking/account/AccountController.java`](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/account/AccountController.java) (Account API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_banking["Banking API"]
  node_banking_app["Banking API<br/>spring-boot app"]
  node_account_controller["Account API<br/>rest controller"]
  node_account_service["Account Service"]
  node_account_repo[("Account Repo")]
  node_account_dto["Account DTOs<br/>api models"]
  node_transaction_controller["Transaction API<br/>rest controller"]
  node_transaction_service["Transaction Service"]
  node_transaction_repo[("Transaction Repo")]
  node_transaction_dto["Transaction DTOs<br/>api models"]
  node_domain_model["Domain Model<br/>entities"]
  node_exchange_client["Exchange Client<br/>http client"]
  node_error_boundary["Error Boundary<br/>exception handling"]
end

subgraph group_support["Support Services"]
  node_exchange_api["Exchange-rate API<br/>node service<br/>[server.js]"]
  node_exchange_swagger["Exchange Swagger<br/>openapi docs<br/>[swagger.js]"]
  node_echo_server["Echo Server<br/>http service<br/>[EchoServer.java]"]
  node_postgres_db[("Postgres<br/>database<br/>[application.yaml]")]
end

subgraph group_tooling["Tooling"]
  node_docker_compose["Docker Compose<br/>runtime orchestration<br/>[docker-compose.yml]"]
  node_rest_clients["REST Clients<br/>manual test scripts"]
  node_service_tests["Service Tests<br/>test suite"]
end

node_banking_app -->|"hosts"| node_account_controller
node_banking_app -->|"hosts"| node_transaction_controller
node_banking_app -->|"wires"| node_error_boundary
node_account_controller -->|"calls"| node_account_service
node_account_controller -->|"uses"| node_account_dto
node_account_service -->|"persists via"| node_account_repo
node_account_service -->|"uses"| node_domain_model
node_account_repo -->|"stores in"| node_postgres_db
node_transaction_controller -->|"calls"| node_transaction_service
node_transaction_controller -->|"uses"| node_transaction_dto
node_transaction_service -->|"persists via"| node_transaction_repo
node_transaction_service -->|"enriches with"| node_exchange_client
node_transaction_service -->|"uses"| node_domain_model
node_transaction_repo -->|"stores in"| node_postgres_db
node_exchange_client -->|"calls"| node_exchange_api
node_exchange_api -->|"documents"| node_exchange_swagger
node_error_boundary -->|"handles"| node_account_controller
node_error_boundary -->|"handles"| node_transaction_controller
node_docker_compose -->|"orchestrates"| node_banking_app
node_docker_compose -->|"orchestrates"| node_exchange_api
node_docker_compose -->|"orchestrates"| node_echo_server
node_docker_compose -->|"orchestrates"| node_postgres_db
node_rest_clients -->|"targets"| node_banking_app
node_rest_clients -->|"targets"| node_exchange_api
node_service_tests -->|"verifies"| node_account_service
node_service_tests -->|"verifies"| node_transaction_service

click node_banking_app "https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/BankingApplication.java"
click node_account_controller "https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/account/AccountController.java"
click node_account_service "https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/account/AccountService.java"
click node_account_repo "https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/account/AccountRepository.java"
click node_account_dto "https://github.com/mosamatirmizi/java_interview_test/tree/main/src/main/java/net/mblb/banking/account/model"
click node_transaction_controller "https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/transaction/TransactionController.java"
click node_transaction_service "https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/transaction/TransactionService.java"
click node_transaction_repo "https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/transaction/TransactionRepository.java"
click node_transaction_dto "https://github.com/mosamatirmizi/java_interview_test/tree/main/src/main/java/net/mblb/banking/transaction/model"
click node_domain_model "https://github.com/mosamatirmizi/java_interview_test/tree/main/src/main/java/net/mblb/banking/domain"
click node_exchange_client "https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/exchangerate/ExchangeRateClient.java"
click node_error_boundary "https://github.com/mosamatirmizi/java_interview_test/tree/main/src/main/java/net/mblb/banking/exception"
click node_exchange_api "https://github.com/mosamatirmizi/java_interview_test/blob/main/exchange-rate-api/server.js"
click node_exchange_swagger "https://github.com/mosamatirmizi/java_interview_test/blob/main/exchange-rate-api/swagger.js"
click node_echo_server "https://github.com/mosamatirmizi/java_interview_test/blob/main/echo-server/EchoServer.java"
click node_postgres_db "https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/resources/application.yaml"
click node_docker_compose "https://github.com/mosamatirmizi/java_interview_test/blob/main/docker-compose.yml"
click node_rest_clients "https://github.com/mosamatirmizi/java_interview_test/tree/main/rest-client"
click node_service_tests "https://github.com/mosamatirmizi/java_interview_test/tree/main/src/test/java/net/mblb/banking"

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_banking_app,node_account_controller,node_account_service,node_account_repo,node_account_dto,node_transaction_controller,node_transaction_service,node_transaction_repo,node_transaction_dto,node_domain_model,node_exchange_client,node_error_boundary toneBlue
class node_exchange_api,node_exchange_swagger,node_echo_server,node_postgres_db toneAmber
class node_docker_compose,node_rest_clients,node_service_tests toneMint
```

## Components

### Banking API

Spring Boot backend in the repo root

- [Banking API](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/BankingApplication.java): spring-boot app · Main banking backend exposed on port 8080 · `src/main/java/net/mblb/banking/BankingApplication.java`
- [Account API](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/account/AccountController.java): rest controller · HTTP entry point for account operations · `src/main/java/net/mblb/banking/account/AccountController.java`
- [Account Service](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/account/AccountService.java): service · Account business logic · `src/main/java/net/mblb/banking/account/AccountService.java`
- [Account Repo](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/account/AccountRepository.java): repository · Persistence boundary for accounts · `src/main/java/net/mblb/banking/account/AccountRepository.java`
- [Account DTOs](https://github.com/mosamatirmizi/java_interview_test/tree/main/src/main/java/net/mblb/banking/account/model): api models · Account request and response contracts · `src/main/java/net/mblb/banking/account/model`
- [Transaction API](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/transaction/TransactionController.java): rest controller · HTTP entry point for transaction operations · `src/main/java/net/mblb/banking/transaction/TransactionController.java`
- [Transaction Service](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/transaction/TransactionService.java): service · Transaction business logic and orchestration · `src/main/java/net/mblb/banking/transaction/TransactionService.java`
- [Transaction Repo](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/transaction/TransactionRepository.java): repository · Persistence boundary for transactions · `src/main/java/net/mblb/banking/transaction/TransactionRepository.java`
- [Transaction DTOs](https://github.com/mosamatirmizi/java_interview_test/tree/main/src/main/java/net/mblb/banking/transaction/model): api models · Transaction request and response contracts · `src/main/java/net/mblb/banking/transaction/model`
- [Domain Model](https://github.com/mosamatirmizi/java_interview_test/tree/main/src/main/java/net/mblb/banking/domain): entities · Core banking entities and paged result model · `src/main/java/net/mblb/banking/domain`
- [Exchange Client](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/java/net/mblb/banking/exchangerate/ExchangeRateClient.java): http client · Outbound integration to exchange-rate service · `src/main/java/net/mblb/banking/exchangerate/ExchangeRateClient.java`
- [Error Boundary](https://github.com/mosamatirmizi/java_interview_test/tree/main/src/main/java/net/mblb/banking/exception): exception handling · Centralized API error translation · `src/main/java/net/mblb/banking/exception`

### Support Services

External HTTP dependencies and local infrastructure

- [Exchange-rate API](https://github.com/mosamatirmizi/java_interview_test/blob/main/exchange-rate-api/server.js): node service · Node/Express exchange-rate service exposed on port 8081 · `exchange-rate-api/server.js`
- [Exchange Swagger](https://github.com/mosamatirmizi/java_interview_test/blob/main/exchange-rate-api/swagger.js): openapi docs · Swagger/OpenAPI surface for the exchange-rate API · `exchange-rate-api/swagger.js`
- [Echo Server](https://github.com/mosamatirmizi/java_interview_test/blob/main/echo-server/EchoServer.java): http service · Small supporting HTTP target on port 3000 · `echo-server/EchoServer.java`
- [Postgres](https://github.com/mosamatirmizi/java_interview_test/blob/main/src/main/resources/application.yaml): database · Primary persistence store on port 5432 · `src/main/resources/application.yaml`

### Tooling

Manual testing and automated checks

- [Docker Compose](https://github.com/mosamatirmizi/java_interview_test/blob/main/docker-compose.yml): runtime orchestration · Local multi-service stack orchestration · `docker-compose.yml`
- [REST Clients](https://github.com/mosamatirmizi/java_interview_test/tree/main/rest-client): manual test scripts · HTTP request collections for local verification · `rest-client`
- [Service Tests](https://github.com/mosamatirmizi/java_interview_test/tree/main/src/test/java/net/mblb/banking): test suite · Focused business-logic tests for account and transaction services · `src/test/java/net/mblb/banking`

## Connections

- Banking API → Account API: hosts · Bootstraps account HTTP endpoints
- Banking API → Transaction API: hosts · Bootstraps transaction HTTP endpoints
- Banking API → Error Boundary: wires · Registers centralized exception handling
- Account API → Account Service: calls · Delegates account operations to business logic
- Account API → Account DTOs: uses · Accepts and returns account API models
- Account Service → Account Repo: persists via · Reads and writes account state
- Account Service → Domain Model: uses · Operates on core account entities
- Account Repo → Postgres: stores in · Persists account data in Postgres
- Transaction API → Transaction Service: calls · Delegates transaction operations to business logic
- Transaction API → Transaction DTOs: uses · Accepts and returns transaction API models
- Transaction Service → Transaction Repo: persists via · Reads and writes transaction state
- Transaction Service → Exchange Client: enriches with · Looks up exchange rates during transaction processing
- Transaction Service → Domain Model: uses · Operates on core transaction entities
- Transaction Repo → Postgres: stores in · Persists transaction data in Postgres
- Exchange Client → Exchange-rate API: calls · Consumes the external exchange-rate HTTP API
- Exchange-rate API → Exchange Swagger: documents · Publishes an OpenAPI surface for the service
- Error Boundary → Account API: handles · Maps account-layer failures to HTTP responses
- Error Boundary → Transaction API: handles · Maps transaction-layer failures to HTTP responses
- Docker Compose → Banking API: orchestrates · Starts the main backend in the local stack
- Docker Compose → Exchange-rate API: orchestrates · Starts the exchange-rate dependency
- Docker Compose → Echo Server: orchestrates · Starts the supporting echo service
- Docker Compose → Postgres: orchestrates · Provides the database dependency
- REST Clients → Banking API: targets · Manual requests for the banking API
- REST Clients → Exchange-rate API: targets · Manual requests for the exchange-rate API
- Service Tests → Account Service: verifies · Tests account business logic
- Service Tests → Transaction Service: verifies · Tests transaction business logic
