PT

Nº 11of 12Index

Microservices platform

A store built as microservices behind a gateway: Nginx balancing Spring Cloud Gateway replicas, JWTs validated by Auth with a Redis cache, Kafka with an outbox, and a reusable GitHub Actions pipeline

Year
2026
Status
IN PROGRESS
Role
Gateway, cache, Nginx and CI/CD · group of 3
Stack
Java · Spring Cloud Gateway · Spring Boot · Nginx +11
plataforma-microsservicos
Microservices platform — The group's documentation — the architecture: Nginx in front of two gateway replicas, Redis, Auth, Account, Exchange and Kafka through to Notification
5 screens

1 of 5

Microservices platform — The group's documentation — the architecture: Nginx in front of two gateway replicas, Redis, Auth, Account, Exchange and Kafka through to Notification

The group's documentation — the architecture: Nginx in front of two gateway replicas, Redis, Auth, Account, Exchange and Kafka through to Notification

01The project

A project for Insper's Platforms, Microservices and APIs course (2026.2), in a group of three: the platform for a store where users sign up, log in and look up exchange rates. Nginx is the only exposed entry point and balances replicas of a Spring Cloud Gateway (WebFlux) gateway, which reads the JWT from the cookie, validates it by calling Auth and forwards the identity in the id-account header — dropping whatever the client sent in that header. Behind it sit Auth, Account (Spring Boot + PostgreSQL) and Exchange (Python/FastAPI); a fifth service, Notification, consumes from Kafka the account-created event that Account writes to a transactional outbox. Prometheus and Grafana, k6 load tests, Trivy scanning and Kubernetes manifests for AWS EKS round out the platform. Of the 73 commits in the main repository, 35 are mine: the gateway, the Redis cache, Nginx and the CI/CD pipeline. Auth, Account, messaging and EKS are Nicolas's; Exchange, observability, load tests and the HPA are Gabriel's.

02What was built

  1. The gateway is mine, with 20 tests: only register, login and logout are open; everything else needs the JWT, validated by Auth, and the gateway always rewrites the id-account header — the services behind it never trust what came from the client

  2. A token cache in Redis shared by every replica: key = SHA-256 of the JWT and a TTL of at most 5 min, never past exp; across 3,001 authenticated requests, 1 call to Auth — and with Redis down, the gateway keeps validating without the cache

  3. Nginx as the only exposed entry point, re-resolving DNS every 10 s: a new gateway replica joins the rotation without a reload

  4. One reusable GitHub Actions pipeline, called by every service: build and tests, Trivy on the code and on the image with a gate on fixable critical CVEs, and a multi-arch image pushed to GHCR and ECR, getting into AWS through OIDC with no keys in GitHub; deploying to EKS from CI still waits on the cluster

  5. From the group: Kafka with a transactional outbox, idempotent consumption, 3 retries and a dead-letter topic in Notification; Prometheus and Grafana; k6 load tests and an HPA rehearsal on a kind cluster; EKS tested with a manual deploy and a smoke test

03Decisions

Decision 01

Question: Why store a hash of the token in Redis, and not the token?

Answer: The cache exists to take Auth out of every request's path, not to become a second place to steal a session from. With the key being the SHA-256 of the JWT, whoever reads Redis cannot reuse a single token; and since the TTL never goes past exp, an expired token does not stay valid because of the cache.

Decision 02

Question: Why one reusable pipeline instead of one per service?

Answer: A fix to the pipeline applies to every service at once. Each microservice only has a small file that calls the workflow in the main repository, and the security gate — Trivy failing on a fixable critical CVE or an exposed secret — is the same for all of them.

04Screens

  • gateway.webp

    The gateway page, my part: routes, authorization through Auth and the rewritten id-account header

  • cache.webp

    Token cache in Redis: cache-aside keyed on the JWT's SHA-256, with a TTL that never goes past exp

  • ci-cd.webp

    The reusable GitHub Actions pipeline: build and tests, Trivy on code and image, a security gate, multi-arch push and the EKS deploy

  • testes-gateway.webp

    mvn test on the gateway: 31 tests passing — the original commit's 20 plus 11 that Nicolas's RBAC added later

1 of 5

Microservices platform — The group's documentation — the architecture: Nginx in front of two gateway replicas, Redis, Auth, Account, Exchange and Kafka through to Notification

The group's documentation — the architecture: Nginx in front of two gateway replicas, Redis, Auth, Account, Exchange and Kafka through to Notification

05Stack

  • Java
  • Spring Cloud Gateway
  • Spring Boot
  • Nginx
  • Redis
  • PostgreSQL
  • Kafka
  • Python
  • Kubernetes
  • AWS EKS
  • GitHub Actions
  • Trivy
  • Prometheus
  • Grafana
  • k6
Next project →Nº 12

C++ firmware for an ESP32 with a touch screen: 8 LVGL mini-apps and an SDL2 simulator for developing without the board