Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

How would you decide between one large multi-module repository and separate repositories per service for 30 Spring Boot services owned by six teams?

A multi-module monorepo gives atomic changes across modules and one version of shared code, but the build grows and needs selective building, code owners and CI that scales. Separate repositories give each team its own release cadence and clear ownership, but shared code must be published as versioned artifacts and kept compatible with a BOM, update bots and tests. We decide from team boundaries and how independently services deploy, not from tool preference, and we avoid putting independently deployed services into one reactor with a single shared version.

Why this question is asked

Where the code lives shapes how six teams work every day: how a shared library change reaches 30 services, how long a pull request build takes, and who can break whose build. Getting it wrong is expensive, because moving 30 services between layouts later takes months. Interviewers ask this design question to see whether we reason from the organisation's needs rather than from a fashion. In this answer, we will recap the two layouts, look at what each one costs in practice, see what each needs to work well, and end with how we would decide for 30 services and six teams.

1A Quick Recap of the Two Layouts

In a monorepo, all 30 services and the shared libraries live in one Git repository. With Maven, they are usually modules of one or several multi-module builds, so a change to a shared library and the services that use it can be made in one commit and built together by the reactor.

In a polyrepo layout, each service has its own repository, and shared code lives in its own library repositories. A service uses a shared library the same way it uses any third-party library: by depending on a released version, such as acme-security 3.4.0, downloaded from the company repository manager.

Both layouts work at large scale, and both fail when their costs are ignored. So the useful question is which set of costs suits our six teams.

2What a Monorepo Gives and What It Costs

The main gift of a monorepo is the atomic change. Suppose we rename a method in the shared security library. In one pull request we change the library and all 30 callers, the build compiles everything together, and there is never a moment where some services use the old API and some the new one. There is also only one version of shared code, so 'which version of the library does payments use?' is never a question.

The cost is that the build grows with the company. Without care, every pull request builds and tests all 30 services, and the build time we saw in smaller projects becomes an hour. So a monorepo needs affected-module detection (build only what a change touches and what depends on it, for example with mvn -pl and -amd), a CODEOWNERS file so the right team reviews changes to its directories, and CI infrastructure that scales with parallel agents and caching. It also makes it easy for teams to reach into each other's internals, so we need module boundaries enforced by the build.

3What Separate Repositories Give and What They Cost

Separate repositories give each team clear ownership and an independent release cadence. The orders team can release ten times a day without waiting for the payments build, and a broken test in one service blocks nobody else. Builds stay small and fast without special tooling.

The cost moves to version management. Shared code must be released and published, and each service chooses when to upgrade. Without help, services drift: after a year, the 30 services might use six different versions of the shared library, and a security fix needs 30 separate upgrades. So a polyrepo needs a platform BOM (a POM that fixes compatible versions of shared and third-party libraries), update bots such as Renovate or Dependabot that open upgrade pull requests automatically, and compatibility testing: the library's own build runs the tests of a few consumer services against the new version before release.

The two layouts side by side
ConcernMonorepoSeparate repositories
Change across many servicesOne atomic commitRelease library, then upgrade each service
Version of shared codeAlways oneMany unless a BOM and bots keep them close
Build sizeGrows; needs selective buildsSmall per repository
OwnershipNeeds CODEOWNERS per directoryClear by repository
Release cadenceIndependent only if versions are separateIndependent by default
Main tooling neededAffected-module CI, cachingBOM, update bots, compatibility tests

4Team Boundaries and Deploy Independence Decide

The strongest signal is how the teams and services actually work. If the six teams each own five services, deploy on their own schedule, and rarely change each other's code, the layout should reflect that independence: separate repositories, or a monorepo where each service keeps its own version and deploys on its own. If two teams own services that always change and release together, such as an API and its worker, those belong together, often as modules of one build.

A second signal is how often shared code changes across services. If the shared libraries change weekly in ways that touch many callers, the monorepo's atomic change saves a lot of coordination. If they are stable and change a few times a year, publishing versions is cheap.

Tool preference, such as 'Google uses a monorepo' or 'microservices mean many repositories', is the weakest signal. Both companies that made those choices also built large amounts of tooling to support them.

5The Trap: One Reactor and One Version for Independent Services

A common mistake is putting all 30 services into a single Maven reactor with one shared version, so every release of any service bumps the version of all of them.

XML
<!-- top pom.xml: one version for everything -->
<version>2026.11.0</version>
<modules>
<module>orders-service</module> <!-- released daily by team A -->
<module>payments-service</module> <!-- released monthly by team B -->
<module>shared-security</module>
<!-- ... 27 more ... -->
</modules>
<!-- releasing orders bumps payments to 2026.11.1 too, with no change in it -->

The reason this hurts is that version numbers stop meaning anything: payments gets a new version with no change, its deploy pipeline sees a new artifact, and nobody can tell from versions what changed. Release builds also have to build and test all 30 services. So unless the services really release together, each service keeps its own version and release process, even inside a monorepo.

6What We Would Choose for 30 Services and Six Teams

For this size, a reasonable default is one repository per team, or per closely related group of services, each with its own multi-module build, plus a small number of shared library repositories. A platform BOM fixes versions of shared and third-party libraries, Renovate keeps every repository within a bounded lag, and shared libraries run consumer tests before release. This matches six independently working teams and keeps builds small without monorepo tooling.

We would choose a single monorepo instead if the teams change shared code together constantly, or if the company is ready to invest in affected-module CI, build caching and code owners from the start. Whichever we pick, we write the decision down with the signals that drove it, so it can be revisited if the team structure changes.

Step throughDeciding the layout
  1. Do services deploy on their own schedules?
    YesKeep separate versions and pipelinesNoThey may share one build and version
  2. Do shared libraries change across many callers often?
    YesLean to a monorepo for atomic changesNoLean to repositories per team
  3. Can we fund selective CI, caching and code owners?
    YesMonorepo is workableNoPrefer separate repositories with BOM and bots

3 steps in order. Play them, or step through them one at a time.

Team boundaries first, then change patterns, then what tooling we can support.

7Follow-up questions

Can a monorepo still let services release independently?

Yes, if each service has its own version and its own deploy pipeline triggered by changes in its directory. The repository is shared, but the release unit is still the service. What breaks independence is a single shared version and a single release build for everything, not the single repository.

How do you stop services in a polyrepo from falling far behind on shared libraries?

We publish a platform BOM, let an update bot open pull requests for every new release, and set a policy for how far behind a service may be, for example no more than two minor versions or 60 days. A dashboard of versions per service makes drift visible, and security fixes get a shorter deadline.

What would make you move from one layout to the other later?

Measured pain. In a polyrepo, signs are frequent multi-repository changes that need careful ordering and long periods of version skew. In a monorepo, signs are build times that keep growing despite selective builds, and teams blocked by each other's failures. We move only when those costs clearly exceed the months a migration takes.

8Conclusion

In this answer, we saw that a monorepo gives atomic changes and one version of shared code but needs selective builds, code owners and scalable CI, while separate repositories give clear ownership and independent releases but need a BOM, update bots and compatibility testing. Team boundaries and deploy independence matter more than preference, and independently deployed services should not share one reactor and one version. For 30 services and six teams, repositories per team with a strong platform BOM is a sound default.

What to say in the interviewAbout 90 seconds aloud

Open with

I would decide from how the teams and services actually work. A multi-module monorepo gives atomic changes, so a shared library and all its callers change in one commit, and there is only ever one version of shared code.

Then, if they want more

The cost is that the build grows, so it needs affected-module detection, code owners per directory and CI that scales with caching and parallel agents. Separate repositories give clear ownership and an independent release cadence, and builds stay small.

The cost moves to version management: shared code has to be published, and without a platform BOM, update bots like Renovate and consumer compatibility tests, the services drift onto many versions. The signals I would weigh are team boundaries, whether services deploy independently, and how often shared code changes across many callers, rather than which companies use which layout.

One thing I would avoid in either case is putting independently deployed services into one reactor with a single shared version, because then every release bumps everything and versions stop meaning anything.

For six teams and 30 services, I would lean towards a repository per team or per related group of services, with shared libraries in their own repositories, a platform BOM and bots. If the teams constantly change shared code together and we can fund the tooling, a monorepo is a fine choice too.

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
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 "How would you decide between one large multi-module repository and separate repositories...": https://scrivio-interview-library.netlify.app/java/maven/65b808fbc2/