Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

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?

A good service template gives every new service a standard feature-based package structure, a build with a shared dependency BOM, observability, security, health checks and configuration conventions, and a test setup with architecture tests, all working on day one. New services are generated from it through a developer portal or project generator, the template is versioned, existing services get upgrade guides or automated migrations, and documented deviations plus team feedback keep it improving instead of fossilising.

Why this question is asked

With 30 teams building Java services, the difference between a template and no template shows up everywhere: in how long a new service takes to reach production, in whether on-call engineers can find the logs and metrics of a service they have never seen, and in how painful the next Spring Boot upgrade is. Interviewers ask this design question at the senior level because the hard part is not the first version of the template; it is keeping 200 services aligned with it two years later. In this answer, we will look at what goes into the template, how teams create services from it, how we version and roll out changes to existing services, and how we handle teams that need to deviate.

1What Problem the Template Solves

A reference service template is a ready-made, working Java service that captures the organisation's agreed way of building services. It is not documentation; it is code that compiles, passes its tests and deploys. A team that creates a service from it gets a hello-world endpoint running in the staging environment on the first day, with logging, metrics, tracing, security and a pipeline already wired.

The reason to invest in it is repetition. Without a template, each of the 30 teams makes the same 40 small decisions, about logging format, health endpoints, error responses, dependency versions, differently. Each difference costs a little when the service is built and much more later, when a platform team has to upgrade, monitor or secure all of them.

2What Goes Into the Template

The template has four groups of content. The first is structure: packages by feature, such as com.acme.payments.refunds, each with a simple internal layering of web, application and persistence, so that every service is navigable in the same way. The second is the build: one Maven or Gradle setup that imports a company BOM, a bill of materials that pins the versions of Spring Boot and every shared library, so services do not each pick their own versions.

The third group is the production basics, working out of the box. That means structured JSON logging with a trace id on every line, Micrometer metrics and OpenTelemetry tracing exported to the company's backend, Spring Boot Actuator health endpoints with separate liveness and readiness groups for Kubernetes, Spring Security configured for the company's identity provider, a standard error response format, and configuration conventions such as which properties come from the environment and how secrets are read.

The fourth group is testing: JUnit setup, Testcontainers for the database, a sample contract test, and a set of ArchUnit architecture tests that enforce the package structure, for example that no feature reaches into another feature's internal package and that controllers never use repositories directly.

XML
<!-- pom.xml of a generated service -->
<parent>
<groupId>com.acme.platform</groupId>
<artifactId>acme-service-parent</artifactId>
<version>7.3.0</version> <!-- pins Spring Boot, libraries, plugins -->
</parent>
<dependencies>
<dependency><groupId>com.acme.platform</groupId><artifactId>acme-observability-starter</artifactId></dependency>
<dependency><groupId>com.acme.platform</groupId><artifactId>acme-security-starter</artifactId></dependency>
<dependency><groupId>com.acme.platform</groupId><artifactId>acme-arch-rules</artifactId><scope>test</scope></dependency>
</dependencies>
Step throughWhat a generated service contains
  1. Feature packagesorders, refunds; web, application, persistence inside each
  2. Company startersobservability, security, error format, config
  3. Service parent and BOMSpring Boot and library versions pinned
  4. Test setupJUnit, Testcontainers, ArchUnit rules
  5. Pipeline and deploymentCI file, container image, Helm chart

5 layers, from the top down. Step through them one at a time.

Shared behaviour sits in versioned libraries, so it can be upgraded without regenerating services.

Notice that most of the behaviour lives in versioned starters and a parent, not in copied code. This is the single most important design choice, and the next sections explain why.

3Generating New Services

Teams should never copy a template repository by hand, because a copy starts drifting immediately. Instead, the template is exposed through a project generator, commonly a developer portal such as Backstage with a software template, or a company-flavoured Spring Initializr. The engineer fills in a form with the service name, team and options such as needs a database or consumes Kafka, and the generator creates the repository, registers the service in the catalogue with its owner, sets up the pipeline and opens the first pull request.

This gives us two useful properties. Every service is registered with an owner from the first minute, and we know exactly which template version each service was generated from, which matters when we roll out changes.

4Keeping Existing Services Aligned

The template will change: a new Spring Boot version, a new tracing exporter, a security fix. The question is how 200 existing services follow. We use two mechanisms that complement each other.

First, anything that can be a library is a library. Observability, security and error handling live in starters, and versions live in the parent and BOM. A service follows most changes by bumping one version number, and a bot such as Renovate or Dependabot opens that pull request automatically in every repository. With good tests, most of those pull requests merge with little effort.

Second, for changes that touch the service's own files, such as a new package convention, a new CI step or a property rename, we publish versioned upgrade guides and, where possible, automated migrations. OpenRewrite is well suited to this: it applies recipes that rewrite code and configuration, and both the Spring Boot upgrades and our own conventions can be expressed as recipes. A recipe that 200 services run beats a guide that 200 teams each interpret.

Step throughRolling out template version 7.4
  1. Release parent and starters 7.4release notes and an upgrade guide
  2. Bot opens a version bump PRin every registered service
  3. Does the change touch service files?
    YesRun the OpenRewrite recipe in the PRNoTests decide
  4. Pipeline green?
    YesTeam reviews and mergesNoTeam fixes or asks platform for help
  5. Dashboard updatesservices per template version

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

A dashboard of versions per service shows how aligned the fleet is.

5Allowing Deviations and Learning From Them

Some teams will have good reasons to deviate: a latency-critical service may not want the default tracing sampler, and a batch service has no HTTP API to secure. If the template forbids every deviation, teams fork it quietly. So we make deviation explicit: a team records it in the repository, for example as an exemption in the ArchUnit configuration with a reason and an owner, or as a short decision record.

Those deviations are our best feedback. If five teams have switched off the same rule, the rule is probably wrong. We review deviations and feedback regularly, perhaps every quarter, with representatives from product teams, and change the template accordingly. A template that listens stays the easiest path; one that does not becomes something teams work around.

6Follow-up questions

Why not let each team copy the template and own it?

Because copied code never gets upgraded consistently. Within a year we would have 30 variants, and every security fix would need 30 different changes. Keeping shared behaviour in versioned libraries and generating only the thin service-specific part means most improvements arrive as a version bump.

How do you measure whether the template works?

We track time from generation to first production deploy, the share of services on the latest two template versions, and incident data such as how often a service lacked the dashboards or alerts needed during an incident. If generation-to-production drops from weeks to a day or two and most services stay current, the template is doing its job.

Who owns the template?

A platform team owns it and its starters, with a clear support channel and a published roadmap. Product teams contribute changes through pull requests, and a small group of senior engineers from product teams reviews significant changes so that the template reflects real needs rather than only the platform team's view.

7Conclusion

In this answer, we designed a reference service template for 30 teams. It contains a feature-based package structure, a build on a shared parent and BOM, observability, security, health and configuration conventions, and a test setup with architecture tests. Services are generated through a developer portal, so each one is registered and traceable to a template version. Shared behaviour lives in versioned starters so that most changes arrive as a version bump, structural changes come with upgrade guides or OpenRewrite recipes, and documented deviations feed back into improving the template.

What to say in the interviewAbout 80 seconds aloud

Open with

I would build the template as a working service rather than a document. It would have packages by feature with a simple internal layering, a build on a company parent and BOM that pins Spring Boot and library versions, and production basics working out of the box: structured logging with trace ids, Micrometer metrics and OpenTelemetry tracing, Actuator liveness and readiness probes, Spring Security for our identity provider, a standard error format and configuration conventions.

Then, if they want more

It would also include the test setup, Testcontainers and a set of ArchUnit rules that enforce the structure. New services would be generated through a developer portal like Backstage, so every service is registered with an owner and we know which template version it came from.

The key design choice for keeping services aligned is to put as much as possible into versioned starters and the parent, so most changes reach existing services as a version bump that a bot opens automatically. For changes to the services' own files I would publish upgrade guides and, wherever possible, OpenRewrite recipes.

And I would allow documented deviations, recorded in the repository with a reason, and review them every quarter, because if several teams turn off the same rule, the template is what needs changing.

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 official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
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 "Design a reference service template for new Java services built by 30 teams. What does...": https://scrivio-interview-library.netlify.app/java/application-architecture/4ed63ff6e2/