Simplified architecture

Some of the unecessary components has been removed:

  • Payment Microservice: The logic should be refactored in order to fit for real production logic.

New diagram:

API Gateway

As suggested by Clement and Paulo, I use HTTP-HTTP pattern for API Gateway eventually. The API gateway itself is using HTTPS, but it communicates REST endpoints via HTTP.

So the API Gateway is responsible for:

  • Dispatching requests to corresponding endpoint.

How to implement this?
My solution: When publishing endpoints to the service discovery infrasture, every endpoints must provide an api-name to identify the api, then when a request arrives from the gateway, the gateway will get the prefix pattern /api/:name/* and find any corresponding endpoints via discovery, then consume the HTTP endpoint.

  • Simple load balancing
  • Health check
  • Failure handling (using Vert.x Circuit Breaker)
  • Global auth state storage(in route context and session scope)

Auth

It’s convenient to use Keycloak via Vert.x OAuth2.