# electronicarts/iris architecture

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

- Interactive diagram: https://gitdiagram.com/electronicarts/iris
- Repository: https://github.com/electronicarts/iris

## Overview

##### Project type and purpose
- IRIS is an open-source C++ library (with an optional example console application) whose purpose is to analyze video content and detect photosensitive epilepsy risks (luminance flashes, red saturation flashes, spatial patterns). It’s built with CMake, uses vcpkg for dependencies, and comes with unit tests.

##### File structure
- Top-level components:
- cmake, CMakeLists.txt, CMakePresets.json: build system
- /iris & src/: core IRIS library (public headers + implementation)
- utils/: supporting utility library (logging, JSON wrapper, frame conversion)
- example/: console application exercising the IRIS library
- config/: appsettings.json (configurable thresholds, toggles)
- test/: unit tests project with test data (videos, images)
- vcpkg.json: external dependency manifest
- The core library follows a pipeline/pipeline-of-responsibility style: FrameManagers → Converters → Detection modules → Result aggregation.

##### README for additional insights
- Describes detection criteria, CSV/JSON output format, example app command-line flags, build instructions (CMake presets, vcpkg integration), and configuration options.

##### Components
a. Main components
1. External Inputs & Configuration
- Video files (e.g. .mp4)
- config/appsettings.json
2. IRIS Core Library
- VideoAnalyser (orchestrator)
- FrameManagers (FpsFrameManager, TimeFrameManager via IFrameManager)
- FrameRgbConverter
- Detection modules:
- FlashDetection (Luminance & Red via RelativeLuminance, RedSaturation)
- PatternDetection
- TransitionTracker (tracks per-second counts)
- ScopeProfiler (performance measurement)
- Log (logging abstraction)
3. Utils Library
- BaseLog, JsonWrapper, FrameConverter
4. Output Writers
- CSVWriter (built into IRIS)
- JsonWriter (optional via –j flag)
5. Example App
- CLI parser (–v, –p, –j flags)
- Invokes IRIS Core, points at input/output directories
6. Tests
- Unit tests (gtest) calling core library APIs, using test videos/images

b. Relationships & interactions
- Example App reads CLI args → loads config JSON → feeds video file paths → calls VideoAnalyser API
- VideoAnalyser: for each frame, uses IFrameManager to fetch frames → FrameRgbConverter → passes frame to detection modules → collects partial FrameData → TransitionTracker computes per-second/extended counts → modules update Result objects
- At end of video, VideoAnalyser writes results via CSVWriter/JsonWriter
- ScopeProfiler wraps critical sections → records timings → Log outputs profiling results
- Utils library is linked by both core and example code (logging, JSON)
- Tests exercise each detection module independently and end-to-end on sample videos

c. Architectural patterns & design principles
- Pipeline pattern: frame processing is a sequence of pluggable steps
- Dependency inversion: IFrameManager interface → concrete implementations for FPS/time-based iteration
- Separation of concerns: distinct modules for configuration, logging, conversion, detection, aggregation, profiling
- Configurable thresholds loaded at runtime from JSON

d. Relevant technologies/frameworks/libraries
- CMake (build) + Ninja (default build tool)
- vcpkg (dependency manager)
- Google Test (unit testing)
- JSON library (via utils/JsonWrapper)
- Standard C++17 (or later), cross-platform

##### Detailed coverage
- Public interfaces (include/iris/*.h) as API boundary
- Test harness invoking specific modules (optional overlay)
- Config parameters (flash threshold, pattern enable flag) near the config component
- Build process with a side note: CMake → vcpkg → library & example app

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Inputs & Configuration
    subgraph "External Inputs & Configuration"
        VideoFile["Video File (.mp4)"]:::external
        ConfigJson["appsettings.json"]:::external
    end

    %% IRIS Core Library
    subgraph "IRIS Core Library"
        VideoAnalyser["VideoAnalyser"]:::core
        IFrameManager["IFrameManager"]:::core
        FpsFrameManager["FpsFrameManager"]:::core
        TimeFrameManager["TimeFrameManager"]:::core
        FrameRgbConverter["FrameRgbConverter"]:::core
        FlashDetection["FlashDetection Module"]:::core
        PatternDetection["PatternDetection Module"]:::core
        TransitionTracker["TransitionTracker"]:::core
        ScopeProfiler["ScopeProfiler"]:::core
        LogCore["Log"]:::core
        CSVWriter["CSVWriter"]:::core
        JsonWriter["JsonWriter"]:::core
    end

    %% Utils Library
    subgraph "Utils Library"
        BaseLog["BaseLog"]:::utils
        JsonWrapper["JsonWrapper"]:::utils
        FrameConverter["FrameConverter"]:::utils
    end

    %% Example Application
    subgraph "Example Application"
        CLI["CLI Parser"]:::example
    end

    %% Unit Tests
    subgraph "Unit Tests"
        Tests["GTest Suite"]:::tests
    end

    %% Data Flow
    VideoFile -->|"input path"| CLI
    ConfigJson -->|"load thresholds"| CLI
    CLI -->|"calls API"| VideoAnalyser
    VideoAnalyser -->|"uses"| IFrameManager
    IFrameManager -->|"FPS mode"| FpsFrameManager
    IFrameManager -->|"Time mode"| TimeFrameManager
    FpsFrameManager --> FrameRgbConverter
    TimeFrameManager --> FrameRgbConverter
    FrameRgbConverter --> FlashDetection
    FrameRgbConverter --> PatternDetection
    FlashDetection --> TransitionTracker
    PatternDetection --> TransitionTracker
    TransitionTracker --> CSVWriter
    TransitionTracker --> JsonWriter
    VideoAnalyser -.-> ScopeProfiler
    ScopeProfiler -.-> LogCore

    %% Utils dependencies
    VideoAnalyser --> BaseLog
    VideoAnalyser --> JsonWrapper
    FrameConverter --> FlashDetection
    CLI --> BaseLog
    CLI --> JsonWrapper
    Tests --> VideoAnalyser
    Tests --> FlashDetection
    Tests --> PatternDetection

    %% Output
    CSVWriter -->|"writes .csv"| OutputCSV["Results.csv"]:::external
    JsonWriter -->|"writes .json"| OutputJSON["Results.json"]:::external

    %% Click Events
    click ConfigJson "https://github.com/electronicarts/iris/blob/main/config/appsettings.json"
    click VideoAnalyser "https://github.com/electronicarts/iris/blob/main/include/iris/VideoAnalyser.h"
    click LogCore "https://github.com/electronicarts/iris/blob/main/include/iris/Log.h"
    click ScopeProfiler "https://github.com/electronicarts/iris/blob/main/include/iris/ScopeProfiler.h"
    click IFrameManager "https://github.com/electronicarts/iris/blob/main/src/IFrameManager.h"
    click FpsFrameManager "https://github.com/electronicarts/iris/blob/main/src/FpsFrameManager.h"
    click TimeFrameManager "https://github.com/electronicarts/iris/blob/main/src/TimeFrameManager.h"
    click FrameRgbConverter "https://github.com/electronicarts/iris/blob/main/src/FrameRgbConverter.h"
    click FlashDetection "https://github.com/electronicarts/iris/blob/main/src/FlashDetection.h"
    click PatternDetection "https://github.com/electronicarts/iris/blob/main/src/PatternDetection.h"
    click TransitionTracker "https://github.com/electronicarts/iris/blob/main/src/TransitionTracker.h"
    click BaseLog "https://github.com/electronicarts/iris/blob/main/utils/include/utils/BaseLog.h"
    click JsonWrapper "https://github.com/electronicarts/iris/blob/main/utils/include/utils/JsonWrapper.h"
    click FrameConverter "https://github.com/electronicarts/iris/blob/main/utils/include/utils/FrameConverter.h"
    click CLI "https://github.com/electronicarts/iris/blob/main/example/main.cpp"
    click Tests "https://github.com/electronicarts/iris/blob/main/test/Iris.Tests/CMakeLists.txt"

    %% Styles
    classDef external fill:#dddddd,stroke:#444,stroke-width:1px,color:#000;
    classDef core fill:#bbdefb,stroke:#1e88e5,stroke-width:1px,color:#000;
    classDef utils fill:#c8e6c9,stroke:#43a047,stroke-width:1px,color:#000;
    classDef example fill:#ffe0b2,stroke:#fb8c00,stroke-width:1px,color:#000;
    classDef tests fill:#e1bee7,stroke:#8e24aa,stroke-width:1px,color:#000;
```
