Scrivio Interview library

Application architecture

22 questions in 7 subtopics.

Layered architecture

ConceptFoundations6 min read
Describe a typical layered Spring application with controller, service and repository layers. Which rules keep the layers healthy?
DebuggingIntermediate7 min read
A Spring Boot application logs a warning about spring.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.
DesignAdvanced7 min read
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?
LeadershipPrincipal6 min read
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

ConceptFoundations6 min read
Explain hexagonal architecture (ports and adapters). What is the difference between driving and driven adapters?
DesignIntermediate7 min read
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.
ScenarioAdvanced6 min read
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?
LeadershipPrincipal6 min read
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

DebuggingFoundations6 min read
A use case class PlaceOrderUseCase 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?
ConceptIntermediate6 min read
Explain clean architecture and its dependency rule. How does it differ from hexagonal and onion architecture?

Modular monolith

DesignIntermediate7 min read
Design a modular monolith in Spring Boot with enforced module boundaries for orders, inventory, billing and customers.
LeadershipAdvanced7 min read
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?
LeadershipPrincipal6 min read
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

ConceptFoundations5 min read
Compare package by layer with package by feature in a Spring codebase. Show an example structure and explain the benefits of package by feature.
ScenarioIntermediate7 min read
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

ConceptFoundations6 min read
Name common architecture anti-patterns in Spring applications and explain why each is harmful.
DebuggingIntermediate7 min read
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.
DesignAdvanced6 min read
Design architecture fitness functions that prevent architecture anti-patterns across 50 repositories owned by different teams.
LeadershipPrincipal7 min read
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

ConceptFoundations7 min read
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 or ModelMapper?
CodingIntermediate7 min read
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.
DesignAdvanced7 min read
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?