# mosip/keycloak architecture

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

- Interactive diagram: https://gitdiagram.com/mosip/keycloak
- Repository: https://github.com/mosip/keycloak

## Overview

##### Project type and purpose
- This is an open-source tool and CI/CD kit for building, customizing, and deploying MOSIP-branded Keycloak server images (both Artemis-based and JBoss-based distributions), together with initialization scripts and a Helm chart for Kubernetes.
- The README confirms its scope: “Contains MOSIP customised keycloak image for IAM.”

##### File structure
- Top-level directories:
- .github: workflows to build & publish on push/tag.
- deploy: shell scripts & YAML for installing/upgrading Keycloak on Kubernetes (e.g., install.sh, import-init.sh).
- helm/keycloak-init: a Helm chart defining a Kubernetes Job (keycloak-init) to seed realms/clients.
- keycloak-artemis: Dockerfile + Bitnami-based filesystem + MOSIP themes + custom SPIs.
- keycloak-jboss: Dockerfile + JBoss-based distribution + MOSIP themes + SPI jar.
- keycloak-init: Python scripts & container to drive realm/user import via Keycloak Admin REST API.
- Build artifacts: Docker images for keycloak-artemis, keycloak-jboss, keycloak-init.

##### README for additional insights
- Triggers GitHub Actions to build and publish Maven artifacts or Docker images.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline" 
        direction TB
        GH1["chart-lint-publish.yml"]:::cicd
        GH2["push-trigger.yml"]:::cicd
        GH3["tag.yml"]:::cicd
        GH4["verify-keycloak-init.yml"]:::cicd
    end
    CI_REG["Docker Registry / Maven Repo"]:::registry
    GH1 -->|build images| CI_REG
    GH2 -->|build images| CI_REG
    GH3 -->|build images| CI_REG
    GH4 -->|build images| CI_REG

    %% Deploy & Helm
    subgraph "Deployment & Helm" 
        direction TB
        DS["deploy/install.sh, import-init.sh, upgrade-init.sh, delete.sh, update_secret.sh"]:::cicd
        DV["deploy/values.yaml"]:::cicd
        DIV["deploy/import-init-values.yaml"]:::cicd
        DUV["deploy/upgrade-init-values.yaml"]:::cicd
        HC["helm/keycloak-init Chart"]:::helm
    end
    CI_REG -->|pull images| DS
    DS -->|invoke Helm| HC

    %% Kubernetes Cluster
    subgraph "Kubernetes Cluster" 
        direction TB
        subgraph "Initialization Job" 
            direction TB
            Job["keycloak-init Job"]:::pod
            INY["input.yaml"]:::pod
            USY["users.yaml"]:::pod
            Job -->|reads| INY
            Job -->|reads| USY
        end
        subgraph "Keycloak Service" 
            direction TB
            SVC["Keycloak Service"]:::k8s
            subgraph "Keycloak Pods" 
                direction TB
                KC_Art["Artemis Pod"]:::pod
                KC_JB["JBoss Pod"]:::pod
                KC_Art -->|connects| DB
                KC_JB -->|connects| DB
            end
            SVC --> KC_Art
            SVC --> KC_JB
        end
        DB["External DB"]:::db
    end
    HC -->|deploys| Job
    HC -->|deploys| KC_Art
    HC -->|deploys| KC_JB

    %% External interaction
    CLIENT["Clients / Browsers"]:::ext -->|HTTPS auth| LB["LoadBalancer"]:::ext -->|routes to| SVC

    Job -->|calls Admin API| SVC

    %% Click events
    click GH1 "https://github.com/mosip/keycloak/blob/release-1.3.x/.github/workflows/chart-lint-publish.yml"
    click GH2 "https://github.com/mosip/keycloak/blob/release-1.3.x/.github/workflows/push-trigger.yml"
    click GH3 "https://github.com/mosip/keycloak/blob/release-1.3.x/.github/workflows/tag.yml"
    click GH4 "https://github.com/mosip/keycloak/blob/release-1.3.x/.github/workflows/verify-keycloak-init.yml"
    click DS "https://github.com/mosip/keycloak/blob/release-1.3.x/deploy/install.sh"
    click DS "https://github.com/mosip/keycloak/blob/release-1.3.x/deploy/import-init.sh"
    click DS "https://github.com/mosip/keycloak/blob/release-1.3.x/deploy/upgrade-init.sh"
    click DS "https://github.com/mosip/keycloak/blob/release-1.3.x/deploy/delete.sh"
    click DS "https://github.com/mosip/keycloak/blob/release-1.3.x/deploy/update_secret.sh"
    click DV "https://github.com/mosip/keycloak/blob/release-1.3.x/deploy/values.yaml"
    click DIV "https://github.com/mosip/keycloak/blob/release-1.3.x/deploy/import-init-values.yaml"
    click DUV "https://github.com/mosip/keycloak/blob/release-1.3.x/deploy/upgrade-init-values.yaml"
    click HC "https://github.com/mosip/keycloak/blob/release-1.3.x/helm/keycloak-init/Chart.yaml"
    click HC "https://github.com/mosip/keycloak/blob/release-1.3.x/helm/keycloak-init/values.yaml"
    click HC "https://github.com/mosip/keycloak/blob/release-1.3.x/helm/keycloak-init/templates/job.yaml"
    click HC "https://github.com/mosip/keycloak/blob/release-1.3.x/helm/keycloak-init/templates/configmap.yaml"
    click HC "https://github.com/mosip/keycloak/blob/release-1.3.x/helm/keycloak-init/templates/client-secrets.yaml"
    click HC "https://github.com/mosip/keycloak/blob/release-1.3.x/helm/keycloak-init/templates/serviceaccount.yaml"
    click HC "https://github.com/mosip/keycloak/blob/release-1.3.x/helm/keycloak-init/templates/_helpers.tpl"
    click HC "https://github.com/mosip/keycloak/blob/release-1.3.x/helm/keycloak-init/templates/tests/test-connection.yaml"
    click Job "https://github.com/mosip/keycloak/tree/release-1.3.x/keycloak-init/Dockerfile"
    click Job "https://github.com/mosip/keycloak/blob/release-1.3.x/keycloak-init/keycloak_init.py"
    click Job "https://github.com/mosip/keycloak/blob/release-1.3.x/keycloak-init/keycloak_logout.py"
    click Job "https://github.com/mosip/keycloak/blob/release-1.3.x/keycloak-init/run.sh"
    click Job "https://github.com/mosip/keycloak/blob/release-1.3.x/keycloak-init/input.yaml"
    click Job "https://github.com/mosip/keycloak/blob/release-1.3.x/keycloak-init/users.yaml"
    click Job "https://github.com/mosip/keycloak/blob/release-1.3.x/keycloak-init/requirements.txt"
    click KC_Art "https://github.com/mosip/keycloak/tree/release-1.3.x/keycloak-artemis/Dockerfile"
    click KC_Art "https://github.com/mosip/keycloak/tree/release-1.3.x/keycloak-artemis/prebuildfs"
    click KC_Art "https://github.com/mosip/keycloak/tree/release-1.3.x/keycloak-artemis/rootfs"
    click KC_Art "https://github.com/mosip/keycloak/blob/release-1.3.x/keycloak-artemis/standalone/deployments/recaptcha-login.jar"
    click KC_Art "https://github.com/mosip/keycloak/blob/release-1.3.x/keycloak-artemis/standalone/deployments/spi-keycloak.jar"
    click KC_Art "https://github.com/mosip/keycloak/tree/release-1.3.x/keycloak-artemis/theme"
    click KC_JB "https://github.com/mosip/keycloak/tree/release-1.3.x/keycloak-jboss/Dockerfile"
    click KC_JB "https://github.com/mosip/keycloak/blob/release-1.3.x/keycloak-jboss/standalone/deployments/spi-keycloak-1.0.jar"
    click KC_JB "https://github.com/mosip/keycloak/tree/release-1.3.x/keycloak-jboss/theme"

    %% Styles
    classDef cicd fill:#BBDEFB,stroke:#1976D2,color:#0D47A1
    classDef registry fill:#90CAF9,stroke:#1565C0,color:#0D47A1
    classDef helm fill:#B3E5FC,stroke:#0288D1,color:#01579B
    classDef k8s fill:#C8E6C9,stroke:#2E7D32,color:#1B5E20
    classDef pod fill:#FFE0B2,stroke:#EF6C00,color:#E65100
    classDef db fill:#FFF9C4,stroke:#F9A825,color:#F57F17
    classDef ext fill:#FFCCBC,stroke:#E64A19,color:#BF360C
```
