# tryum/warpbrowser architecture

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

- Interactive diagram: https://gitdiagram.com/tryum/warpbrowser
- Repository: https://github.com/tryum/warpbrowser

## Overview

##### Project Type & Purpose
- WarpBrowser is a command-line application (Rust/Cargo) whose purpose is to intercept a URL, look up a set of matching rules, and launch the appropriate browser. It has platform‐specific code (windows.rs) and a modular internal design (config, link_processor, browsers).

##### File Structure
- Top-level:
- Cargo.toml / Cargo.lock → build system & dependency management
- .github/workflows → CI for Windows builds
- README.md → user-facing documentation
- src/
- main.rs → CLI entry point & argument parsing
- config.rs → loading/storing of rules (e.g., file-based or registry)
- link_processor.rs → logic to parse incoming URL and match rules
- browsers.rs → abstraction over browser processes (launching them)
- windows.rs → Windows-specific registration code

##### Extract Insights from the README
- Core features: URL capture, rule matching, registering as system browser, interactive rule creation.
- Future work: time‐based rule sets, regex rules, history import.
- Known issue: Windows 10 registration.

##### Main Components & Relationships
a. Components:
- CLI Interface (main.rs + argument parser crate, e.g., Clap)
- Configuration Store (config.rs; could be JSON/TOML file or OS registry)
- Rule Engine (link_processor.rs; matches URL → rule)
- Browser Launcher (browsers.rs; spawns child process with URL)
- OS Integration (windows.rs; registry modifications, “register” action)
- CI/CD Pipeline (.github/workflows)
- Build System (Cargo)
b. Data Flow & Interactions:
1. User invokes warpbrowser.exe with a URL or command
2. main.rs parses flags → decides: register, add-rule, select-browser, or redirect
3. config.rs loads existing rules/config
4. link_processor.rs matches URL against rule set
5. browsers.rs launches the chosen browser process with the URL
6. windows.rs code runs if “--register” or Windows registry access needed
c. Architectural Patterns:
- Single Responsibility Modules
- Layered approach: Presentation (CLI) → Domain (Rule Engine) → Infrastructure (OS/Browsers)
- Platform Abstraction Layer (windows.rs versus potential Unix implementation)
d. Key Technologies:
- Rust / Cargo
- clap or structopt (for CLI parsing)
- serde (for config serialization)
- platform-specific crates (winreg, winapi)

##### Detailed Element Checklist
- [ ] CLI Parameters & Commands
- [ ] Config Store (file or registry)
- [ ] Rule Matching Flow
- [ ] Browser Abstraction Layer
- [ ] OS Integration Layer
- [ ] Build & CI Pipeline

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        CLI["CLI Interface"]:::presentation
    end

    %% Core Logic Layer
    subgraph "Core Logic Layer"
        Config["Configuration Store"]:::core
        Rule["Rule Engine"]:::core
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Browser["Browser Launcher"]:::infra
        OSInt["OS Integration Layer"]:::infra
    end

    %% Persistence
    subgraph "Persistence"
        File["rules.json (file-based)"]:::external
        Reg["Windows Registry"]:::external
    end

    %% DevOps
    subgraph "DevOps"
        CI["CI/CD Pipeline"]:::external
        Build["Build System (Cargo)"]:::external
    end

    %% Data Flows
    CLI -->|"parse args"| Config
    CLI -->|"receive URL"| Rule
    Config -->|"load rules"| File
    Config -->|"load rules"| Reg
    Config -->|"provide rule set"| Rule
    Rule -->|"select browser"| Browser
    Browser -->|"spawn process with URL"| OSInt
    CLI -->|"--register flag"| OSInt
    OSInt -->|"modify registry"| Reg
    CI -->|"triggers build"| Build

    %% Click Events
    click CLI "https://github.com/tryum/warpbrowser/blob/main/src/main.rs"
    click Config "https://github.com/tryum/warpbrowser/blob/main/src/config.rs"
    click Rule "https://github.com/tryum/warpbrowser/blob/main/src/link_processor.rs"
    click Browser "https://github.com/tryum/warpbrowser/blob/main/src/browsers.rs"
    click OSInt "https://github.com/tryum/warpbrowser/blob/main/src/windows.rs"
    click CI "https://github.com/tryum/warpbrowser/blob/main/.github/workflows/build-windows.yml"
    click Build "https://github.com/tryum/warpbrowser/blob/main/Cargo.toml"

    %% Styles
    classDef presentation fill:#e0f7fa,stroke:#0288d1,color:#000
    classDef core fill:#e8f5e9,stroke:#43a047,color:#000
    classDef infra fill:#fff3e0,stroke:#fb8c00,color:#000
    classDef external fill:#eceff1,stroke:#78909c,color:#000
```
