# thomasdarimont/keycloak-project-example architecture

> Architecture diagram of the GitHub repository thomasdarimont/keycloak-project-example, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thomasdarimont/keycloak-project-example
- Repository: https://github.com/thomasdarimont/keycloak-project-example

## Overview

##### High-Level Architecture Overview

a) Infrastructure Layer:
- Docker Containers and Networking
- Load Balancers (HAProxy, Apache, Nginx, Caddy options)
- TLS/SSL Configuration
- Database Options (PostgreSQL, MySQL, Oracle, MSSQL)

b) Core Services:
- Keycloak Server Instances (Clustered Setup)
- External Infinispan Cluster
- OpenLDAP Integration
- Mail Server (maildev)

c) Monitoring & Observability:
- Prometheus for Metrics Collection
- Grafana for Dashboards
- OpenTelemetry Collector
- Jaeger for Tracing
- Graylog for Logging

d) Applications & Extensions:
- Custom Keycloak Extensions
- Frontend Applications
- Backend APIs
- Authentication Flows

##### Key Components

a) Authentication Flow:
- Identity Providers (OIDC, SAML)
- Custom Authenticators (SMS, Email, Backup Codes)
- Token Exchange
- User Federation

b) Security Layer:
- TLS Termination
- IP Filters
- Custom Security Providers

c) Development Environment:
- Hot Deployment
- Theme Development
- Extension Development
- Testing Infrastructure

##### Deployment View

Different deployment options:
- Development Environment
- Clustered Setup
- Standalone Setup
- CI/CD Pipeline Integration

##### Specific Implementation Details

Unique features:
- Custom Realm Configuration
- Identity Brokering Setup
- Extension Points
- Monitoring Integration

- Overview Layer (High-level architecture)
- Detailed Layer (Component interactions)
- Security Layer (Authentication flows)
- Monitoring Layer (Observability setup)

Tools Recommendation:
- Export to various formats
- Version control integration

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef infrastructure fill:#e6f3ff,stroke:#4d94ff
    classDef core fill:#ffe6e6,stroke:#ff4d4d
    classDef monitoring fill:#e6ffe6,stroke:#4dff4d
    classDef security fill:#ffe6f3,stroke:#ff4dff
    classDef apps fill:#fff2e6,stroke:#ffb84d
    classDef extensions fill:#f3e6ff,stroke:#b84dff

    %% Infrastructure Layer
    subgraph Infrastructure
        Docker["Docker Containers"]:::infrastructure
        LoadBalancer["Load Balancer (HAProxy)"]:::infrastructure
        Databases["Databases (PostgreSQL/MySQL/Oracle)"]:::infrastructure
    end

    %% Core Services Layer
    subgraph CoreServices
        KeycloakServer["Keycloak Server"]:::core
        Infinispan["External Infinispan"]:::core
        OpenLDAP["OpenLDAP"]:::core
        MailServer["Mail Server (maildev)"]:::core
    end

    %% Monitoring Layer
    subgraph Monitoring
        Prometheus["Prometheus"]:::monitoring
        Grafana["Grafana"]:::monitoring
        OpenTelemetry["OpenTelemetry"]:::monitoring
        Jaeger["Jaeger"]:::monitoring
        Graylog["Graylog"]:::monitoring
    end

    %% Security Layer
    subgraph Security
        CustomAuth["Custom Authenticators"]:::security
        MFA["MFA Implementation"]:::security
        TokenExchange["Token Exchange"]:::security
    end

    %% Applications Layer
    subgraph Applications
        FrontendApp["Frontend Web Apps"]:::apps
        BackendAPI["Backend APIs"]:::apps
        AccountService["Account Service"]:::apps
        CustomThemes["Custom Themes"]:::apps
    end

    %% Extensions Layer
    subgraph Extensions
        CoreExt["Core Extensions"]:::extensions
        EventListeners["Event Listeners"]:::extensions
        CustomEndpoints["Custom Endpoints"]:::extensions
    end

    %% Relationships
    Docker --> KeycloakServer
    Docker --> Databases
    LoadBalancer --> KeycloakServer
    KeycloakServer --> Infinispan
    KeycloakServer --> OpenLDAP
    KeycloakServer --> MailServer
    KeycloakServer --> CustomAuth
    KeycloakServer --> CoreExt
    CustomAuth --> MFA
    CustomAuth --> TokenExchange
    KeycloakServer --> EventListeners
    KeycloakServer --> CustomEndpoints
    FrontendApp --> KeycloakServer
    BackendAPI --> KeycloakServer
    AccountService --> KeycloakServer
    KeycloakServer --> CustomThemes
    KeycloakServer --> Prometheus
    Prometheus --> Grafana
    KeycloakServer --> OpenTelemetry
    OpenTelemetry --> Jaeger
    KeycloakServer --> Graylog

    %% Click events for component mapping
    click Docker "https://github.com/thomasdarimont/keycloak-project-example/blob/main/deployments/local/dev/docker-compose.yml"
    click LoadBalancer "https://github.com/thomasdarimont/keycloak-project-example/blob/main/deployments/local/cluster/haproxy/haproxy.cfg"
    click KeycloakServer "https://github.com/thomasdarimont/keycloak-project-example/tree/main/keycloak/docker/src/main/docker/keycloak/"
    click Infinispan "https://github.com/thomasdarimont/keycloak-project-example/tree/main/deployments/local/cluster/haproxy-external-ispn/"
    click OpenLDAP "https://github.com/thomasdarimont/keycloak-project-example/blob/main/config/stage/dev/openldap/demo.ldif"
    click Prometheus "https://github.com/thomasdarimont/keycloak-project-example/blob/main/config/stage/dev/prometheus/prometheus.yml"
    click Grafana "https://github.com/thomasdarimont/keycloak-project-example/tree/main/config/stage/dev/grafana/provisioning/dashboards/"
    click OpenTelemetry "https://github.com/thomasdarimont/keycloak-project-example/blob/main/config/stage/dev/otel/otel-collector-config.yaml"
    click Graylog "https://github.com/thomasdarimont/keycloak-project-example/tree/main/deployments/local/dev/graylog/"
    click CustomAuth "https://github.com/thomasdarimont/keycloak-project-example/tree/main/keycloak/extensions/src/main/java/com/github/thomasdarimont/keycloak/custom/auth/"
    click MFA "https://github.com/thomasdarimont/keycloak-project-example/tree/main/keycloak/extensions/src/main/java/com/github/thomasdarimont/keycloak/custom/auth/mfa/"
    click TokenExchange "https://github.com/thomasdarimont/keycloak-project-example/tree/main/keycloak/extensions/src/main/java/com/github/thomasdarimont/keycloak/custom/oauth/tokenexchange/"
    click FrontendApp "https://github.com/thomasdarimont/keycloak-project-example/tree/main/apps/frontend-webapp-springboot/"
    click BackendAPI "https://github.com/thomasdarimont/keycloak-project-example/tree/main/apps/backend-api-springboot/"
    click AccountService "https://github.com/thomasdarimont/keycloak-project-example/tree/main/apps/account-svc/"
    click CustomThemes "https://github.com/thomasdarimont/keycloak-project-example/tree/main/keycloak/themes/"
    click CoreExt "https://github.com/thomasdarimont/keycloak-project-example/tree/main/keycloak/extensions/src/main/java/com/github/thomasdarimont/keycloak/custom/"
    click EventListeners "https://github.com/thomasdarimont/keycloak-project-example/tree/main/keycloak/extensions/src/main/java/com/github/thomasdarimont/keycloak/custom/eventpublishing/"
    click CustomEndpoints "https://github.com/thomasdarimont/keycloak-project-example/tree/main/keycloak/extensions/src/main/java/com/github/thomasdarimont/keycloak/custom/endpoints/"
```
