Quick revision
The short answer
Automated architecture tests are the guard rail: they check every commit, which design reviews cannot do consistently, but they only encode decisions that people have already made. Design reviews are where those decisions are made and changed, and team structure shapes the architecture more than either, so modules should line up with the teams that own them. Rules should stay few, documented and owned, and be revisited whenever the architecture changes on purpose.
What to remember
In this answer, we saw that automated architecture tests catch erosion at every commit, which reviews cannot do consistently, but that they only encode decisions that design reviews make. Team structure shapes the architecture most strongly, so modules should align with their owners. Rules should be few, documented and owned, and must be revisited whenever the architecture changes intentionally, so that reviews, rules and teams reinforce each other.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Automated architecture tests are the guard rail: they check every commit, which design reviews cannot do consistently, but they only encode decisions that people have already made. Design reviews are where those decisions are made and changed, and team structure shapes the architecture more than either, so modules should line up with the teams that own them. Rules should stay few, documented and owned, and be revisited whenever the architecture changes on purpose.
Why this question is asked
Every long-lived code base tells the same story. The first design is clear, then deadlines, new people and new features slowly blur it, until the diagram on the wiki no longer describes the system. This is architecture erosion, and it rarely comes from one bad decision; it comes from hundreds of small, reasonable shortcuts. Interviewers ask this at the most senior level because the answer is not a tool choice but a view of how architecture survives in an organisation. In this answer, we will look at why erosion happens, what automated tests are good and bad at, what design reviews add, why team structure matters most, how to keep rules healthy, and how the three fit together.
1Why Architecture Erodes
Architecture, in practice, is a set of decisions about what may depend on what: the order service does not read the billing tables, controllers do not talk to repositories, the payments module has one public API. Each decision is easy to follow when it is fresh and everyone remembers why it was made.
Over years, three forces wear it down. People leave and new people do not know the reasons. Deadlines make a direct call into another module's internals look cheaper than doing it properly. And reviews look at changes one at a time, so a single shortcut looks harmless even when it is the twentieth of its kind. None of these is solved by better intentions, which is why we need mechanisms.
2What Automated Rules Do Well, and What They Cannot Do
Automated architecture tests, written with ArchUnit or Spring Modulith, check every commit on every branch, in seconds, without getting tired. A reviewer may miss a new import of an internal class among 400 changed lines; the test never does. That consistency is something no human process can match, and it is the main reason to have them. They also make decisions visible: a rule with a clear because() message teaches the next developer the design at the exact moment they are about to break it.
But a rule can only enforce a decision someone already made. It cannot tell us whether the module boundaries are right, whether a new feature belongs in orders or in a new module, or whether a rule has become an obstacle. Rules also only cover what is easy to express as dependencies; much of architecture, such as data ownership or how services handle failure, does not show up in imports at all. So automated tests are a guard rail, not a designer.
3What Design Reviews Add
Design reviews, whether a lightweight architecture decision record for a pull request or a meeting for a large change, are where decisions are made, explained and changed. They bring judgement: someone asks whether a new dependency is a sign that two modules should merge, or whether a feature crosses a boundary in a way that will hurt later.
Their weakness is the opposite of automated tests. They happen occasionally, depend on who is in the room, and cannot check every commit. So the two need each other: reviews decide, and the outcome of a review that changes a boundary should usually be a new or changed rule, so the decision keeps being enforced after everyone has forgotten the meeting.
4Why Team Structure Matters Most
There is a well-known observation, Conway's law, that systems tend to mirror the communication structure of the organisations that build them. If one team owns both orders and billing, the boundary between them will blur no matter what the rules say, because the team will treat them as one thing. If two teams share one module, it will grow a hidden internal boundary between their parts, or become a battleground.
So the strongest protection for a module boundary is a team boundary: each module has one owning team, and other teams reach it only through its published API. When the organisation changes, the architecture should be reviewed with it. In practice this means checking, at every reorganisation, which modules each team owns, and treating a module with no owner, or with three, as an architecture problem. CODEOWNERS files make the ownership explicit in the repository.
- Team structureone owning team per module; shapes everything below
- Design reviews and decision recordsmake, explain and change the decisions
- Automated architecture rulesenforce the decisions on every commit
- The codewhat actually exists
4 layers, from the top down. Step through them one at a time.
Each layer protects the one below it; rules alone cannot hold an architecture the teams do not share.
5Keeping the Rules Healthy
Rules decay too. A suite of 70 architecture rules, half of which nobody understands, will be suppressed, frozen forever, or deleted in frustration. So I would keep the set small, perhaps ten to twenty rules for a large system, each one documented with its reason and an owner who can answer questions about it. Every rule should earn its place by protecting a decision that matters.
When the architecture changes on purpose, for example when two modules merge or a module is extracted into a service, the rules must change in the same piece of work. A rule that describes last year's architecture is worse than no rule, because it teaches people that rules are obstacles to route around. A short review of the rules once or twice a year, looking at which ones have frozen violations that never go down, keeps them aligned with reality.
6Putting It Together With an Example
Imagine a ten-year-old insurance platform where the claims module calls deep into policy internals in 150 places. A design review decides that policy should expose a small API and publish events, and that claims will use only those. The review produces a decision record and an ArchUnit rule forbidding access to policy internals, frozen at 150 violations. The policy team owns the API; the claims team owns the migration. The count is reported each sprint and falls to zero over three months, at which point the rule becomes strict. Without the review, nobody would have agreed the target; without the rule, new shortcuts would have appeared during the migration; without clear ownership, the API would not have been maintained.
7Follow-up questions
Should architecture rules ever block a release?
Strict rules fail the build like any test, so in effect yes, for new violations. That is acceptable because they are few and well understood. In an emergency, a reviewed entry in the frozen store is a better escape hatch than disabling the rule, because it keeps the debt visible.
Who should own the architecture rules?
Each rule should have an owner, usually the team that owns the boundary it protects, with an architecture group owning the shared conventions. Ownership means answering questions, updating the rule when the design changes, and deciding exceptions.
How do we know if the architecture is eroding?
Trends tell us more than snapshots: the number of frozen violations over time, the number of dependencies between modules, how often changes touch several modules at once, and how long features that cross modules take. Rising numbers are a prompt for a design review, not just for more rules.
8Conclusion
In this answer, we saw that automated architecture tests catch erosion at every commit, which reviews cannot do consistently, but that they only encode decisions that design reviews make. Team structure shapes the architecture most strongly, so modules should align with their owners. Rules should be few, documented and owned, and must be revisited whenever the architecture changes intentionally, so that reviews, rules and teams reinforce each other.
Open with
I see three mechanisms with different jobs. Automated architecture tests, with ArchUnit or Spring Modulith, are the guard rail: they check every commit in seconds and never get tired, so they catch the hundreds of small shortcuts that cause erosion and that reviews will miss.
Then, if they want more
But they only encode decisions someone already made; they cannot tell us whether the boundaries are right. That is what design reviews and decision records are for: they make and change the decisions, and when a review changes a boundary, the outcome should be a new or updated rule, so the decision keeps being enforced.
The strongest force, though, is team structure. Systems mirror the organisations that build them, so I want each module to have one owning team that publishes its API, and I review module ownership whenever the organisation changes.
I keep the rules few, maybe ten to twenty for a large system, each with a reason and an owner, because a large set of rules nobody understands gets suppressed or deleted.
And whenever we change the architecture on purpose, the rules change in the same piece of work, otherwise they describe last year's system and people learn to route around them.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Maven guides, Gradle user manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Over a long-lived codebase, architecture tends to erode. What role should automated...": https://scrivio-interview-library.netlify.app/java/code-quality-tools/a64772cd71/