Application architecture
22 questions in 7 subtopics.
Layered architecture
Describe a typical layered Spring application with controller, service and repository layers. Which rules keep the layers healthy?A Spring Boot application logs a warning aboutspring.jpa.open-in-view at startup. In production, one endpoint runs hundreds of SQL queries while serialising its JSON response, and database connections are held for long periods. Explain and fix.Design a reference service template for new Java services built by 30 teams. What does it include, and how do you keep existing services aligned as the template evolves?Layered architecture is the oldest style in enterprise Java, dating from three-tier J2EE applications. Why has it survived despite criticism, and when should an organisation move beyond it?Hexagonal and ports and adapters
Explain hexagonal architecture (ports and adapters). What is the difference between driving and driven adapters?Structure a Spring Boot payment service in hexagonal style. Describe the modules or packages, where Spring annotations are allowed, and how you enforce the structure.Several teams complain that the company's mandated hexagonal architecture adds four mapping layers to simple CRUD services and slows delivery. How do you respond as the architect who owns the standard?Is it worth designing a system's core to be independent of its frameworks, as hexagonal architecture suggests, when the system is expected to live 15 years? Use concrete migration history to argue.Clean architecture
A use case classPlaceOrderUseCase imports org.springframework.web.client.RestTemplate to call the inventory service and returns ResponseEntity<OrderDto>. Which architectural rule is broken, and how do you fix it?Explain clean architecture and its dependency rule. How does it differ from hexagonal and onion architecture?Modular monolith
Design a modular monolith in Spring Boot with enforced module boundaries for orders, inventory, billing and customers.Leadership asks you to split a one-million-line monolith into 60 microservices within a year. What do you propose instead, or how do you make it safe?Microservices became popular around 2014, and many organisations later consolidated services back into larger units. Looking back, what lessons do you take for choosing architecture styles over a decade?Package by feature
Compare package by layer with package by feature in a Spring codebase. Show an example structure and explain the benefits of package by feature.You must move a package-by-layer codebase of about 400 classes to package by feature without a big-bang change. How do you do it?Anti-patterns
Name common architecture anti-patterns in Spring applications and explain why each is harmful.Your microservices must be deployed together, a single user request triggers a chain of seven synchronous calls, and a schema change in one service breaks three others. Diagnose the situation and propose changes.Design architecture fitness functions that prevent architecture anti-patterns across 50 repositories owned by different teams.How do you design architecture governance for an engineering organisation that will last for years without becoming a bottleneck or being ignored?DTO and bean mapping
Why should a Spring REST API return DTOs instead of JPA entities, and what are the options for mapping between them: hand-written code, records with factory methods, MapStruct orModelMapper?Write a MapStruct mapper from Order (with Customer and a list of OrderLine entities) to OrderDto (customerName, lineCount, total). Make the build fail if a target field is not mapped, and explain how you test it.Teams complain that each request passes through four mapping steps (API DTO, command, domain object, entity) and mapping code is a third of the codebase. As the architecture lead, how do you decide how many models and mappings a service should have?No question matches these choices.