# phyphox/phyphox-ios architecture

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

- Interactive diagram: https://gitdiagram.com/phyphox/phyphox-ios
- Repository: https://github.com/phyphox/phyphox-ios

## Overview

##### Main Components
- phyphox-iOS App: This is the core application containing the UI, business logic, and integration with iOS native services. It is structured as an Xcode project (see the phyphox.xcodeproj directory) and consists of several logical layers such as:
– Application Lifecycle and App Delegate (e.g., AppDelegate.swift).
– User Interface Modules for the main view, dialogs, experiment views, navigation controllers, and localized resources.
– Experiment Management: Located under the “Experiments” folder, including submodules for data input, analysis, export, network connection, serialization, and view descriptors.
- phyphox-experiments (submodule): Contains definitions of physics experiments.
- phyphox-webinterface (submodule): Manages the web interface served by the app when remote features are activated.

##### Representing the Layers and Interactions
– Experiment Handling Layer: Show components responsible for processing experiment data, such as the Experiment Manager, Experiment Serialization, and Experiment Analysis Modules. Within this, indicate submodules for various types of analyses (e.g., FFTAnalysis, IntegrationAnalysis, Signal analysis modules in the “Experiments/Analysis/Modules” directory). Label these nodes accordingly.
– Data Input/Output Layer: Include modules handling sensor input (Bluetooth, GPS, sensor inputs) and output (like ExperimentAudioOutput, ExperimentBluetoothOutput).

##### Architectural Patterns and Principles
- Modular/Layered Architecture: Emphasize the separation between UI, business logic (experiment processing/serialization), and external modules.
- MVC/MVVM Characteristics: Many files in the UI directory follow a pattern where controllers manage a set of views corresponding to various experiment activities.
- Localization Support: Indicate the dedicated localization resources (the multiple .lproj directories and Settings bundle) as a cross-cutting concern that interacts with the UI layer.
- Test and Validation: Represent the Tests layer (phyphoxTests) which ensures reliability of components like buffer management, document deserialization, and overall experiment data handling.

##### Details to Emphasize
- Be specific about each layer: starting from iOS-specific application lifecycle management, then breaking down the experiment-related logic (analysis, input/output, data serialization), and finally showing how external submodules are integrated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core App
    subgraph "phyphox-iOS App"
        A1["Xcode Project"]:::core
        A2["App Delegate"]:::core
    end

    %% UI Layer
    subgraph "UI Layer"
        UI1["Main UI"]:::ui
        UI2["Experiment View"]:::ui
        UI3["Navigation Controller"]:::ui
        UI4["Collection View"]:::ui
        UI5["UI Extensions"]:::ui
    end

    %% Experiment Management
    subgraph "Experiment Management"
        EM1["Experiment Manager"]:::experiment
        EM2["Analysis Modules"]:::experiment
        EM3["Data Input Module"]:::experiment
        EM4["Data Output Module"]:::experiment
        EM5["Serialization"]:::experiment
        EM6["Export"]:::experiment
    end

    %% External Submodules
    subgraph "External Submodules"
        EX1["phyphox-experiments"]:::external
        EX2["phyphox-webinterface"]:::external
    end

    %% Helper Libraries
    subgraph "Helper Libraries & Utilities"
        HL["Helper Libraries"]:::helper
    end

    %% Localization & Resources
    subgraph "Localization & Resources"
        L1["Localized Resources (.lproj)"]:::localization
        L2["Settings Bundle"]:::localization
        L3["Assets"]:::localization
        L4["Colors"]:::localization
    end

    %% Build & Deployment Tools
    subgraph "Build & Deployment Tools"
        B1["Fastlane"]:::deployment
        B2["Gemfile"]:::deployment
        B3["JXLS"]:::deployment
        B4["ZipZap"]:::deployment
    end

    %% Testing
    subgraph "Testing"
        T1["Test Suite"]:::testing
    end

    %% Connections from Core App to Layers
    A1 -->|"initiates"| UI1
    A1 -->|"initiates"| EM1

    %% UI Layer internal connections
    UI1 -->|"controls"| UI2
    UI1 -->|"manages"| UI3
    UI1 -->|"renders"| UI4
    UI1 -->|"uses"| UI5

    %% Experiment Management internal connections
    EM1 -->|"uses"| EM2
    EM1 -->|"receives"| EM3
    EM1 -->|"sends-to"| EM4
    EM1 -->|"serializes"| EM5
    EM1 -->|"exports"| EM6

    %% Integration between Experiment Management and External Submodules
    EM1 -->|"defines"| EX1
    EM1 -->|"integrates"| EX2

    %% Cross-layer interactions
    UI1 -->|"utilizes"| HL
    EM1 -->|"utilizes"| HL

    %% UI interacting with Localization & Resources
    UI1 -->|"localizes"| L1
    UI1 -->|"localizes"| L2
    UI1 -->|"displays"| L3
    UI1 -->|"applies"| L4

    %% Build & Deployment influence
    B1 ---|"builds"| A1
    B2 ---|"configures"| A1
    B3 ---|"integrates"| A1
    B4 ---|"packages"| A1

    %% Testing relation
    A1 ---|"verified-by"| T1

    %% Class definitions for styling
    classDef core fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef ui fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef experiment fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef external fill:#ffebcc,stroke:#333,stroke-width:2px;
    classDef helper fill:#e0e0e0,stroke:#333,stroke-width:2px;
    classDef localization fill:#d0f0fd,stroke:#333,stroke-width:2px;
    classDef deployment fill:#f0d0f0,stroke:#333,stroke-width:2px;
    classDef testing fill:#f7e8aa,stroke:#333,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/phyphox/phyphox-ios/blob/master/phyphox-iOS/phyphox.xcodeproj"
    click A2 "https://github.com/phyphox/phyphox-ios/blob/master/phyphox-iOS/phyphox/AppDelegate.swift"
    click UI1 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/UI/MainView"
    click UI2 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/UI/MainView/ExperimentView"
    click UI3 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/UI/MainView/NavigationController"
    click UI4 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/UI/CollectionView"
    click UI5 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/UI/Extensions"
    click EM1 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/Experiments"
    click EM2 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/Experiments/Analysis"
    click EM3 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/Experiments/Data-Input"
    click EM4 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/Experiments/Output"
    click EM5 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/Experiments/Serialization"
    click EM6 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/Experiments/Export"
    click EX1 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-experiments"
    click EX2 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-webinterface"
    click HL "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphox/Helper"
    click L2 "https://github.com/phyphox/phyphox-ios/blob/master/phyphox-iOS/phyphox/Settings.bundle"
    click L3 "https://github.com/phyphox/phyphox-ios/blob/master/phyphox-iOS/phyphox/Assets.xcassets"
    click L4 "https://github.com/phyphox/phyphox-ios/blob/master/phyphox-iOS/phyphox/color.xcassets"
    click B1 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/fastlane"
    click B2 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/Gemfile"
    click B3 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/JXLS"
    click B4 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/ZipZap"
    click T1 "https://github.com/phyphox/phyphox-ios/tree/master/phyphox-iOS/phyphoxTests"
```
