# blue-sky-infomation-factory/python-webview2 architecture

> Architecture diagram of the GitHub repository blue-sky-infomation-factory/python-webview2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/blue-sky-infomation-factory/python-webview2
- Repository: https://github.com/blue-sky-infomation-factory/python-webview2

## Overview

BSIF-Webview2 is a Python framework for building Windows desktop applications with Microsoft WebView2. The main workflow is for application code to start an application and create a window, which hosts browser content and exposes Python methods to JavaScript through synchronous and asynchronous bridge calls. The framework also provides native file and directory pickers. A separate command-line workflow checks for and installs the WebView2 and .NET runtimes. The excerpts show bridge injection and runtime installation; the webview-to-picker relationship is supported only by the source index, so it is marked unverified.

Main entry points: [`bsif_webview/webview.py`](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/webview.py) (WebView window), [`bsif_webview_tool/environment.py`](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview_tool/environment.py) (Environment checks and installers), [`bsif_webview/bridge.py`](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/bridge.py) (Python bridge handlers), [`bsif_webview_tool/__main__.py`](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview_tool/__main__.py) (Runtime installer command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application and windows"]
  node_application["WebView application<br/>[webview.py]"]
  node_window["WebView window<br/>[webview.py]"]
  node_browser["WebView2 browser"]
end

subgraph group_bridge["JavaScript bridge"]
  node_bridge_runtime["Python bridge handlers<br/>[bridge.py]"]
  node_bridge_script["JavaScript bridge<br/>[bridge.js]"]
end

subgraph group_native["Native dialogs"]
  node_picker["File and directory pickers"]
end

subgraph group_runtime["Runtime setup"]
  node_cli["Runtime installer command<br/>[__main__.py]"]
  node_environment["Environment checks and installers<br/>[environment.py]"]
end

node_developer(("Application developer"))
node_webview_runtime["WebView2 runtime"]
node_dotnet_runtime[".NET runtime"]

node_developer -.->|"starts"| node_application
node_application -->|"creates"| node_window
node_window -->|"hosts"| node_browser
node_window -->|"initializes"| node_bridge_runtime
node_bridge_runtime -->|"injects"| node_bridge_script
node_browser -.->|"runs"| node_bridge_script
node_window -.->|"uses"| node_picker
node_developer -.->|"runs"| node_cli
node_cli -->|"checks and installs"| node_environment
node_environment -->|"checks and installs"| node_webview_runtime
node_environment -->|"checks and installs"| node_dotnet_runtime

click node_application "https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/webview.py"
click node_window "https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/webview.py"
click node_picker "https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/file_system_dialog.py"
click node_bridge_runtime "https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/bridge.py"
click node_bridge_script "https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/bridge.js"
click node_cli "https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview_tool/__main__.py"
click node_environment "https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview_tool/environment.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_application,node_window,node_browser,node_webview_runtime toneBlue
class node_bridge_runtime,node_bridge_script toneAmber
class node_picker toneMint
class node_cli,node_environment toneRose
class node_developer,node_dotnet_runtime toneIndigo
```

## Components

### Application and windows

- [WebView application](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/webview.py): `bsif_webview/webview.py`
- [WebView window](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/webview.py): `bsif_webview/webview.py`
- **WebView2 browser**

### JavaScript bridge

- [Python bridge handlers](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/bridge.py): `bsif_webview/bridge.py`
- [JavaScript bridge](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/bridge.js): `bsif_webview/bridge.js`

### Native dialogs

- [File and directory pickers](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview/file_system_dialog.py): `bsif_webview/file_system_dialog.py`

### Runtime setup

- [Runtime installer command](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview_tool/__main__.py): `bsif_webview_tool/__main__.py`
- [Environment checks and installers](https://github.com/blue-sky-infomation-factory/python-webview2/blob/main/bsif_webview_tool/environment.py): `bsif_webview_tool/environment.py`

### Other components

- **Application developer**
- **WebView2 runtime**
- **.NET runtime**

## Connections

- Application developer → WebView application: starts
- WebView application → WebView window: creates (evidence: `bsif_webview/webview.py`)
- WebView window → WebView2 browser: hosts (evidence: `bsif_webview/webview.py`)
- WebView window → Python bridge handlers: initializes (evidence: `bsif_webview/webview.py`)
- Python bridge handlers → JavaScript bridge: injects (evidence: `bsif_webview/bridge.py`)
- WebView2 browser → JavaScript bridge: runs
- WebView window → File and directory pickers: uses (evidence: `bsif_webview/webview.py`)
- Application developer → Runtime installer command: runs
- Runtime installer command → Environment checks and installers: checks and installs (evidence: `bsif_webview_tool/__main__.py`)
- Environment checks and installers → WebView2 runtime: checks and installs (evidence: `bsif_webview_tool/environment.py`)
- Environment checks and installers → .NET runtime: checks and installs (evidence: `bsif_webview_tool/environment.py`)
