# ivantomic77/greeter architecture

> Architecture diagram of the GitHub repository ivantomic77/greeter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ivantomic77/greeter
- Repository: https://github.com/ivantomic77/greeter

## Overview

##### Project Type Analysis
This is a microservices-based application implementing Zero Trust Security principles, with Spring Cloud Gateway as the central component. The project demonstrates secure service-to-service communication and authentication flow.

##### Main Components

a. External Components:
- Client Applications (Postman)
- Keycloak Authorization Server (Port 18080)

b. Core Services:
- Spring Cloud Gateway Service
- Greeting Service

c. Security Components:
- JWT Token Flow
- Authentication/Authorization Layers

##### Connection and Flow Representation

- Blue: Regular service calls
- Green: Successful authentication paths
- Red: Security boundaries
- Gray: Infrastructure components

##### Specific Elements

a. Gateway Service Details:
- Port exposure
- Security filters
- Route configurations
- Token validation logic

b. Greeting Service Details:
- Protected endpoints
- JWT validation
- Exception handling

c. Security Flow:
**1. Client → Gateway (Authentication request)**
**2. Gateway → Keycloak (Token validation)**
**3. Gateway → Greeting Service (Protected request with JWT)**
**4. Zero Trust boundary markers**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        POSTMAN["Postman Client"]:::client
    end

    subgraph Gateway["Gateway Layer"]
        GW["Gateway Service"]:::service
        GA["Gateway Application"]:::component
        KA["Keycloak Authenticator"]:::security
        GSC["Gateway Security Config"]:::security
        AO["Auth Objects"]:::security
    end

    subgraph Service["Service Layer"]
        GS["Greeting Service"]:::service
        GSA["Greeting Service Application"]:::component
        GC["Greet Controller"]:::component
        GSV["Greet Service"]:::component
        CJAC["Custom JWT Auth Converter"]:::security
        SSC["Service Security Config"]:::security
        EH["Exception Handler"]:::component
    end

    subgraph Auth["Authentication Layer"]
        KC["Keycloak Server\n(Port: 18080)"]:::auth
        REALM["Springboot\nMicroservice Realm"]:::auth
    end

    subgraph Config["Configuration"]
        DC["Docker Compose"]:::config
        GC_YAML["Gateway Config YAML"]:::config
        GSC_YAML["Greeting Service Config YAML"]:::config
    end

    %% Connections
    POSTMAN -->|"API Request"| GW
    GW -->|"Route Request"| GS
    GW -.->|"Validate Token"| KC
    KC -.->|"Issue Token"| GW
    GW -->|"Forward Request\nwith JWT"| GS

    %% Internal Component Relations
    GW --- GA
    GW --- KA
    GW --- GSC
    GW --- AO

    GS --- GSA
    GS --- GC
    GS --- GSV
    GS --- CJAC
    GS --- SSC
    GS --- EH

    KC --- REALM

    %% Click Events
    click GA "https://github.com/ivantomic77/greeter/blob/main/gateway/src/main/java/dev/tomic/gateway/GatewayApplication.java"
    click KA "https://github.com/ivantomic77/greeter/blob/main/gateway/src/main/java/dev/tomic/gateway/security/KeycloakAuthenticator.java"
    click GSC "https://github.com/ivantomic77/greeter/blob/main/gateway/src/main/java/dev/tomic/gateway/security/SecurityConfig.java"
    click AO "https://github.com/ivantomic77/greeter/blob/main/gateway/src/main/java/dev/tomic/gateway/security/AuthObject.java"
    click GSA "https://github.com/ivantomic77/greeter/blob/main/greeting-service/src/main/java/dev/tomic/greetingservice/GreetingServiceApplication.java"
    click GC "https://github.com/ivantomic77/greeter/blob/main/greeting-service/src/main/java/dev/tomic/greetingservice/greet/GreetController.java"
    click GSV "https://github.com/ivantomic77/greeter/blob/main/greeting-service/src/main/java/dev/tomic/greetingservice/greet/GreetService.java"
    click CJAC "https://github.com/ivantomic77/greeter/blob/main/greeting-service/src/main/java/dev/tomic/greetingservice/security/CustomJwtAuthenticationConverter.java"
    click SSC "https://github.com/ivantomic77/greeter/blob/main/greeting-service/src/main/java/dev/tomic/greetingservice/security/SecurityConfig.java"
    click EH "https://github.com/ivantomic77/greeter/blob/main/greeting-service/src/main/java/dev/tomic/greetingservice/exception/RestExceptionHandler.java"
    click REALM "https://github.com/ivantomic77/greeter/blob/main/keycloak-exports/realm.json"
    click DC "https://github.com/ivantomic77/greeter/blob/main/docker-compose.yml"
    click GC_YAML "https://github.com/ivantomic77/greeter/blob/main/gateway/src/main/resources/application.yml"
    click GSC_YAML "https://github.com/ivantomic77/greeter/blob/main/greeting-service/src/main/resources/application.yml"
    click POSTMAN "https://github.com/ivantomic77/greeter/blob/main/integration-test/Microservice Gateway Example.postman_collection.json"

    %% Styling
    classDef client fill:#E1F5FE,stroke:#01579B
    classDef service fill:#E8F5E9,stroke:#1B5E20
    classDef component fill:#F3E5F5,stroke:#4A148C
    classDef security fill:#FFEBEE,stroke:#B71C1C
    classDef auth fill:#FFF3E0,stroke:#E65100
    classDef config fill:#FAFAFA,stroke:#212121

    %% Legend
    subgraph Legend
        L1["Client Component"]:::client
        L2["Service Component"]:::service
        L3["Application Component"]:::component
        L4["Security Component"]:::security
        L5["Auth Component"]:::auth
        L6["Configuration"]:::config
    end
```
