Open the editor

Spring Boot microservices stack architecture

Java services on Spring Boot behind a gateway, exchanging events through Kafka.

Spring Boot microservices stack architecture diagram: Spring Cloud Gateway, Spring Boot services, Kafka, PostgreSQL per service, Observability

Spring Boot is the most common way to build Java back ends. It packages a Spring application with an embedded server and sensible defaults, so a service starts with one command. For microservices, Spring Cloud adds a gateway, configuration and resilience tools, and Spring for Apache Kafka handles events.

In this stack each service is its own Spring Boot application with its own PostgreSQL database, accessed through Spring Data JPA. Spring Cloud Gateway routes client requests, Spring Security checks OAuth 2.0 tokens, and Micrometer exports metrics and traces.

What the stack is made of

Spring Cloud Gateway
Routes requests to services, with filters for auth, rate limits and retries.
Spring Boot services
Orders and inventory, each with web endpoints, Spring Data JPA and its own database.
Kafka
Carries domain events between services, through Spring for Apache Kafka.
PostgreSQL per service
Each service owns its schema, migrated with Flyway or Liquibase.
Observability
Spring Boot Actuator and Micrometer feed Prometheus, Grafana and tracing.

How a request flows through it

  1. A client calls POST /orders on the gateway with a token.
  2. The gateway validates the token and routes the call to the orders service.
  3. The orders service saves the order with JPA and publishes OrderPlaced to Kafka.
  4. The inventory service consumes the event and reserves stock in its own database.

When to use it, and when not to

Good fit

  • Enterprise systems with Java teams and long support horizons.
  • Microservices that need mature libraries for security, data, messaging and observability.
  • Integration with existing Java systems.

Think twice

  • Tiny services where JVM start-up time and memory matter, unless you compile to native images with GraalVM.
  • A small team without the platform to run many services: use one Spring Boot modular monolith first.

Edit this diagram

Click Open the diagram in the editor to get your own copy, saved in your browser. Rename the boxes to match your system, swap any technology for the one you use from the icon palette, then export a PNG, SVG or PDF, or share a link. No sign-up.