Architecture Microservices (Spring Boot)
Microservices de production : Spring Boot, streaming d'événements Apache Kafka, auth OAuth2/Keycloak, appels inter-services gRPC, passerelle API, Docker. Conception orientée événements avec isolation PostgreSQL par service.
Kafka orienté événements + OAuth2 Keycloak + appels sync gRPC + Spring Cloud Gateway
Système de microservices production avec architecture orientée événements.
Topologie des Services
Client → Spring Cloud Gateway (passerelle API)
→ Keycloak (auth OAuth2/OIDC)
→ Service A ←→ Kafka ←→ Service B
→ Service C --gRPC--> Service D
→ PostgreSQL (isolation BDD par service)
Décisions Clés
| Problème | Solution | Justification |
|---|---|---|
| Communication async | Apache Kafka | Découplage + durabilité + replay |
| Appels sync internes | gRPC | Contrats typés + 5–10× plus rapide que REST |
| Authentification | Keycloak OAuth2 | Centralisé, standard industriel |
| Routage des services | Spring Cloud Gateway | Chaînes de filtres + circuit breaking |
Événements Kafka OrderCreated, PaymentProcessed, InventoryUpdated — rétention 7 jours permettant aux services de rejouer après défaillances.
gRPC vs REST
- ▸Interne (service→service) : gRPC (binaire, typé, rapide)
- ▸Externe (navigateur→passerelle) : REST/JSON (compatibilité, debuggabilité)
Keycloak OAuth2 Tokens JWT avec périmètres au niveau service. Comptes de service pour l'auth machine-à-machine. Introspection des tokens à la passerelle — pas de logique d'auth par service.