# soo5sin/mauiwebviewexample architecture

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

- Interactive diagram: https://gitdiagram.com/soo5sin/mauiwebviewexample
- Repository: https://github.com/soo5sin/mauiwebviewexample

## Overview

##### Main Components

A. Core Application Layer
- MAUI Application Host
- Custom HybridWebView Control
- Platform-Specific Handlers

B. Platform-Specific Implementations
- iOS Implementation
- Android Implementation
- Windows Implementation (with HTTP Listener workaround)

**Top Layer (UI/Presentation):**
**┌─────────────────────────────────────┐**
- MainPage (XAML/CS)                  │
- AppShell (XAML/CS)                  │
- ┘

**Middle Layer (Core Components):**
**┌─────────────────────────────────────┐**
- HybridWebView Control               │
- MainPageViewModel                   │
- ┘

**Platform-Specific Layer:**
**┌───────────┐ ┌───────────┐ ┌───────────┐**
- iOS     │ │  Android  │ │  Windows  │
- Handler  │ │  Handler  │ │  Handler  │
- ┘ └───────────┘ └───────────┘

##### Key Elements to Highlight

a. Communication Flow:
- JavaScript -> Native bridge
- EvaluateJavaScriptAsync capability

b. Platform-Specific Implementation Details:
- iOS: Native WebKit Handler
- Android: Native WebView Handler
- Windows: WebView2 with HTTP Listener workaround

##### Technical Details

- MAUI Custom Handlers
- JavaScript Bridge Interface
- Platform-Specific WebView Implementations
- View-ViewModel Binding
- Resource Management

##### Notes for Implementation

- Use standard UML notation where applicable
- Version information for MAUI
- Platform-specific requirements
- Document the JavaScript interface methods

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI_Layer
        MainPage["MainPage (XAML/CS)"]
        AppShell["AppShell (XAML/CS)"]
    end

    subgraph Core_Components
        HybridWebView["HybridWebView Control"]
        MainPageViewModel["MainPageViewModel"]
        AppHost["Application Host"]
        MauiConfig["MAUI Program Configuration"]
    end

    subgraph Platform_Specific
        direction TB
        subgraph Handlers
            direction TB
            iOSHandler["iOS Handler"]
            AndroidHandler["Android Handler"]
            WindowsHandler["Windows Handler<br/>(HTTP Listener)"]
        end
    end

    MainPage --> HybridWebView
    AppShell --> MainPage
    MainPage --> MainPageViewModel
    HybridWebView --> iOSHandler
    HybridWebView --> AndroidHandler
    HybridWebView --> WindowsHandler
    AppHost --> MauiConfig
    MauiConfig --> HybridWebView

    %% Component Mappings
    click MainPage "https://github.com/soo5sin/MAUIWebViewExample/blob/main/WebViewHostExample/MainPage.xaml"
    click AppShell "https://github.com/soo5sin/MAUIWebViewExample/blob/main/WebViewHostExample/AppShell.xaml"
    click HybridWebView "https://github.com/soo5sin/MAUIWebViewExample/blob/main/WebViewHostExample/Controls/HybridWebView.cs"
    click MainPageViewModel "https://github.com/soo5sin/MAUIWebViewExample/blob/main/WebViewHostExample/ViewModels/MainPageViewModel.cs"
    click iOSHandler "https://github.com/soo5sin/MAUIWebViewExample/blob/main/WebViewHostExample/Platforms/iOS/Handlers/HybridWebViewHandler.cs"
    click AndroidHandler "https://github.com/soo5sin/MAUIWebViewExample/blob/main/WebViewHostExample/Platforms/Android/Handlers/HybridWebViewHandler.cs"
    click WindowsHandler "https://github.com/soo5sin/MAUIWebViewExample/blob/main/WebViewHostExample/Platforms/Windows/Handlers/HybridWebViewHandler.cs"
    click AppHost "https://github.com/soo5sin/MAUIWebViewExample/blob/main/WebViewHostExample/App.xaml"
    click MauiConfig "https://github.com/soo5sin/MAUIWebViewExample/blob/main/WebViewHostExample/MauiProgram.cs"

    %% Styling
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef platform fill:#FF9800,stroke:#F57C00,color:white
    classDef config fill:#9C27B0,stroke:#7B1FA2,color:white

    class MainPage,AppShell ui
    class HybridWebView,MainPageViewModel,AppHost core
    class iOSHandler,AndroidHandler,WindowsHandler platform
    class MauiConfig config

    %% Legend
    subgraph Legend
        UI[UI Components]:::ui
        Core[Core Components]:::core
        Platform[Platform Handlers]:::platform
        Config[Configuration]:::config
    end
```
