# mdcurtis/micromanager-upstream architecture

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

- Interactive diagram: https://gitdiagram.com/mdcurtis/micromanager-upstream
- Repository: https://github.com/mdcurtis/micromanager-upstream

## Overview

##### Project type and purpose
- This is Micro-Manager, an open-source, cross-platform microscopy control system. It consists of:
- A native C++ core library (MMCore) that manages device communication and acquisition logic
- A device abstraction layer (MMDevice) and many DeviceAdapter modules (DLLs/.so) that drive microscope hardware
- A Java Swing desktop application (MMStudio) that provides the user interface and a plugin framework
- Language bindings (SWIG-generated Java & Python wrappers) and scripting support (Beanshell, Clojure)
- A rich plugin ecosystem (pure-Java modules under plugins/) for specialized acquisition or analysis tasks

A. MMCore (C++ core)
– Manages overall system state, acquisition sequences, logging, configuration
– Exposes a plugin/adapter API for hardware modules
B. MMDevice (C++ module interface)
– Defines abstract base classes and threading support for any device type
– Loads individual DeviceAdapter shared libraries at runtime
C. DeviceAdapters (C++ shared libraries)
– One adapter per hardware device: cameras, stages, shutters, lasers, etc.
– Implements MMDevice interfaces to translate generic device calls into hardware-specific driver calls or DLL calls
D. Java Wrappers
– MMCoreJ_wrap: SWIG-generated JNI glue for Java (MMStudio)
– MMCorePy_wrap: SWIG-generated wrapper for Python scripts
E. MMStudio (Java Swing UI)
– Front-end application, loads MMCore via JNI, offers configuration panels, live view, acquisition controls, plugin manager
– Hosts pure-Java plugins (src in plugins/… package hierarchy) that implement the MMPlugin API
F. Scripting engines & CLI
– Beanshell scripts (scripts/*.bsh) executed by MMStudio’s embedded interpreter
– Clojure/Ant-based modules for specialized tasks
G. External interfaces
– Python libraries (MMCorePy) for programmatic control
– Command-line batch utilities (Test_Programs, systemtest, etc.)

##### Relationships and data flows
- MMStudio (Java UI) ←→ MMCore (JNI calls)
- MMCore loads MMDevice modules (dynamic shared libraries) via PluginManager
- MMDevice base classes dispatch calls to concrete DeviceAdapters
- DeviceAdapters ↔ hardware drivers (OS-level DLLs/USB/serial)
- MMCore emits events (image frames, device status) back up to Java or Python via callback mechanisms
- User scripts (Beanshell, Python) call MMCore or MMStudio API to automate acquisitions

##### Important architectural patterns
- Plugin architecture: decoupled hardware layer (DeviceAdapters) from core logic
- Adapter pattern: DeviceAdapters implement uniform MMDevice interface to support many hardware types
- Layered pattern: UI layer (Java) atop core library (C++), with language wrappers mediating
- Event-driven design: acquisition events propagate from core to UI/plugins

##### Technologies & frameworks
- C++ (MMCore, MMDevice, DeviceAdapters)
- SWIG + JNI for Java (MMCoreJ_wrap)
- SWIG + Python C/API for Python bindings (MMCorePy_wrap)
- Java Swing for UI, Ant/Maven/Clojure for builds and scripting
- Make/autotools for native C++ modules, Visual Studio project files for Windows builds

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Java Layer
    subgraph "Java Layer"
        direction TB
        MMStudio["MMStudio (Java Swing UI)"]:::java
        PureJavaPlugins["Pure-Java Plugins"]:::plugin
        Beanshell["Beanshell Scripts"]:::script
        Clojure["Clojure Modules"]:::script
    end

    %% Wrappers
    MMStudio -->|"JNI calls"| JNIWrapper["SWIG JNI Wrapper"]:::wrapper
    Beanshell -->|"Beanshell Interpreter"| MMStudio
    Clojure -->|"Ant/Clojure Tasks"| MMStudio
    subgraph "Language Bindings"
        direction TB
        JNIWrapper
        PyWrapper["SWIG Python Wrapper"]:::wrapper
    end

    %% C++ Core Layer
    subgraph "C++ Core" 
        direction TB
        MMCore["MMCore (C++ Core)"]:::core
        Logs["Config / Logs"]:::storage
        MMCore -->|"manages config"| Logs
        MMCore -->|"loads modules via"| PluginMgr["PluginManager"]:::core
        PluginMgr -->|"loads"| MMDevice["MMDevice (Abstract Interface)"]:::core
        MMDevice -->|"dispatches to"| DeviceAdapterFactory["DeviceAdapter Factory"]:::core
        DeviceAdapterFactory -->|"loads adapters"| DeviceAdapters["DeviceAdapters (DLL/.so)"]:::core
    end

    %% External Hardware
    DeviceAdapters -->|"hardware calls"| Hardware["Hardware Drivers"]:::hardware

    %% Callbacks and scripting
    MMCore -->|"events/callbacks"| MMStudio
    MMCore -->|"events/callbacks"| PyWrapper

    %% CLI Utilities
    subgraph "CLI & Tests"
        direction TB
        TestProg["Test_Programs CLI"]:::cli
        SysTest["System Tests"]:::cli
    end
    TestProg -->|"uses"| MMCore
    SysTest -->|"Java Seq Tests"| MMStudio

    %% Python control
    subgraph "External Interfaces"
        direction TB
        PyWrapper -->|"calls"| MMCore
    end

    %% Click Events
    click MMCore "https://github.com/mdcurtis/micromanager-upstream/tree/master/MMCore/"
    click MMDevice "https://github.com/mdcurtis/micromanager-upstream/tree/master/MMDevice/"
    click DeviceAdapters "https://github.com/mdcurtis/micromanager-upstream/tree/master/DeviceAdapters/"
    click JNIWrapper "https://github.com/mdcurtis/micromanager-upstream/tree/master/MMCoreJ_wrap/"
    click PyWrapper "https://github.com/mdcurtis/micromanager-upstream/tree/master/MMCorePy_wrap/"
    click MMStudio "https://github.com/mdcurtis/micromanager-upstream/tree/master/mmstudio/"
    click PureJavaPlugins "https://github.com/mdcurtis/micromanager-upstream/tree/master/plugins/"
    click Beanshell "https://github.com/mdcurtis/micromanager-upstream/tree/master/scripts/"
    click Clojure "https://github.com/mdcurtis/micromanager-upstream/tree/master/acqEngine/"
    click TestProg "https://github.com/mdcurtis/micromanager-upstream/tree/master/Test_Programs/"
    click SysTest "https://github.com/mdcurtis/micromanager-upstream/tree/master/systemtest/"

    %% Styles
    classDef core fill:#AED6F1,stroke:#217DBB,color:#000
    classDef java fill:#A9DFBF,stroke:#28B463,color:#000
    classDef wrapper fill:#D2B4DE,stroke:#8E44AD,color:#000
    classDef plugin fill:#F9E79F,stroke:#B7950B,color:#000
    classDef script fill:#FAD7A0,stroke:#CA6F1E,color:#000
    classDef storage fill:#F5CBA7,stroke:#BA4A00,color:#000
    classDef hardware fill:#F5B7B1,stroke:#C0392B,color:#000
    classDef cli fill:#D5DBDB,stroke:#616A6B,color:#000
```
