# krishnav2/browser-url architecture

> Architecture diagram of the GitHub repository krishnav2/browser-url, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/krishnav2/browser-url
- Repository: https://github.com/krishnav2/browser-url

## Overview

browser-url is a small Rust library that detects the focused window, classifies recognized browsers, and extracts URL and window metadata. The documented workflow is implemented by the public API, browser classifier, platform dispatcher, and Windows UI Automation extractor. macOS and Linux are explicitly planned but not implemented; the graph omits those branches. Edges reflect the sampled calls and README documentation.

Main entry points: [`src/lib.rs`](https://github.com/krishnav2/browser-url/blob/main/src/lib.rs) (Active browser API), [`src/url_extraction.rs`](https://github.com/krishnav2/browser-url/blob/main/src/url_extraction.rs) (Platform dispatcher), [`src/platform/windows.rs`](https://github.com/krishnav2/browser-url/blob/main/src/platform/windows.rs) (Windows UI extraction), [`src/browser_detection.rs`](https://github.com/krishnav2/browser-url/blob/main/src/browser_detection.rs) (Browser classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_api["Active browser API<br/>[lib.rs]"]
  node_window["Active window lookup<br/>[lib.rs]"]
end

subgraph group_detection["Browser Detection"]
  node_classifier["Browser classifier"]
end

subgraph group_extraction["URL Extraction"]
  node_dispatcher["Platform dispatcher<br/>[url_extraction.rs]"]
  node_windows["Windows UI extraction<br/>[windows.rs]"]
end

subgraph group_model["Results and Errors"]
  node_info["Browser information<br/>[lib.rs]"]
  node_errors["API errors<br/>[error.rs]"]
end

node_user(("Library caller"))
node_uia["Windows UI Automation"]

node_user -->|"calls"| node_api
node_api -->|"queries"| node_window
node_api -->|"classifies window"| node_classifier
node_api -->|"requests URL"| node_dispatcher
node_window -->|"returns window data"| node_api
node_classifier -->|"returns browser type"| node_api
node_dispatcher -->|"dispatches on Windows"| node_windows
node_windows -->|"queries controls"| node_uia
node_windows -->|"returns URL"| node_dispatcher
node_api -->|"assembles result"| node_info
node_api -->|"returns failures"| node_errors
node_dispatcher -->|"returns platform errors"| node_errors

click node_api "https://github.com/krishnav2/browser-url/blob/main/src/lib.rs"
click node_window "https://github.com/krishnav2/browser-url/blob/main/src/lib.rs"
click node_classifier "https://github.com/krishnav2/browser-url/blob/main/src/browser_detection.rs"
click node_dispatcher "https://github.com/krishnav2/browser-url/blob/main/src/url_extraction.rs"
click node_windows "https://github.com/krishnav2/browser-url/blob/main/src/platform/windows.rs"
click node_info "https://github.com/krishnav2/browser-url/blob/main/src/lib.rs"
click node_errors "https://github.com/krishnav2/browser-url/blob/main/src/error.rs"

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_api,node_window,node_uia toneBlue
class node_classifier toneAmber
class node_dispatcher,node_windows toneMint
class node_info,node_errors toneRose
class node_user toneIndigo
```

## Components

### Public API

- [Active browser API](https://github.com/krishnav2/browser-url/blob/main/src/lib.rs): `src/lib.rs`
- [Active window lookup](https://github.com/krishnav2/browser-url/blob/main/src/lib.rs): `src/lib.rs`

### Browser Detection

- [Browser classifier](https://github.com/krishnav2/browser-url/blob/main/src/browser_detection.rs): `src/browser_detection.rs`

### URL Extraction

- [Platform dispatcher](https://github.com/krishnav2/browser-url/blob/main/src/url_extraction.rs): `src/url_extraction.rs`
- [Windows UI extraction](https://github.com/krishnav2/browser-url/blob/main/src/platform/windows.rs): `src/platform/windows.rs`

### Results and Errors

- [Browser information](https://github.com/krishnav2/browser-url/blob/main/src/lib.rs): `src/lib.rs`
- [API errors](https://github.com/krishnav2/browser-url/blob/main/src/error.rs): `src/error.rs`

### Other components

- **Library caller**
- **Windows UI Automation**

## Connections

- Library caller → Active browser API: calls (evidence: `src/lib.rs`)
- Active browser API → Active window lookup: queries (evidence: `src/lib.rs`)
- Active browser API → Browser classifier: classifies window (evidence: `src/lib.rs`)
- Active browser API → Platform dispatcher: requests URL (evidence: `src/lib.rs`)
- Active window lookup → Active browser API: returns window data (evidence: `src/lib.rs`)
- Browser classifier → Active browser API: returns browser type (evidence: `src/lib.rs`)
- Platform dispatcher → Windows UI extraction: dispatches on Windows (evidence: `src/url_extraction.rs`)
- Windows UI extraction → Windows UI Automation: queries controls (evidence: `src/platform/windows.rs`)
- Windows UI extraction → Platform dispatcher: returns URL (evidence: `src/url_extraction.rs`)
- Active browser API → Browser information: assembles result (evidence: `src/lib.rs`)
- Active browser API → API errors: returns failures (evidence: `src/lib.rs`)
- Platform dispatcher → API errors: returns platform errors (evidence: `src/url_extraction.rs`)
