# shingzhanho/openinsteam-chrome architecture

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

- Interactive diagram: https://gitdiagram.com/shingzhanho/openinsteam-chrome
- Repository: https://github.com/shingzhanho/openinsteam-chrome

## Overview

##### Project type and purpose
- Type: Browser extension (Chrome).
- Purpose: On Steam website pages, inject a button that opens the current page in the locally installed Steam client, and send usage metrics to Google Analytics.

##### File structure
- manifest.json – extension descriptor (permissions, content scripts).
- js/
– script.js: content script runs in page context to inject UI and handle clicks.
– ga.js, gtag.js: analytics libraries for event tracking.
- css/page-element-style.css – styling for the injected button.
- README.md – high-level description, usage guide, privacy policy.

##### Extract key components
a. Chrome Browser (extension host)
b. OpenInSteam Extension
– Manifest (registration, permissions)
– Analytics Modules (ga.js, gtag.js)
c. Steam Web Page (target domain)
d. Steam Client (native handler via steam:// protocol)
e. Google Analytics (external service)

##### Interactions and data flows
1. Chrome user navigates to a Steam page (e.g., store.steampowered.com).
2. Chrome’s extension engine injects script.js and page-element-style.css into the page.
4. On button click:
– script.js triggers navigation to steam://… URI → OS launches Steam Client.
– script.js (via ga.js/gtag.js) sends an event to Google Analytics servers.
5. Google Analytics aggregates usage metrics.

##### Architectural patterns and design principles
- Separation of concerns:
– manifest.json defines capabilities and injection points.
– Content script handles UI and protocol calls.
– Analytics modules isolated from business logic.
- Client-side-only architecture: no backend; all logic runs in browser or native Steam handler.
- Minimal external dependency: only Google Analytics.

##### Essential elements
- File grouping to show how the project’s directory maps to components.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Chrome Browser"
        Manifest["manifest.json"]:::files
        subgraph "Content Script Module"
            script["js/script.js"]:::files
            css["css/page-element-style.css"]:::files
            icons["icons/"]:::files
        end
        subgraph "Analytics Module"
            ga["js/ga.js"]:::files
            gtag["js/gtag.js"]:::files
        end
    end

    README["README.md"]:::files

    SteamWeb["Steam Web Page"]:::external
    OSHandler["steam:// Protocol Handler"]:::native
    SteamClient["Steam Client"]:::native
    GA["Google Analytics"]:::external

    Manifest -->|"defines permissions"| script
    script -->|"inject script & CSS"| SteamWeb
    css -->|"apply styles"| SteamWeb
    script -->|"on button click"| OSHandler
    OSHandler -->|"launch app"| SteamClient
    script -->|"send event"| ga
    script -->|"send event"| gtag
    ga -->|"track event"| GA
    gtag -->|"track event"| GA

    click Manifest "https://github.com/shingzhanho/openinsteam-chrome/blob/master/manifest.json"
    click script "https://github.com/shingzhanho/openinsteam-chrome/blob/master/js/script.js"
    click css "https://github.com/shingzhanho/openinsteam-chrome/blob/master/css/page-element-style.css"
    click icons "https://github.com/shingzhanho/openinsteam-chrome/tree/master/icons/"
    click ga "https://github.com/shingzhanho/openinsteam-chrome/blob/master/js/ga.js"
    click gtag "https://github.com/shingzhanho/openinsteam-chrome/blob/master/js/gtag.js"
    click README "https://github.com/shingzhanho/openinsteam-chrome/blob/master/README.md"

    classDef browser fill:#cce5ff,stroke:#333,stroke-width:1px;
    classDef external fill:#e0e0e0,stroke:#333,stroke-width:1px;
    classDef native fill:#d4edda,stroke:#333,stroke-width:1px;
    classDef files fill:#ffffff,stroke:#333,stroke-width:1px;
```
