# yuigawada/icimulator architecture

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

- Interactive diagram: https://gitdiagram.com/yuigawada/icimulator
- Repository: https://github.com/yuigawada/icimulator

## Overview

Based on our review of the file tree and README, this project is an iOS camera simulator that intercepts calls to native camera APIs (AVFoundation and UIImagePickerController) and replaces them with fake/mock implementations to work within the iOS simulator. Additionally, it supports a “Mac Camera Mode” that leverages a Python-based streaming server, making it a hybrid solution that touches both iOS app internals and external services.

##### Main Components

- iOS Simulator Application:
– This is the target environment where an iOS app uses camera functions.
– Show the “Example” app (and the project’s main iCimulator integration code) as a demonstration of how a client integrates using the simulated camera functionality.

- iCimulator Framework:
– Inside iCimulator, break out sub-components:
▸ Mock AVFoundation Classes (found in iCimulator/Foundation) such as FakeCaptureDevice, FakeCaptureSession, FakeCapturePhotoOutput, and related typealiases in iCimulator.swift.
▸ UIImagePickerController Mocks (located in iCimulator/UIImagePickerController) that substitute the real controller with fake implementations.
▸ Utility functions (e.g., VideoConverter, StopWatch, and other helpers in iCimulator/Utilities).

- Configuration and Templates:
– Show the iCimulator.plist and the template files in the “templates” folder, which dictate how the simulation behaves (e.g., image, video, or Mac Camera mode).
– These files provide the mock data paths and configuration details for the simulation.

- External Dependencies and Integration Points:
– Carthage/CocoaPods Integration: Indicate that the project can be integrated via Carthage (as seen in the Carthage folder) or CocoaPods.
– The “iCimulator.podspec” and various Xcode workspace/project files support multiple build and distribution approaches.

- Streaming Server for Mac Camera Mode:
– Separate out the “streaming_server” directory. This Python-scripted server communicates (streaming video data) with the iOS Simulator when using Mac Camera Mode.
– List its dependencies (Python 3.7.3, numpy, opencv-python, Pillow, Pandas) and mark this as an external component that feeds live data into the simulation.

##### Relationships and Interactions

- That the iOS Simulator application (or Example app) imports the iCimulator module.
- That configuration (via iCimulator.plist and templates) guides which simulation mode is active (image, video, or Mac Camera).
- Dependency flow for build systems (Carthage/CocoaPods) as supporting elements that feed into the iCimulator framework build.

##### Architectural Patterns & Design Principles

- "substitution" pattern as the simulator replaces real capture classes with fake ones.
- Modularity: Each component (AVFoundation simulation, UIKit simulation, configuration, external streaming server) is developed and maintained in separate directories.
- Clear separation between client (app) and library layers, making it easily integratable as an external dependency.

##### Relevant Technologies and Frameworks

- Swift (for the iOS parts, including typealias and other components).
- AVFoundation / UIKit – represented by their fake counterparts.
- Xcode project structure (demonstrated in Example, iCimulator.xcodeproj, and .xcworkspace files).
- Python with external libraries for the streaming_server component.
- Carthage and CocoaPods, which indicate how dependencies are managed and integrated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% iOS Simulator Side
    subgraph "iOS Simulator Side"
        A["Example iOS App"]:::ios
        C["Build Systems_Dependency Management"]:::build
        B["iCimulator Framework"]:::framework
        subgraph "iCimulator Framework Components"
            B1["AVFoundation Mocks"]:::mock
            B2["UIImagePickerController Mocks"]:::mock
            B3["Utilities_&_Helpers"]:::util
            B4["Configuration_&_Templates"]:::config
        end
        A -->|"API_CallReplacement"| B
        B -->|"contains"| B1
        B -->|"contains"| B2
        B -->|"contains"| B3
        B -->|"config_from"| B4
        C -->|"builds"| B
    end

    %% External Services
    subgraph "External Services"
        D["Streaming Server (Python)"]:::external
    end

    %% Interaction between Framework and External Streaming Server in Mac Camera Mode
    B -.->|"Streaming_Data"| D

    %% Click Events
    click A "https://github.com/yuigawada/icimulator/tree/master/Example/Example"
    click B "https://github.com/yuigawada/icimulator/tree/master/iCimulator/"
    click B1 "https://github.com/yuigawada/icimulator/tree/master/iCimulator/Foundation/"
    click B2 "https://github.com/yuigawada/icimulator/tree/master/iCimulator/UIImagePickerController/"
    click B3 "https://github.com/yuigawada/icimulator/tree/master/iCimulator/Utilities/"
    click B4 "https://github.com/yuigawada/icimulator/blob/master/iCimulator.plist"
    click C "https://github.com/yuigawada/icimulator/tree/master/Carthage/"
    click D "https://github.com/yuigawada/icimulator/tree/master/streaming_server/"

    %% Styles
    classDef ios fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef framework fill:#ffd699,stroke:#333,stroke-width:2px;
    classDef mock fill:#ffebcc,stroke:#333,stroke-width:2px;
    classDef util fill:#e6ffe6,stroke:#333,stroke-width:2px;
    classDef config fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef build fill:#d9d2e9,stroke:#333,stroke-width:2px;
    classDef external fill:#d4edda,stroke:#333,stroke-width:2px;
```
