# acm-vit/open-with-browser architecture

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

- Interactive diagram: https://gitdiagram.com/acm-vit/open-with-browser
- Repository: https://github.com/acm-vit/open-with-browser

## Overview

##### Project type and purpose
- This is a cross-platform desktop application built with Tauri:
- Frontend: React + Vite (apps/desktop/src)
- Backend: Rust (apps/desktop/src-tauri)
- Purpose: “Open With Browser” intelligently routes incoming links to the correct browser and profile based on user-defined rules.

##### File structure
- Monorepo layout:
- apps/desktop – the single Tauri app (UI + Rust backend)
– src/           → React components, pages, state management
– src-tauri/     → Rust modules: rule engine, discovery, opener, storage stub, registration
- docs/           → architecture notes, OS-specific profile guides
- packages/       → placeholder for future shared libraries/crates
- CI workflows (.github/workflows) for build and release
- Config files: package.json, Cargo.toml, Vite, ESLint, Prettier, tsconfig

##### README for additional insights
- Architecture section outlines planned backend services:
- Rule Engine
- Browser Discovery
- Profile Resolver
- Opener
- Registration (URL handler)
- Storage (SQLite planned)
- Quick showcase clarifies user flows: dashboard → settings → click link → route or fallback dialog

##### Elements
- Clear labels on every component (e.g., “Rule Engine”, “Profile Resolver”)
- Annotations for protocols (IPC, HTTP, CLI spawn) and data stores (SQLite)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (JS/React)"
        direction TB
        UI["Dashboard\nSettings\nFallback Dialog"]:::frontend
        State["AppStore\nUIStore"]:::frontend
        RoutingLib["Routing & Models"]:::frontend
    end

    %% Tauri Bridge
    Bridge["Tauri Bridge (IPC Layer)"]:::bridge

    %% Backend Layer
    subgraph "Backend (Rust Services)"
        direction TB
        RegService["Registration Service"]:::backend
        RuleEngine["Rule Engine"]:::backend
        Discovery["Browser Discovery"]:::backend
        ProfileResolver["Profile Resolver"]:::backend
        Opener["Opener (Process Spawn)"]:::backend
        Storage["Storage (SQLite Stub)"]:::storage
        Diagnostics["Diagnostics / Telemetry"]:::backend
    end

    %% External Actors
    OS["Operating System"]:::external
    Browsers["External Browsers & Profiles"]:::external
    TelemetrySink["Telemetry / Audit Log Sink"]:::external

    %% Connections
    UI -->|invoke settings / link events via IPC| Bridge
    State -->|read/write config| Bridge
    RoutingLib -->|route UI nav| Bridge

    Bridge -->|register URL handler| RegService
    OS -->|HTTP/HTTPS callback| RegService
    RegService -->|on link clicked| RuleEngine

    RuleEngine -->|match rule| ProfileResolver
    RuleEngine -->|no match| UI
    UI -->|user fallback choice| Bridge
    Bridge -->|fallback event| RuleEngine

    ProfileResolver -->|resolved browser+profile| Opener
    Opener -->|spawn process| Browsers

    Bridge -->|discover browsers| Discovery
    Discovery -->|populate list| UI

    Bridge -->|read/write rules| Storage
    RegService -->|persist registration state| Storage
    RuleEngine -->|fetch rules| Storage

    Diagnostics -->|log events| TelemetrySink

    %% Click Events
    click UI "https://github.com/acm-vit/open-with-browser/tree/main/apps/desktop/src"
    click State "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src/store/appStore.ts"
    click State "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src/store/uiStore.ts"
    click RoutingLib "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src/lib/routing.ts"
    click RoutingLib "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src/lib/models.ts"
    click Bridge "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/commands.rs"
    click RegService "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/commands.rs"
    click RegService "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/tauri.conf.json"
    click RuleEngine "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/routing.rs"
    click Discovery "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/browser_details.rs"
    click Discovery "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/platform/mod.rs"
    click Discovery "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/platform/linux.rs"
    click Discovery "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/platform/macos.rs"
    click Discovery "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/platform/windows.rs"
    click ProfileResolver "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/domain/models.rs"
    click Opener "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/link.rs"
    click Storage "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/preferences.rs"
    click Diagnostics "https://github.com/acm-vit/open-with-browser/blob/main/apps/desktop/src-tauri/src/diagnostics.rs"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,stroke-width:1px;
    classDef bridge fill:#FFE5B4,stroke:#FF8C00,stroke-width:2px;
    classDef backend fill:#D6F5D6,stroke:#28A745,stroke-width:1px;
    classDef storage fill:#FFF5BA,stroke:#E6C300,stroke-width:1px;
    classDef external fill:#F0F0F0,stroke:#666666,stroke-width:1px,stroke-dasharray: 2 2;
```
