# jembi/platform architecture

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

- Interactive diagram: https://gitdiagram.com/jembi/platform
- Repository: https://github.com/jembi/platform

## Overview

##### Main Components

a. Core Infrastructure Layer:
- Docker Swarm Orchestration
- Reverse Proxies (Nginx/Traefik)
- Identity Access Management (Keycloak)
- Monitoring Stack (Prometheus/Grafana/Loki)

b. Data Storage Layer:
- FHIR Datastore (HAPI FHIR)
- Analytics Datastores (Clickhouse & Elasticsearch)
- Client Registry (JEMPI/SanteMPI)
- PostgreSQL Database
- Data Lake Storage

c. Message Processing Layer:
- Interoperability Layer (OpenHIM)
- Message Bus (Kafka)
- Data Mappers (Logstash)
- Kafka Consumers (Mapper & Unbundler)

d. Visualization Layer:
- Dashboard Visualizers (Superset, Kibana, JSReport)
- Monitoring Dashboards

##### Component Grouping

- Reverse Proxy Layer                                     |
- (Nginx/Traefik)                                                                        |

- Security Layer                                         |
- (Keycloak)                                                                            |

- Data Ingestion|    |  Processing      |    |  Storage            |                |
- OpenHIM       |    |  Kafka           |    |  HAPI FHIR          |                |
- Mediators     |--->|  Logstash        |--->|  Clickhouse         |                |
- Consumers       |    |  Elasticsearch      |                |

- Visualization Layer                                    |
- (Superset, Kibana, JSReport)                                                          |

- Monitoring Layer                                       |
- (Prometheus, Grafana, Loki)                                                           |

##### Technical Details

- Port mappings for key services
- Volume mounts for persistent storage
- Network segregation
- Resource allocation indicators
- Scaling indicators for clustered services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style Definitions
    classDef proxy fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef security fill:#FF6B6B,stroke:#333,stroke-width:2px
    classDef processing fill:#90EE90,stroke:#333,stroke-width:2px
    classDef storage fill:#FFD700,stroke:#333,stroke-width:2px
    classDef visualization fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef monitoring fill:#A9A9A9,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#B8860B,stroke:#333,stroke-width:2px

    subgraph Proxy["Reverse Proxy Layer"]
        NGINX["Nginx Proxy"]:::proxy
        TRAEFIK["Traefik Proxy"]:::proxy
    end

    subgraph Security["Security Layer"]
        KEYCLOAK["Keycloak IAM"]:::security
    end

    subgraph Processing["Processing Layer"]
        OPENHIM["OpenHIM"]:::processing
        KAFKA["Kafka Message Bus"]:::processing
        LOGSTASH["Logstash"]:::processing
        MAPPER["Kafka Mapper"]:::processing
        UNBUNDLER["Kafka Unbundler"]:::processing
    end

    subgraph Storage["Storage Layer"]
        HAPI["HAPI FHIR"]:::storage
        CLICKHOUSE["Clickhouse"]:::storage
        ELASTIC["Elasticsearch"]:::storage
        POSTGRES["PostgreSQL"]:::storage
        DATALAKE["Data Lake"]:::storage
        JEMPI["JEMPI"]:::storage
        SANTEMPI["SanteMPI"]:::storage
    end

    subgraph Visualization["Visualization Layer"]
        SUPERSET["Superset"]:::visualization
        KIBANA["Kibana"]:::visualization
        JSREPORT["JSReport"]:::visualization
    end

    subgraph Monitoring["Monitoring Layer"]
        PROMETHEUS["Prometheus"]:::monitoring
        GRAFANA["Grafana"]:::monitoring
        LOKI["Loki"]:::monitoring
    end

    subgraph Infrastructure["Infrastructure Management"]
        ANSIBLE["Ansible"]:::infrastructure
        TERRAFORM["Terraform"]:::infrastructure
    end

    %% Relationships
    NGINX --> KEYCLOAK
    TRAEFIK --> KEYCLOAK
    KEYCLOAK --> OPENHIM
    OPENHIM --> KAFKA
    KAFKA --> LOGSTASH
    KAFKA --> MAPPER
    KAFKA --> UNBUNDLER
    LOGSTASH --> ELASTIC
    MAPPER --> HAPI
    UNBUNDLER --> CLICKHOUSE
    HAPI --> DATALAKE
    CLICKHOUSE --> SUPERSET
    ELASTIC --> KIBANA
    POSTGRES --> JSREPORT
    JEMPI --> POSTGRES
    SANTEMPI --> POSTGRES

    %% Monitoring Connections
    PROMETHEUS -.-> NGINX
    PROMETHEUS -.-> OPENHIM
    PROMETHEUS -.-> KAFKA
    GRAFANA -.-> PROMETHEUS
    LOKI -.-> GRAFANA

    %% Click Events
    click NGINX "https://github.com/jembi/platform/tree/main/reverse-proxy-nginx"
    click TRAEFIK "https://github.com/jembi/platform/tree/main/reverse-proxy-traefik"
    click KEYCLOAK "https://github.com/jembi/platform/tree/main/identity-access-manager-keycloak"
    click PROMETHEUS "https://github.com/jembi/platform/tree/main/monitoring/prometheus"
    click GRAFANA "https://github.com/jembi/platform/tree/main/monitoring/grafana"
    click LOKI "https://github.com/jembi/platform/tree/main/monitoring/loki"
    click HAPI "https://github.com/jembi/platform/tree/main/fhir-datastore-hapi-fhir"
    click CLICKHOUSE "https://github.com/jembi/platform/tree/main/analytics-datastore-clickhouse"
    click ELASTIC "https://github.com/jembi/platform/tree/main/analytics-datastore-elastic-search"
    click JEMPI "https://github.com/jembi/platform/tree/main/client-registry-jempi"
    click SANTEMPI "https://github.com/jembi/platform/tree/main/client-registry-santempi"
    click POSTGRES "https://github.com/jembi/platform/tree/main/database-postgres"
    click DATALAKE "https://github.com/jembi/platform/tree/main/datalake"
    click OPENHIM "https://github.com/jembi/platform/tree/main/interoperability-layer-openhim"
    click KAFKA "https://github.com/jembi/platform/tree/main/message-bus-kafka"
    click LOGSTASH "https://github.com/jembi/platform/tree/main/data-mapper-logstash"
    click MAPPER "https://github.com/jembi/platform/tree/main/kafka-mapper-consumer"
    click UNBUNDLER "https://github.com/jembi/platform/tree/main/kafka-unbundler-consumer"
    click SUPERSET "https://github.com/jembi/platform/tree/main/dashboard-visualiser-superset"
    click KIBANA "https://github.com/jembi/platform/tree/main/dashboard-visualiser-kibana"
    click JSREPORT "https://github.com/jembi/platform/tree/main/dashboard-visualiser-jsreport"
    click ANSIBLE "https://github.com/jembi/platform/tree/main/infrastructure/ansible"
    click TERRAFORM "https://github.com/jembi/platform/tree/main/infrastructure/terraform"
```
