# mekomsolutions/ozone-distro-cambodia architecture

> Architecture diagram of the GitHub repository mekomsolutions/ozone-distro-cambodia, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mekomsolutions/ozone-distro-cambodia
- Repository: https://github.com/mekomsolutions/ozone-distro-cambodia

## Overview

##### Project type and purpose
- This is a multi-module Maven “assembler” project that bundles:
– An OpenMRS distribution (EMR) pre-configured for NCD/Cervical Cancer screening.
– A Superset analytics/reporting platform pre-loaded with dashboards, charts, datasets.
– Docker-compose files for backing up data and redirecting reports.
- In short, it’s a healthcare information system distribution (“Ozone Kh”) combining a web-based EMR + analytics.

##### File structure
- Top-level modules:
– base/ — common assembly rules, OpenMRS initializer configurations, Superset assets (charts/dashboards/datasets), shared POM.
– prod/ — production assembly overrides.
– scripts/ — wrappers, build scripts, Docker-Compose files.
- base/configs/openmrs/initializer_config — CSV/XML definitions of concepts, encounter types, forms, roles, location hierarchy, etc.
- base/configs/superset/assets — the YAML definitions for charts, dashboards, datasets pre-packed into Superset.
- Assembly descriptors (assembly.xml) in each module define how to produce ZIP/TAR distributions.
- pom.xml hierarchy (root + sub-modules) orchestrates multi-module build.
- .github/workflows + .gitpod.yml + .ocd3.yml handle CI checks, dependency validation, cloud IDE support.

##### README for additional insights
- Purpose: “download and package all the software artefacts that make Ozone for Cambodia.”
- Two runtime environments: OpenMRS SPA login (frontend) and Superset (analytics).

a. Main components:
1. Developer & CI/CD pipeline:
- GitHub repo → GitHub Actions (.github/workflows)
- Maven multi-module build → artifacts (ZIP/TAR)
- Optional publishing to Nexus/public repo
2. Runtime orchestration:
- Docker-Compose orchestration (OpenMRS + DB + Superset + Analytics DB + Redis? as needed)
3. OpenMRS EMR service:
- Tomcat (or embedded container) hosting the Ozone Kh frontend SPA and REST back-end
- Connected to primary relational database (PostgreSQL/MySQL) with initializer data
4. Superset analytics service:
- Flask-based Superset web server
- Metadata DB (PostgreSQL) for user/dashboards
- Analytics DB (could be same or separate PostgreSQL) containing clinical data exported from OpenMRS
5. Configuration & initializer:
- CSV/XML loader that imports concepts, forms, global properties, roles, locations into the EMR DB at startup
- Superset import scripts that load YAML assets into the Superset service at startup

b. Relationships and interactions:
– CI triggers Maven build → produces two distribution bundles (base + prod)
– Ops runs docker-compose-reports-redirect.yml + backup.docker-compose.yml to start services
– On OpenMRS startup, initializer reads base/configs/openmrs/initializer_config → populates DB
– Users interact with the OpenMRS SPA via browser → CRUD patient data
– ETL or direct BI views expose the OpenMRS clinical DB to Superset analytics DB (could be via views or periodic dump)
– Superset connects to analytics DB → users view dashboards and charts loaded from base/configs/superset/assets

c. Architectural patterns & design principles:
– Multi-module Maven for modular builds and dependency isolation
– Separation of concerns: EMR vs. analytics
– Infrastructure as code: Docker-Compose for local/dev setups and scripts for production overrides
– Convention over configuration: assembly.xml descriptors + folder layout
– Idempotent configuration: initializer config files drive reproducible DB setup

d. Key technologies & frameworks:
– Build: Maven, Groovy scripts (build-openmrs-frontend.groovy), GitHub Actions
– Backend: OpenMRS (Java/Spring on Tomcat), CSV/XML Initializer Module
– Frontend: Single Page App (Ozone SPA, React-based ESM modules)
– Analytics: Apache Superset (Python/Flask)
– Data stores: PostgreSQL (or MySQL), possibly Redis or other caches
– Containerization: Docker-Compose, docker files in scripts/

##### Detail is key
– Show external dependencies (Nexus, public repo) if relevant to the deployment.
– Don’t overthink—simply break the project into: Build pipeline, Deployment orchestration, EMR service + initializer, Analytics service, Data stores, and User UIs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build Pipeline
    subgraph "Build Pipeline"
        GH1["GitHub Actions: CI"]:::build
        GH2["GitHub Actions: Dependency Check"]:::build
        GitpodNode["Cloud IDE (Gitpod)"]:::build
        Ocd3Node["Validation Config (.ocd3.yml)"]:::build
        MVNWrapper["Maven Wrapper & Scripts"]:::build
        RootPOM["Root pom.xml"]:::build
        BasePOM["base/pom.xml"]:::build
        ProdPOM["prod/pom.xml"]:::build
        BaseAssembly["base/assembly.xml"]:::build
        SupersetAssembly["base/configs/superset/assembly.xml"]:::build
        ProdAssembly["prod/assembly.xml"]:::build
    end

    %% Artifacts
    Artifacts["Distribution Artifacts (ZIP/TAR)"]:::build

    %% Deployment Orchestration
    subgraph "Deployment Orchestration"
        DockerCompose["Docker-Compose Orchestration"]:::infrastructure
        BackupCompose["Backup Docker-Compose"]:::infrastructure
        ComposeList["Compose Files List"]:::infrastructure
    end

    %% Service Layer
    subgraph "Service Layer"
        subgraph "EMR Service"
            OpenMRSInit["Initializer Configs"]:::emr
            SPAAsmConfig["SPA Assembly Config"]:::emr
            OpenMRSFrontend["OpenMRS SPA + REST API"]:::emr
            EMRDB["Primary DB (PostgreSQL/MySQL)"]:::infrastructure
        end
        subgraph "Analytics Service"
            SupersetWeb["Superset Web UI & API"]:::analytics
            SupersetAssets["Superset Assets"]:::analytics
            MetaDB["Metadata DB"]:::infrastructure
            AnalyticsDB["Analytics DB"]:::infrastructure
        end
    end

    Browser["User Browser"]:::external

    %% Connections - Build Pipeline
    GH1 --> RootPOM
    GH2 --> RootPOM
    GitpodNode --> RootPOM
    Ocd3Node --> RootPOM
    MVNWrapper --> RootPOM
    RootPOM --> BasePOM
    RootPOM --> ProdPOM
    BasePOM --> BaseAssembly
    BasePOM --> SupersetAssembly
    ProdPOM --> ProdAssembly
    BaseAssembly --> Artifacts
    SupersetAssembly --> Artifacts
    ProdAssembly --> Artifacts

    %% Deployment
    Artifacts --> DockerCompose
    DockerCompose --> OpenMRSFrontend
    DockerCompose --> SupersetWeb
    DockerCompose --> EMRDB
    DockerCompose --> MetaDB
    DockerCompose --> AnalyticsDB
    BackupCompose --> EMRDB
    ComposeList --> DockerCompose

    %% EMR Service Init
    OpenMRSInit --> EMRDB
    OpenMRSInit --> OpenMRSFrontend
    SPAAsmConfig --> OpenMRSFrontend

    %% Data flows
    EMRDB -->|"ETL/BI Views"| AnalyticsDB
    SupersetAssets --> SupersetWeb
    AnalyticsDB --> SupersetWeb
    MetaDB --> SupersetWeb

    %% User interactions
    Browser --> OpenMRSFrontend
    Browser --> SupersetWeb

    %% Click Events
    click GH1 "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/.github/workflows/ci.yml"
    click GH2 "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/.github/workflows/check-deps.yml"
    click GitpodNode "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/.gitpod.yml"
    click Ocd3Node "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/.ocd3.yml"
    click MVNWrapper "https://github.com/mekomsolutions/ozone-distro-cambodia/tree/main/base/scripts/"
    click RootPOM "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/pom.xml"
    click BasePOM "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/base/pom.xml"
    click ProdPOM "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/prod/pom.xml"
    click BaseAssembly "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/base/assembly.xml"
    click SupersetAssembly "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/base/configs/superset/assembly.xml"
    click ProdAssembly "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/prod/assembly.xml"
    click SupersetAssets "https://github.com/mekomsolutions/ozone-distro-cambodia/tree/main/base/configs/superset/assets/"
    click OpenMRSInit "https://github.com/mekomsolutions/ozone-distro-cambodia/tree/main/base/configs/openmrs/initializer_config/"
    click SPAAsmConfig "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/base/configs/openmrs/frontend_assembly/spa-assemble-config.json"
    click DockerCompose "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/base/scripts/docker-compose-reports-redirect.yml"
    click BackupCompose "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/base/scripts/backup.docker-compose.yml"
    click ComposeList "https://github.com/mekomsolutions/ozone-distro-cambodia/blob/main/base/scripts/docker-compose-files.txt"

    %% Styles
    classDef build fill:#a2f5a2,stroke:#333,stroke-width:1px
    classDef infrastructure fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef emr fill:#a2d2f5,stroke:#333,stroke-width:1px
    classDef analytics fill:#f5cba2,stroke:#333,stroke-width:1px
    classDef external fill:#eeeeee,stroke:#333,stroke-width:1px
```
