# mosip/infra architecture

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

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

## Overview

1. **What this repository is**
   - This repo is a deployment and lifecycle-management system for the MOSIP platform, not the application itself.
   - It combines **Terraform** for cloud/infrastructure provisioning and **Helmsman** for Kubernetes application deployment.
   - The main supported runtime is **AWS**; Azure and GCP directories exist but are largely placeholders compared with AWS.

2. **Top-level control plane**
   - **GitHub Actions** is the orchestration layer for all deployment and teardown operations.
   - Workflows in `.github/workflows` call shell scripts in `.github/scripts`, which then invoke Terraform or Helmsman.
   - The workflows are segmented by lifecycle stage: base infrastructure, observability infrastructure, MOSIP infrastructure, Helmsman app stacks, and destroy/cleanup.

3. **Infrastructure provisioning boundary: Terraform**
   - Terraform owns the **cloud boundary**: VPC/networking, EC2 instances, security groups, DNS, storage, cluster bootstrap, and optional observability management infrastructure.
   - The Terraform tree is split into:
     - `base-infra` for foundational network access and WireGuard/jump-host setup
     - `infra` for the main MOSIP cluster and supporting services
     - `observ-infra` for the optional management plane
   - `terraform/modules/aws` contains reusable units for AWS-specific setup such as RKE2 cluster bootstrap, PostgreSQL setup, NGINX, NFS, and Rancher/Keycloak-related provisioning.

4. **Terraform deployment model and state**
   - Terraform workflows support two backends: **local encrypted state** and **S3 remote state**.
   - Local state is protected with **GPG encryption**; repo scripts handle encrypt/decrypt and backend setup.
   - This means state management is a first-class concern in the architecture: the repo is designed to safely persist infra state across CI runs.

5. **Cloud resources and cluster shape**
   - On AWS, Terraform creates:
     - VPC, subnets, route tables, security groups
     - a **jump server** for access
     - **WireGuard** endpoints for private connectivity
     - EC2-based nodes for **RKE2 Kubernetes**
     - optional external **PostgreSQL** on a dedicated volume
     - DNS records and certificates for service subdomains
   - The infrastructure is built around private networking, with the cluster and supporting services largely accessed through VPN/jump-host boundaries rather than public exposure.

6. **Platform management plane: optional observ-infra**
   - `observ-infra` is a separate, optional cluster used for **Rancher** and **Keycloak**.
   - This plane is intended for operator identity, cluster management, and centralized monitoring rather than MOSIP workloads.
   - If used, it introduces an extra integration boundary: the main cluster must later be registered with Rancher, and Keycloak becomes the identity provider for operator access.

7. **Helmsman as the Kubernetes application layer**
   - Helmsman deploys and manages Helm releases from **Desired State Files (DSFs)** in `Helmsman/dsf`.
   - The DSFs are split by responsibility:
     - `prereq-dsf.yaml` for cluster-wide prerequisites like monitoring, Istio, and logging
     - `external-dsf.yaml` for shared dependencies like PostgreSQL, MinIO, Kafka, and Keycloak
     - `mosip-dsf.yaml` for core MOSIP services
     - `esignet-dsf.yaml` for the eSignet stack
     - `testrigs-dsf.yaml` for test/validation workloads
   - Helmsman is the application boundary where Kubernetes resources are declared, but many low-level prerequisites are injected via hooks and external secrets.

8. **Helmsman hook layer and setup automation**
   - The `Helmsman/hooks` directory contains the operational glue that prepares namespaces, configmaps, secrets, DB state, Istio, SoftHSM, Redis, and test jobs.
   - These hooks are run before/after Helm installs to bridge gaps between cluster state and application readiness.
   - This layer is important architecturally because it handles cross-chart coordination that Helm charts alone do not manage cleanly.

9. **Key runtime dependencies and data flow**
   - The main service stack depends on shared platform services:
     - **PostgreSQL** for persistent data
     - **MinIO** for object storage
     - **Kafka/Activemq** for messaging
     - **Keycloak** for identity/authentication
     - **Istio** for service mesh and ingress routing
     - **Monitoring/logging** components for observability
   - Data flows are mostly internal to the Kubernetes cluster, with DNS routing and Istio gateways exposing the public/internal subdomains.
   - Secrets and access inputs flow from GitHub Secrets into workflows, then into Terraform/Helmsman, and finally into Kubernetes secrets/configmaps or cloud resources.

10. **eSignet and test-rig branch of the architecture**
   - eSignet is an optional stack that extends MOSIP with OIDC and mock identity/relying-party components for identity flows and integration testing.
   - It sits on top of the same shared infrastructure and typically depends on MOSIP core services and Keycloak.
   - Test rigs are a final validation layer: they consume the deployed MOSIP platform and exercise APIs/UI/DSL workflows, making them downstream from the core platform rather than standalone services.

11. **Observability, logging, and mesh boundary**
   - The repo includes dedicated utilities for **monitoring, logging, alerting, and Istio add-ons**.
   - Prometheus/Grafana-style monitoring, alertmanager rules, Kibana dashboards, and logging outputs are treated as shared platform services rather than application-specific features.
   - This subsystem crosses both Terraform and Helmsman: Terraform can provision the management plane, while Helmsman installs the in-cluster observability stack.

12. **Operational lifecycle and teardown**
   - Destroy workflows mirror the deployment structure: there are separate paths for Terraform destroy and Helmsman resource cleanup.
   - Cleanup scripts in both `.github/scripts` and `Helmsman/hooks` reflect that the repo manages stateful infra across multiple layers, so teardown is not a single action.
   - For an architecture diagram, it’s useful to show two independent lifecycles: **provisioning** via Terraform and **application deployment/rollback/cleanup** via Helmsman.

Main entry points: [`Helmsman`](https://github.com/mosip/infra/tree/master/Helmsman) (Helmsman Root), [`.github/workflows`](https://github.com/mosip/infra/blob/master/.github/workflows) (GitHub Actions), [`terraform`](https://github.com/mosip/infra/tree/master/terraform) (Terraform Root), [`terraform/modules/aws`](https://github.com/mosip/infra/tree/master/terraform/modules/aws) (AWS Modules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_ci["CI Orchestration"]
  node_github_actions["GitHub Actions<br/>workflow orchestrator<br/>[workflows]"]
  node_workflow_scripts["Workflow Scripts<br/>bash glue<br/>[scripts]"]
  node_terraform_workflows["Terraform Jobs<br/>ci pipeline<br/>[terraform.yml]"]
  node_helmsman_workflows["Helmsman Jobs<br/>ci pipeline<br/>[helmsman_mosip.yml]"]
  node_destroy_workflows["Destroy Jobs<br/>ci pipeline"]
end

subgraph group_group_tf["Terraform"]
  node_terraform_root["Terraform Root<br/>infra tree"]
  node_base_infra["Base Infra<br/>terraform stage"]
  node_main_infra["MOSIP Infra<br/>terraform stage"]
  node_observ_infra["Observ Infra<br/>terraform stage"]
  node_aws_modules["AWS Modules<br/>terraform modules"]
  node_rke2_cluster["RKE2 Cluster<br/>terraform module"]
  node_shared_services["Shared Services<br/>terraform module"]
  node_rancher_keycloak["Rancher/Keycloak<br/>terraform module"]
end

subgraph group_group_hm["Helmsman"]
  node_helmsman_root["Helmsman Root<br/>deployment tree"]
  node_dsf_sets["DSF Sets<br/>desired state"]
  node_hooks["Hooks<br/>lifecycle glue"]
  node_platform_utils["Platform Utils<br/>k8s assets"]
end

subgraph group_group_ops["Ops Integrations"]
  node_observability(("Observability<br/>shared platform"))
  node_identity_management(("Identity Mgmt<br/>shared platform"))
  node_state_management(("State Mgmt<br/>deployment state<br/>[scripts]"))
end

node_github_actions -->|"invokes"| node_workflow_scripts
node_github_actions -->|"runs"| node_terraform_workflows
node_github_actions -->|"runs"| node_helmsman_workflows
node_github_actions -->|"runs"| node_destroy_workflows
node_workflow_scripts -->|"protects"| node_state_management
node_terraform_workflows -->|"provisions"| node_terraform_root
node_terraform_root -->|"contains"| node_base_infra
node_terraform_root -->|"contains"| node_main_infra
node_terraform_root -->|"contains"| node_observ_infra
node_main_infra -->|"uses"| node_aws_modules
node_aws_modules -->|"includes"| node_rke2_cluster
node_aws_modules -->|"includes"| node_shared_services
node_aws_modules -->|"includes"| node_rancher_keycloak
node_base_infra -.->|"enables access"| node_rke2_cluster
node_observ_infra -->|"integrates"| node_rancher_keycloak
node_helmsman_workflows -->|"deploys"| node_helmsman_root
node_helmsman_root -->|"defines"| node_dsf_sets
node_helmsman_root -->|"executes"| node_hooks
node_helmsman_root -->|"installs"| node_platform_utils
node_platform_utils -->|"provides"| node_observability
node_observ_infra -.->|"supports"| node_identity_management
node_helmsman_root -.->|"consumes"| node_identity_management

click node_github_actions "https://github.com/mosip/infra/blob/master/.github/workflows"
click node_workflow_scripts "https://github.com/mosip/infra/blob/master/.github/scripts"
click node_terraform_workflows "https://github.com/mosip/infra/blob/master/.github/workflows/terraform.yml"
click node_helmsman_workflows "https://github.com/mosip/infra/blob/master/.github/workflows/helmsman_mosip.yml"
click node_destroy_workflows "https://github.com/mosip/infra/blob/master/.github/workflows/destroy-resources.yml"
click node_terraform_root "https://github.com/mosip/infra/tree/master/terraform"
click node_base_infra "https://github.com/mosip/infra/tree/master/terraform/base-infra"
click node_main_infra "https://github.com/mosip/infra/tree/master/terraform/infra"
click node_observ_infra "https://github.com/mosip/infra/tree/master/terraform/observ-infra"
click node_aws_modules "https://github.com/mosip/infra/tree/master/terraform/modules/aws"
click node_rke2_cluster "https://github.com/mosip/infra/tree/master/terraform/modules/aws/rke2-cluster"
click node_shared_services "https://github.com/mosip/infra/tree/master/terraform/modules/aws/postgresql-setup"
click node_rancher_keycloak "https://github.com/mosip/infra/tree/master/terraform/modules/aws/rancher-keycloak-setup"
click node_helmsman_root "https://github.com/mosip/infra/tree/master/Helmsman"
click node_dsf_sets "https://github.com/mosip/infra/tree/master/Helmsman/dsf"
click node_hooks "https://github.com/mosip/infra/tree/master/Helmsman/hooks"
click node_platform_utils "https://github.com/mosip/infra/tree/master/Helmsman/utils"
click node_observability "https://github.com/mosip/infra/tree/master/Helmsman/utils/logging"
click node_identity_management "https://github.com/mosip/infra/tree/master/Rancher-keycloak-integration"
click node_state_management "https://github.com/mosip/infra/blob/master/.github/scripts"

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_github_actions,node_workflow_scripts,node_terraform_workflows,node_helmsman_workflows,node_destroy_workflows toneBlue
class node_terraform_root,node_base_infra,node_main_infra,node_observ_infra,node_aws_modules,node_rke2_cluster,node_shared_services,node_rancher_keycloak toneAmber
class node_helmsman_root,node_dsf_sets,node_hooks,node_platform_utils toneMint
class node_observability,node_identity_management,node_state_management toneRose
```

## Components

### CI Orchestration

GitHub Actions workflows and scripts that drive provisioning, deployment, and teardown.

- [GitHub Actions](https://github.com/mosip/infra/blob/master/.github/workflows): workflow orchestrator · Top-level control plane for deploy, destroy, and integration flows. · `.github/workflows`
- [Workflow Scripts](https://github.com/mosip/infra/blob/master/.github/scripts): bash glue · Shell layer that configures backends, state, secrets, and test execution. · `.github/scripts`
- [Terraform Jobs](https://github.com/mosip/infra/blob/master/.github/workflows/terraform.yml): ci pipeline · Workflow entrypoints for provisioning and destroying infrastructure. · `.github/workflows/terraform.yml`
- [Helmsman Jobs](https://github.com/mosip/infra/blob/master/.github/workflows/helmsman_mosip.yml): ci pipeline · Workflow entrypoints for MOSIP, eSignet, external, and testrig deployment lifecycles. · `.github/workflows/helmsman_mosip.yml`
- [Destroy Jobs](https://github.com/mosip/infra/blob/master/.github/workflows/destroy-resources.yml): ci pipeline · Cleanup and teardown paths for Terraform and Helmsman resources. · `.github/workflows/destroy-resources.yml`

### Terraform

Cloud infrastructure provisioning and state management.

- [Terraform Root](https://github.com/mosip/infra/tree/master/terraform): infra tree · Repository-wide Terraform entrypoints and environment splits. · `terraform`
- [Base Infra](https://github.com/mosip/infra/tree/master/terraform/base-infra): terraform stage · Foundational network access, jump host, and WireGuard setup. · `terraform/base-infra`
- [MOSIP Infra](https://github.com/mosip/infra/tree/master/terraform/infra): terraform stage · Primary AWS cluster and supporting platform services. · `terraform/infra`
- [Observ Infra](https://github.com/mosip/infra/tree/master/terraform/observ-infra): terraform stage · Optional management plane for Rancher and Keycloak. · `terraform/observ-infra`
- [AWS Modules](https://github.com/mosip/infra/tree/master/terraform/modules/aws): terraform modules · Reusable AWS building blocks for cluster bootstrap and shared services. · `terraform/modules/aws`
- [RKE2 Cluster](https://github.com/mosip/infra/tree/master/terraform/modules/aws/rke2-cluster): terraform module · EC2-based Kubernetes cluster bootstrap and worker/control-plane setup. · `terraform/modules/aws/rke2-cluster`
- [Shared Services](https://github.com/mosip/infra/tree/master/terraform/modules/aws/postgresql-setup): terraform module · Reusable provisioning for PostgreSQL, NGINX, NFS, and resource creation. · `terraform/modules/aws/postgresql-setup`
- [Rancher/Keycloak](https://github.com/mosip/infra/tree/master/terraform/modules/aws/rancher-keycloak-setup): terraform module · Optional operator management plane and identity integration setup. · `terraform/modules/aws/rancher-keycloak-setup`

### Helmsman

Kubernetes application deployment, hooks, and platform utilities.

- [Helmsman Root](https://github.com/mosip/infra/tree/master/Helmsman): deployment tree · Desired-state driven Kubernetes application layer. · `Helmsman`
- [DSF Sets](https://github.com/mosip/infra/tree/master/Helmsman/dsf): desired state · Helmsman desired-state files split by prerequisites, shared deps, MOSIP, eSignet, and test rigs. · `Helmsman/dsf`
- [Hooks](https://github.com/mosip/infra/tree/master/Helmsman/hooks): lifecycle glue · Pre/post install automation for namespaces, secrets, databases, mesh, storage, and tests. · `Helmsman/hooks`
- [Platform Utils](https://github.com/mosip/infra/tree/master/Helmsman/utils): k8s assets · Shared charts and manifests for ingress, observability, logging, and service wiring. · `Helmsman/utils`

### Ops Integrations

Cross-cutting operator-management and observability boundaries.

- [Observability](https://github.com/mosip/infra/tree/master/Helmsman/utils/logging): shared platform · Monitoring, logging, alerting, and Istio add-ons spanning Terraform and Helmsman. · `Helmsman/utils/logging`
- [Identity Mgmt](https://github.com/mosip/infra/tree/master/Rancher-keycloak-integration): shared platform · Keycloak and Rancher integration boundary for operator access and cluster registration. · `Rancher-keycloak-integration`
- [State Mgmt](https://github.com/mosip/infra/blob/master/.github/scripts): deployment state · Encrypted local state and remote S3 backend handling for Terraform runs. · `.github/scripts`

## Connections

- GitHub Actions → Workflow Scripts: invokes · Workflows delegate setup, backend configuration, encryption, and cleanup to scripts.
- GitHub Actions → Terraform Jobs: runs · CI entrypoints for terraform apply and destroy operations.
- GitHub Actions → Helmsman Jobs: runs · CI entrypoints for Helmsman deployments across MOSIP and supporting stacks.
- GitHub Actions → Destroy Jobs: runs · Separate teardown flows for infrastructure and Kubernetes resources.
- Workflow Scripts → State Mgmt: protects · Scripts manage GPG encryption, decryption, locking, and backend setup.
- Terraform Jobs → Terraform Root: provisions · Terraform workflows drive the infrastructure tree.
- Terraform Root → Base Infra: contains · Base infrastructure is the foundational provisioning stage.
- Terraform Root → MOSIP Infra: contains · Main cluster and workload infrastructure lives here.
- Terraform Root → Observ Infra: contains · Optional management-plane infrastructure lives here.
- MOSIP Infra → AWS Modules: uses · AWS environments assemble reusable modules.
- AWS Modules → RKE2 Cluster: includes · Cluster bootstrap and node provisioning.
- AWS Modules → Shared Services: includes · Storage, database, and edge-service setup.
- AWS Modules → Rancher/Keycloak: includes · Optional management-plane provisioning.
- Base Infra → RKE2 Cluster: enables access · Jump-host and private connectivity support cluster access.
- Observ Infra → Rancher/Keycloak: integrates · Management cluster and identity services are provisioned together.
- Helmsman Jobs → Helmsman Root: deploys · Helmsman workflows apply desired-state files and hooks.
- Helmsman Root → DSF Sets: defines · Desired-state files describe stack-specific releases.
- Helmsman Root → Hooks: executes · Hooks prepare cluster state before and after Helm actions.
- Helmsman Root → Platform Utils: installs · Shared manifests and charts provide ingress, mesh, logging, and monitoring.
- Platform Utils → Observability: provides · Logging, alerting, dashboards, and Istio add-ons form the observability layer.
- Observ Infra → Identity Mgmt: supports · Rancher and Keycloak are the operator-management boundary.
- Helmsman Root → Identity Mgmt: consumes · Application deployment depends on shared identity and cluster-management services.
