# fellowgeek/enclose architecture

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

- Interactive diagram: https://gitdiagram.com/fellowgeek/enclose
- Repository: https://github.com/fellowgeek/enclose

## Overview

##### Main Components
- Native iOS Module:
- Located in the iOS-Swift folder.
- Native macOS Module:
- Located in the MacOS-Swift folder.
- Contains components such as AppDelegate.swift, ViewController.swift, Main.storyboard (in Base.lproj), info.plist, and an assets folder.
- Web Asset Layer:
- Both the iOS-Swift and MacOS-Swift folders contain a “www” directory.
- This directory contains HTML files (index.html, display.html), CSS (styles.css), JavaScript files (application.js, enClose.js), and additional image assets.
- Development and Build Infrastructure:
- Xcode project files (e.g., enClose.xcodeproj for both platforms) indicate that Xcode is used as the IDE and build tool.
- Configuration files (Info.plist, entitlements, project.pbxproj) are essential to the project setup.

##### Relationships and Interactions
- Platform-specific Native Layers:
- Each platform module (iOS and macOS) encapsulates native initialization (AppDelegate, SceneDelegate on iOS) and view controllers that likely instantiate and display web content.
- Typically, a WKWebView or similar component is used by these controllers to load content from the corresponding "www" folder.
- Web-to-Native Interaction:
- The framework’s core concept is to allow JavaScript code in the web layer to call native Swift functions. This bidirectional bridge should be a prominent part of the design.
- Native-to-Web Interaction:

##### Architectural Patterns and Design Principles
- Hybrid Application Architecture:
- Separation of concerns between the native UI layer and the web-based presentation/logic layer is critical.
- Bridge mechanism that allows these two layers to interact seamlessly.
- Modularity by Platform:
- Flexibility:
- As noted in the README, enClose is designed to remove restrictions by not confining developers to predefined APIs/plugins. Capture this flexibility by highlighting the open communication channels between layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development Infrastructure
    subgraph "Development Infrastructure"
        infra_ios["Xcode: iOS enClose.xcodeproj"]:::infra
        infra_mac["Xcode: macOS enClose-MacOS.xcodeproj"]:::infra
    end

    %% Hybrid Bridge / Integration Layer
    bridge["Hybrid Bridge / Integration"]:::bridge

    %% iOS Application Module
    subgraph "iOS Application"
        ios_native["Native Module: AppDelegate, SceneDelegate, MainViewController, Storyboards"]:::native
        ios_web["Web Assets: index.html, display.html, CSS, JS"]:::web
    end

    %% macOS Application Module
    subgraph "macOS Application"
        mac_native["Native Module: AppDelegate, ViewController, Storyboards, Info.plist"]:::native
        mac_web["Web Assets: index.html, CSS, JS"]:::web
    end

    %% Connections from Development Infrastructure to Bridge
    infra_ios -->|"supports"| bridge
    infra_mac -->|"supports"| bridge

    %% iOS Module Interactions
    ios_native -->|"loadsWebView"| ios_web
    ios_web -->|"callsNative"| bridge
    bridge -->|"invokesNative"| ios_native

    %% macOS Module Interactions
    mac_native -->|"loadsWebView"| mac_web
    mac_web -->|"callsNative"| bridge
    bridge -->|"invokesNative"| mac_native

    %% Click Events
    click ios_native "https://github.com/fellowgeek/enclose/tree/master/iOS-Swift/enClose"
    click ios_web "https://github.com/fellowgeek/enclose/tree/master/iOS-Swift/www"
    click mac_native "https://github.com/fellowgeek/enclose/tree/master/MacOS-Swift/enClose-MacOS"
    click mac_web "https://github.com/fellowgeek/enclose/tree/master/MacOS-Swift/www"
    click infra_ios "https://github.com/fellowgeek/enclose/blob/master/iOS-Swift/enClose.xcodeproj"
    click infra_mac "https://github.com/fellowgeek/enclose/blob/master/MacOS-Swift/enClose-MacOS.xcodeproj"

    %% Styles
    classDef native fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef web fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef bridge fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef infra fill:#90EE90,stroke:#000,stroke-width:2px;
```
