# seokju-na/webview-bundle architecture

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

- Interactive diagram: https://gitdiagram.com/seokju-na/webview-bundle
- Repository: https://github.com/seokju-na/webview-bundle

## Overview

##### Main Components

a) Core Components:
- Webview Bundle Core (crates/webview-bundle)
- Bundle Builder
- Encoder/Decoder
- Error Handling

b) Platform Integration Layers:
- Tauri Integration (crates/webview-bundle-tauri)
- Electron Integration (packages/electron)
- Node.js Bindings (packages/node-binding)

c) CLI Tool:
- Command-line Interface (crates/webview-bundle-cli)
- Bundle Command
- Extract Command
- Pack Command

**┌─────────────────────────────────────────────┐**
- Application Layer                 │
- ┌──────────┐  ┌──────────┐  ┌──────────┐  │
- Electron │  │  Tauri   │  │  Future   │  │
- App    │  │   App    │  │ Platforms │  │
- ┘  └──────────┘  └──────────┘  │
- ┤
- Integration Layer                 │
- ┌──────────┐  ┌──────────┐  ┌──────────┐  │
- Electron │  │  Tauri   │  │  Node.js  │  │
- Binding  │  │ Binding  │  │ Binding   │  │
- ┘  └──────────┘  └──────────┘  │
- ┤
- Core Layer                     │
- ┌──────────────────────────────────────┐  │
- Webview Bundle Core           │  │
- ┌────────┐ ┌────────┐ ┌────────┐   │  │
- Builder │ │Encoder │ │Decoder │   │  │
- ┘ └────────┘ └────────┘   │  │
- ┘  │
- ┤
- CLI Layer                      │
- ┌──────────────────────────────────────┐  │
- Command Line Interface         │  │
- ┌────────┐ ┌────────┐ ┌────────┐   │  │
- Bundle │ │Extract │ │ Pack   │   │  │
- ┘ └────────┘ └────────┘   │  │
- ┘  │
- ┘

##### Important Elements to Highlight

a) Data Flow:
- How web resources flow from the bundle through the core layer to platform-specific implementations
- Offline-first nature with appropriate caching mechanisms

b) Cross-Platform Support:
- Modular nature of platform support
- Clear separation between core functionality and platform-specific code

c) Build Process:
- CLI's role in the build pipeline
- How the bundling process integrates with different platforms

##### Implementation Details to Note

- The project uses a hybrid Rust/TypeScript architecture
- Platform-specific bindings are implemented as separate packages
- The core functionality is implemented in Rust for performance
- Cross-platform support is achieved through platform-specific adapters

##### Future Extensibility

Placeholder components for:
- Android integration (planned)
- iOS integration (planned)
- Other potential platform integrations

Remember to include notes about:
- The offline-first nature of the system
- Cross-platform compatibility
- Performance considerations
- Security implications of offline resource bundling

This system design should help developers understand both the current state of the project and its potential for growth while maintaining a clear view of the core architecture and its platform-specific implementations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#b3d1ff,stroke:#4d88ff
    classDef platform fill:#90EE90,stroke:#228B22
    classDef cli fill:#FFB366,stroke:#FF8000
    classDef future fill:#E0E0E0,stroke:#808080
    classDef example fill:#FFD700,stroke:#DAA520

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        ElectronApp["Electron App"]
        TauriApp["Tauri App"]
        FutureApp["Future Platforms"]:::future
    end

    %% Integration Layer
    subgraph IntegrationLayer["Integration Layer"]
        ElectronBinding["Electron Binding"]
        TauriBinding["Tauri Binding"]
        NodeBinding["Node.js Binding"]
        
        ElectronLoader["Electron Loader"]
        TauriLoader["Tauri Loader"]
    end

    %% Core Layer
    subgraph CoreLayer["Core Layer"]
        Core["Webview Bundle Core"]
        Builder["Bundle Builder"]
        Encoder["Encoder"]
        Decoder["Decoder"]
        ErrorHandler["Error Handler"]
    end

    %% CLI Layer
    subgraph CLILayer["CLI Layer"]
        CLI["Command Line Interface"]
        BundleCmd["Bundle Command"]
        ExtractCmd["Extract Command"]
        PackCmd["Pack Command"]
    end

    %% Example Layer
    subgraph Examples["Example Implementations"]
        ElectronExample["Electron Example"]
        TauriExample["Tauri Example"]
    end

    %% Relationships
    Core --> Builder
    Core --> Encoder
    Core --> Decoder
    Core --> ErrorHandler
    
    CLI --> BundleCmd
    CLI --> ExtractCmd
    CLI --> PackCmd
    
    ElectronBinding --> Core
    TauriBinding --> Core
    NodeBinding --> Core
    
    ElectronLoader --> ElectronBinding
    TauriLoader --> TauriBinding
    
    ElectronApp --> ElectronBinding
    TauriApp --> TauriBinding
    
    ElectronExample --> ElectronApp
    TauriExample --> TauriApp

    %% Click Events
    click Core "https://github.com/seokju-na/webview-bundle/tree/main/crates/webview-bundle/src/"
    click Builder "https://github.com/seokju-na/webview-bundle/blob/main/crates/webview-bundle/src/builder.rs"
    click Encoder "https://github.com/seokju-na/webview-bundle/blob/main/crates/webview-bundle/src/encoder.rs"
    click Decoder "https://github.com/seokju-na/webview-bundle/blob/main/crates/webview-bundle/src/decoder.rs"
    click ErrorHandler "https://github.com/seokju-na/webview-bundle/blob/main/crates/webview-bundle/src/error.rs"
    
    click TauriBinding "https://github.com/seokju-na/webview-bundle/tree/main/crates/webview-bundle-tauri/"
    click ElectronBinding "https://github.com/seokju-na/webview-bundle/tree/main/packages/electron/"
    click NodeBinding "https://github.com/seokju-na/webview-bundle/tree/main/packages/node-binding/"
    
    click CLI "https://github.com/seokju-na/webview-bundle/tree/main/crates/webview-bundle-cli/"
    click BundleCmd "https://github.com/seokju-na/webview-bundle/blob/main/crates/webview-bundle-cli/src/commands/bundle.rs"
    click ExtractCmd "https://github.com/seokju-na/webview-bundle/blob/main/crates/webview-bundle-cli/src/commands/extract.rs"
    click PackCmd "https://github.com/seokju-na/webview-bundle/blob/main/crates/webview-bundle-cli/src/commands/pack.rs"
    
    click ElectronExample "https://github.com/seokju-na/webview-bundle/tree/main/examples/electron-simple/"
    click TauriExample "https://github.com/seokju-na/webview-bundle/tree/main/examples/tauri-simple/"
    
    click ElectronLoader "https://github.com/seokju-na/webview-bundle/blob/main/packages/electron/src/Loader.ts"
    click TauriLoader "https://github.com/seokju-na/webview-bundle/blob/main/crates/webview-bundle-tauri/src/loader.rs"

    %% Style Applications
    class Core,Builder,Encoder,Decoder,ErrorHandler core
    class ElectronBinding,TauriBinding,NodeBinding,ElectronLoader,TauriLoader platform
    class CLI,BundleCmd,ExtractCmd,PackCmd cli
    class FutureApp future
    class ElectronExample,TauriExample example
```
