How mosamatirmizi/java_interview_test works
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: TransactionService.java Transaction Service · BankingApplication.java Banking API · docker-compose.yml Docker Compose · AccountController.java Account API
Components 19
Banking API
Spring Boot backend in the repo root
- Banking API · Main banking backend exposed on port 8080
src/main/java/net/mblb/banking/BankingApplication.java - Account API · HTTP entry point for account operations
src/main/java/net/mblb/banking/account/AccountController.java - Account Service · Account business logic
src/main/java/net/mblb/banking/account/AccountService.java - Account Repo · Persistence boundary for accounts
src/main/java/net/mblb/banking/account/AccountRepository.java - Account DTOs · Account request and response contracts
src/main/java/net/mblb/banking/account/model - Transaction API · HTTP entry point for transaction operations
src/main/java/net/mblb/banking/transaction/TransactionController.java - Transaction Service · Transaction business logic and orchestration
src/main/java/net/mblb/banking/transaction/TransactionService.java - Transaction Repo · Persistence boundary for transactions
src/main/java/net/mblb/banking/transaction/TransactionRepository.java - Transaction DTOs · Transaction request and response contracts
src/main/java/net/mblb/banking/transaction/model - Domain Model · Core banking entities and paged result model
src/main/java/net/mblb/banking/domain - Exchange Client · Outbound integration to exchange-rate service
src/main/java/net/mblb/banking/exchangerate/ExchangeRateClient.java - Error Boundary · Centralized API error translation
src/main/java/net/mblb/banking/exception
Support Services
External HTTP dependencies and local infrastructure
- Exchange-rate API · Node/Express exchange-rate service exposed on port 8081
exchange-rate-api/server.js - Exchange Swagger · Swagger/OpenAPI surface for the exchange-rate API
exchange-rate-api/swagger.js - Echo Server · Small supporting HTTP target on port 3000
echo-server/EchoServer.java - Postgres · Primary persistence store on port 5432
src/main/resources/application.yaml
Tooling
Manual testing and automated checks
- Docker Compose · Local multi-service stack orchestration
docker-compose.yml - REST Clients · HTTP request collections for local verification
rest-client - Service Tests · Focused business-logic tests for account and transaction services
src/test/java/net/mblb/banking
Connections 26
- 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