# bettermedicine/ohif architecture

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

- Interactive diagram: https://gitdiagram.com/bettermedicine/ohif
- Repository: https://github.com/bettermedicine/ohif

## Overview

##### Main Components
- Viewer Application: This is the client‑facing progressive web app (PWA) contained in platform/app. It hosts the main user interface for rendering medical images.
- Core Business Logic: Found in platform/core, it encapsulates the essential services like the DICOM metadata store, display set services, hanging protocol management, panel coordination, and more.
- UI Library/Components: Under platform/ui (and platform/ui‑next), this houses the React component library that supplies the widgets (buttons, panels, toolbars, dialogs, etc.) used by the viewer.
- Extensions: The extensions directory contains modular plug‑ins for various functionalities (e.g., segmentation, measurement tracking, volume rendering, PDF and DICOM RT handling, and even whole slide microscopy). These enable high customizability and can be visualized as plugins that integrate with the core system.
- Modes: The modes folder provides different “modes” or configurations of the viewer (like basic development, longitudinal, TMTV, microscopy, etc.) that adapt behaviors/configurations for specific use cases.
- Supporting Modules:
- Internationalization (platform/i18n)
- Documentation (platform/docs)
- CLI tools (platform/cli) and project-level configuration (lerna.json, package.json, etc.)

- Viewer (platform/app) as the central user interface that communicates with the core business logic (platform/core) via clearly defined services.
- That the UI components (from platform/ui/ui‑next) feed into the viewer.
- Integration of extensions into the core architecture – for example, using a plug‑in pattern where extensions (e.g., cornerstone, dicom‑pdf, measurement‑tracking) extend or override default behaviors.
- CI/CD and deployment aspects (like Docker configuration, Netlify, CircleCI workflows) as supporting infrastructure components that deploy the viewer.

##### Architectural Patterns and Design Principles
- Modular and Plugin-based Architecture: Separate business logic, UI, and functionality are designed to be decoupled. Extensions and modes define clear interfaces for integration.
- Monorepo Project Organization: Managed with Lerna and Yarn Workspaces, which coordinates shared dependencies and common configuration across modules.
- Separation of Concerns: Notice that data access (DICOMweb via dedicated modules) is separated from presentation (UI components).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "OHIF Medical Imaging Viewer"
        direction TB
        External["DICOMweb Data Source"]:::external

        subgraph "Core Services"
            direction TB
            Core["Platform Core Business Logic"]:::core
            External -->|"DICOMData"| Core
        end

        subgraph "UI Components"
            direction TB
            UI1["Platform UI Components"]:::ui
            UI2["Platform UI‑Next"]:::ui
            Core -->|"FeedsData"| UI1
            Core -->|"FeedsData"| UI2
        end

        subgraph "Viewer Shell"
            direction TB
            Viewer["Viewer Application (PWA)"]:::viewer
            Modes["Modes/Configurations"]:::mode
            Viewer -->|"Configures"| Modes
            Viewer <-->|"IntegratesWith"| UI1
            Viewer <-->|"IntegratesWith"| UI2
        end

        subgraph "Extensions Ecosystem"
            direction TB
            Extensions["Extensions/Plugins"]:::extension
            Core -->|"PluginIntegration"| Extensions
            UI1 -->|"UIExtension"| Extensions
            UI2 -->|"UIExtension"| Extensions
        end

        subgraph "Supporting Modules"
            direction TB
            I18n["Internationalization Module"]:::support
            Docs["Documentation"]:::support
            CLI["CLI Tools & Configurations"]:::support
        end

        subgraph "Supporting Infrastructure"
            direction TB
            Infra["CI/CD & Deployment"]:::infra
        end

        Core -->|"SendsUpdates"| Viewer
        Viewer -->|"UserCommands"| Core
        Viewer -->|"Uses"| UI1
        Viewer -->|"Uses"| UI2
        Modes -->|"Customizes"| Viewer
        Infra --- Core
        Infra --- Viewer
        Infra --- Extensions
    end

click Viewer "https://github.com/bettermedicine/ohif/tree/master/platform/app"
click Core "https://github.com/bettermedicine/ohif/tree/master/platform/core"
click UI1 "https://github.com/bettermedicine/ohif/tree/master/platform/ui"
click UI2 "https://github.com/bettermedicine/ohif/tree/master/platform/ui‑next"
click Extensions "https://github.com/bettermedicine/ohif/tree/master/extensions"
click Modes "https://github.com/bettermedicine/ohif/tree/master/modes"
click I18n "https://github.com/bettermedicine/ohif/tree/master/platform/i18n"
click Docs "https://github.com/bettermedicine/ohif/tree/master/platform/docs"
click CLI "https://github.com/bettermedicine/ohif/tree/master/platform/cli"

classDef viewer fill:#f9f,stroke:#333,stroke-width:2px;
classDef core fill:#b3d9ff,stroke:#333,stroke-width:2px;
classDef ui fill:#c2f0c2,stroke:#333,stroke-width:2px;
classDef extension fill:#ffcc99,stroke:#333,stroke-width:2px;
classDef mode fill:#ffe6e6,stroke:#333,stroke-width:2px;
classDef support fill:#e6e6e6,stroke:#333,stroke-width:2px;
classDef infra fill:#d9d9d9,stroke:#333,stroke-width:2px;
classDef external fill:#ffd1dc,stroke:#333,stroke-width:2px;
```
