# mosip/mosip-infra architecture

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

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

## Overview

This repository is a deployment/infrastructure repository for MOSIP – the open-source platform for identity management – that provides the scripts, playbooks, Helm charts, and utilities to deploy, configure, and manage MOSIP in both sandbox and production environments. In other words, it is not the application’s business logic per se but rather the “glue” that automates and coordinates the deployment of various MOSIP microservices and external dependencies.

##### Main Components
- Deployment Orchestration: This includes the Ansible playbooks (in the “deployment/sandbox‑v2” directory and various “roles” sub‑directories), Terraform scripts (in the “deployment/terraform” folder), and pre‑/post‑install scripts.
- Helm Charts and Kubernetes Manifests: There are thousands of Helm charts under directories like “deployment/sandbox‑v2/helm/charts”, “deployment/v3” (which cover specific components like config‑server, keycloak, identity modules, and many microservices such as admin, artifactory, ida, idrepo, print, etc.), all of which deploy the MOSIP microservices into K8s clusters.
- External Services Integration: There is a clear separation of “external” subdirectories (e.g., “deployment/v3/external”) that provide deployment scripts and Helm configurations for systems such as keycloak (for IAM), elasticsearch, Kafka, hsm/softhsm, Minio/object-store, and others.
- Utility and Management Tools: The “utils” directory holds several helper scripts (from interacting with master data to managing on‑boarding and secrets) demonstrating support functions that link deployment actions with monitoring, logging, and configuration management.
- Environment-specific Profiles: There are directories for different environment setups (sandbox and production), which show that the deployment pipeline supports multiple profiles, thereby influencing availability and resilience patterns.

##### Relationships and Interactions
- Kubernetes layer where Helm charts are used to deploy the required MOSIP microservices – each microservice (for instance, “mosip/config‑server”, “mosip/idrepo”, “mosip/ida”, etc.) becomes a separate deployment unit within the cluster.
- External dependencies that get integrated during deployment. For example, external systems like Kafka, keycloak, and object storage are deployed/configured by additional scripts and charts in the “deployment/v3/external” folder.
- Out interactions such as:
○ Playbooks triggering helm chart installations.
○ Helm charts interacting with the Kubernetes API.
○ Utility scripts (in the “utils” folder) that extract, compare, or update configuration properties.
○ Terraform scripts provisioning underlying infrastructure (e.g., AWS in “deployment/terraform/aws”).

##### Architectural Patterns and Design Principles
- Microservices Architecture: Each MOSIP component is deployed as a separate microservice, coordinated by Helm charts.
- Infrastructure as Code (IaC): The presence of Terraform along with Ansible and Helm emphasizes a full “declarative” approach to provisioning and configuration.
- Environment Segregation: There are distinct directories for sandbox vs. production profiles, highlighting best practices in isolation and configuration management.
- Extensibility and Modularity: With components separated into discrete Helm charts and Ansible roles, the design strongly adheres to modular design principles.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Infrastructure Provisioning"
        T("Terraform Scripts"):::infra
    end

    subgraph "Deployment Orchestration Layer"
        A1("Ansible Playbooks"):::orchestration
        A2("Ansible Roles"):::orchestration
        A3("Preinstall Script"):::orchestration
        A4("Postinstall Script"):::orchestration
    end

    subgraph "Service Packaging (Kubernetes/Helm)"
        H1("Helm Charts (Sandbox)"):::helm
        H2("MOSIP Microservices (Production)"):::helm
    end

    subgraph "External Service Integrations"
        E("External Services"):::external
    end

    subgraph "Utility & Management Tools"
        U1("Utility Scripts (Sandbox)"):::utils
        U2("Utility Tools (Production)"):::utils
    end

    subgraph "Environment Profiles"
        P("Environment Profiles"):::profiles
    end

    %% Relationships
    T -->|"triggers"| A1
    T -->|"triggers"| A2

    A1 -->|"initiates"| H1
    A2 -->|"assists"| H1
    A3 -->|"prerequisite_for"| A1
    A4 -->|"poststeps_of"| A1

    H1 -->|"deploys"| H2
    H2 -->|"integrates_with"| E

    U1 -->|"monitors"| A1
    U1 -->|"supports"| H1
    U2 -->|"monitors"| H2

    P -->|"configures"| A1
    P -->|"configures"| H2

    %% Click Events
    click A1 "https://github.com/mosip/mosip-infra/tree/master/deployment/sandbox‑v2/playbooks"
    click A2 "https://github.com/mosip/mosip-infra/tree/master/deployment/sandbox‑v2/roles"
    click A3 "https://github.com/mosip/mosip-infra/blob/master/deployment/sandbox‑v2/preinstall.sh"
    click A4 "https://github.com/mosip/mosip-infra/blob/master/deployment/sandbox‑v2/reset.yml"
    click T "https://github.com/mosip/mosip-infra/tree/master/deployment/sandbox‑v2/terraform/aws/sandbox"
    click H1 "https://github.com/mosip/mosip-infra/tree/master/deployment/sandbox‑v2/helm/charts"
    click H2 "https://github.com/mosip/mosip-infra/tree/master/deployment/v3/mosip"
    click E "https://github.com/mosip/mosip-infra/tree/master/deployment/v3/external"
    click U1 "https://github.com/mosip/mosip-infra/tree/master/deployment/sandbox‑v2/utils"
    click U2 "https://github.com/mosip/mosip-infra/tree/master/deployment/v3/utils"
    click P "https://github.com/mosip/mosip-infra/tree/master/deployment/v3/profiles"

    %% Styles
    classDef infra fill:#f9e79f,stroke:#d4ac0d,stroke-width:2px;
    classDef orchestration fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef helm fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
    classDef external fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
    classDef utils fill:#f5cba7,stroke:#e67e22,stroke-width:2px;
    classDef profiles fill:#ebdef0,stroke:#af7ac5,stroke-width:2px;
```
