# jihedchaabane/gr-client-credentials-demo architecture

> Architecture diagram of the GitHub repository jihedchaabane/gr-client-credentials-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jihedchaabane/gr-client-credentials-demo
- Repository: https://github.com/jihedchaabane/gr-client-credentials-demo

## Overview

This repository is a Spring-based OAuth2 client-credentials and service-to-service demo, with separate authorization, gateway, client, and infrastructure applications. The demonstrated workflow is an HTTP caller invoking the RestTemplate consumer, which obtains a token from the authorization server and calls the gateway; client1 can also call client2 directly. The tree documents additional config-server, Eureka, and Spring Boot Admin services, but the supplied excerpts do not establish their runtime connections or gateway routing, so those links are omitted.

Main entry points: [`springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java`](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java) (Token Consumer), [`gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/config/AuthorizationServerConfig.java`](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/config/AuthorizationServerConfig.java) (OAuth2 Server), [`springboot-oauth2-client1/src/main/java/com/chj/gr/controller/ProtectedController.java`](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client1/src/main/java/com/chj/gr/controller/ProtectedController.java) (Client One), [`springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/model/TokenResponse.java`](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/model/TokenResponse.java) (Token Response)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_auth["Authorization"]
  node_authorization["OAuth2 Server"]
  node_authsecurity["Auth Security"]
  node_validateuser["User Validation"]
  node_hello["Auth Hello API"]
end

subgraph group_services["Service Clients"]
  node_consumer["Token Consumer<br/>[Ms3Controller.java]"]
  node_tokenmodel["Token Response<br/>[TokenResponse.java]"]
  node_client1["Client One"]
  node_client1security["Client One Security"]
  node_publicapi["Public API"]
  node_client2["Client Two"]
  node_client2security["Client Two Security"]
end

subgraph group_access["Gateway Access"]
  node_gateway["API Gateway"]
  node_gatewaysecurity["Gateway Security"]
end

subgraph group_platform["Platform Services"]
  node_configserver["Config Server"]
  node_eureka["Service Registry"]
  node_admin["Service Admin"]
end

node_caller(("HTTP Caller"))

node_caller -->|"invokes"| node_consumer
node_consumer -->|"requests token"| node_authorization
node_authorization -->|"returns token"| node_consumer
node_consumer -->|"maps response"| node_tokenmodel
node_consumer -->|"calls API"| node_gateway
node_client1 -->|"calls endpoint"| node_client2

click node_consumer "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java"
click node_tokenmodel "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/model/TokenResponse.java"
click node_authorization "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/config/AuthorizationServerConfig.java"
click node_authsecurity "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/config/SecurityConfig.java"
click node_validateuser "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/controller/ValidateUserController.java"
click node_hello "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/controller/HelloController.java"
click node_gateway "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-api-gateway/src/main/java/com/chj/gr/ApiGatewayApplication.java"
click node_gatewaysecurity "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-api-gateway/src/main/java/com/chj/gr/conf/SecurityConfig.java"
click node_client1 "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client1/src/main/java/com/chj/gr/controller/ProtectedController.java"
click node_client1security "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client1/src/main/java/com/chj/gr/conf/SecurityConfig.java"
click node_publicapi "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client1/src/main/java/com/chj/gr/controller/PublicController.java"
click node_client2 "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client2/src/main/java/com/chj/gr/controller/Protected2Controller.java"
click node_client2security "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client2/src/main/java/com/chj/gr/conf/SecurityConfig.java"
click node_configserver "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-config-server/src/main/java/com/chj/gr/SpringConfigServerApplication.java"
click node_eureka "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-eureka-server/src/main/java/com/chj/gr/EurekaServerApplication.java"
click node_admin "https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-springboot-admin/src/main/java/com/chj/gr/SpringBootAdminApplication.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_authorization,node_authsecurity,node_validateuser,node_hello toneBlue
class node_consumer,node_tokenmodel,node_client1,node_client1security,node_publicapi,node_client2,node_client2security toneAmber
class node_gateway,node_gatewaysecurity toneMint
class node_configserver,node_eureka,node_admin toneRose
class node_caller toneIndigo
```

## Components

### Authorization

- [OAuth2 Server](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/config/AuthorizationServerConfig.java): `gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/config/AuthorizationServerConfig.java`
- [Auth Security](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/config/SecurityConfig.java): `gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/config/SecurityConfig.java`
- [User Validation](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/controller/ValidateUserController.java): `gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/controller/ValidateUserController.java`
- [Auth Hello API](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/controller/HelloController.java): `gr-conf-oauth2-authorization-server/src/main/java/com/chj/gr/controller/HelloController.java`

### Service Clients

- [Token Consumer](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java): `springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java`
- [Token Response](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/model/TokenResponse.java): `springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/model/TokenResponse.java`
- [Client One](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client1/src/main/java/com/chj/gr/controller/ProtectedController.java): `springboot-oauth2-client1/src/main/java/com/chj/gr/controller/ProtectedController.java`
- [Client One Security](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client1/src/main/java/com/chj/gr/conf/SecurityConfig.java): `springboot-oauth2-client1/src/main/java/com/chj/gr/conf/SecurityConfig.java`
- [Public API](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client1/src/main/java/com/chj/gr/controller/PublicController.java): `springboot-oauth2-client1/src/main/java/com/chj/gr/controller/PublicController.java`
- [Client Two](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client2/src/main/java/com/chj/gr/controller/Protected2Controller.java): `springboot-oauth2-client2/src/main/java/com/chj/gr/controller/Protected2Controller.java`
- [Client Two Security](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/springboot-oauth2-client2/src/main/java/com/chj/gr/conf/SecurityConfig.java): `springboot-oauth2-client2/src/main/java/com/chj/gr/conf/SecurityConfig.java`

### Gateway Access

- [API Gateway](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-api-gateway/src/main/java/com/chj/gr/ApiGatewayApplication.java): `gr-conf-api-gateway/src/main/java/com/chj/gr/ApiGatewayApplication.java`
- [Gateway Security](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-api-gateway/src/main/java/com/chj/gr/conf/SecurityConfig.java): `gr-conf-api-gateway/src/main/java/com/chj/gr/conf/SecurityConfig.java`

### Platform Services

- [Config Server](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-config-server/src/main/java/com/chj/gr/SpringConfigServerApplication.java): `gr-conf-config-server/src/main/java/com/chj/gr/SpringConfigServerApplication.java`
- [Service Registry](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-eureka-server/src/main/java/com/chj/gr/EurekaServerApplication.java): `gr-conf-eureka-server/src/main/java/com/chj/gr/EurekaServerApplication.java`
- [Service Admin](https://github.com/jihedchaabane/gr-client-credentials-demo/blob/main/gr-conf-springboot-admin/src/main/java/com/chj/gr/SpringBootAdminApplication.java): `gr-conf-springboot-admin/src/main/java/com/chj/gr/SpringBootAdminApplication.java`

### Other components

- **HTTP Caller**

## Connections

- HTTP Caller → Token Consumer: invokes (evidence: `springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java`)
- Token Consumer → OAuth2 Server: requests token (evidence: `springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java`)
- OAuth2 Server → Token Consumer: returns token (evidence: `springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java`)
- Token Consumer → Token Response: maps response (evidence: `springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java`)
- Token Consumer → API Gateway: calls API (evidence: `springboot-oauth2-external-resttemplate-consumer/src/main/java/com/chj/gr/controller/Ms3Controller.java`)
- Client One → Client Two: calls endpoint (evidence: `springboot-oauth2-client1/src/main/java/com/chj/gr/controller/ProtectedController.java`)
