# amirshnll/custom-device-emulation-chrome architecture

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

- Interactive diagram: https://gitdiagram.com/amirshnll/custom-device-emulation-chrome
- Repository: https://github.com/amirshnll/custom-device-emulation-chrome

## Overview

##### Project type and purpose
- This is a browser‐extension project (“custom‐device‐emulation‐chrome”) that runs entirely inside Chrome.
- Its purpose is to let users select or add device presets (viewport size, DPR, UA string) in the Chrome DevTools device toolbar.

##### File structure
- Top level:
- CODE_OF_CONDUCT.md, CONTRIBUTING.md, LICENSE, README.md, .github/ – standard repo docs
- device.json – the master list of device definitions
- release.sh – deploy script for publishing the extension
- images/ – screenshots for the README
- plugin/ directory (the actual extension bundle) contains:
- manifest.json – extension metadata, permissions, entry points
- privacy.md – privacy policy for the Web Store

##### README for additional insights
- No runtime backend or server components are mentioned—everything is client‐side.
- The extension UI walks through DevTools keyboard shortcuts, device editing, and uses the device list in device.json.

a. Main components
1. Chrome Browser (host environment)
2. Extension Loader & Manifest (defines permissions and resources)
3. UI Layer (popup.html + styles.css)
4. Logic Layer (popup.js)
5. Data Layer (device.json)
6. Chrome DevTools Protocol / chrome.* APIs (to configure emulation)
7. Release Pipeline (release.sh → Chrome Web Store)
b. Relationships & interactions
- At install time, Chrome reads manifest.json and registers the extension.
- popup.js fetches device.json, renders the device list, handles “Add Device” actions.
- On user input, popup.js calls Chrome DevTools Protocol (via chrome.debugger or chrome.devtools.* APIs) to apply viewport, DPR, and UA overrides.
- release.sh picks up the plugin/ folder, packages it, and publishes to the Chrome Web Store.
c. Architectural patterns & design principles
- Separation of concerns: UI (HTML/CSS) vs. business logic (JS) vs. static data (JSON).
- Manifest‐driven plugin architecture—declarative registration of resources and permissions.
- Client‐only design—no backend required.
d. Key technologies/frameworks
- Native Chrome Extension APIs (chrome.browserAction, chrome.devtools)
- Standard web tech: HTML5, CSS3, JavaScript ES6
- JSON for data serialization

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Entities
    User["User"]:::external
    browser["Chrome Browser"]:::external
    api["Chrome DevTools Protocol / chrome.* APIs"]:::external
    webstore["Chrome Web Store"]:::external

    %% Plugin Subgraph
    subgraph "Chrome Extension (plugin/)" 
        manifest["manifest.json"]:::script
        uiHTML["popup.html"]:::frontend
        uiCSS["styles.css"]:::frontend
        logic["popup.js"]:::logic
    end

    %% Data Layer
    data["device.json"]:::data

    %% Release Pipeline
    release["release.sh"]:::script

    %% Relationships
    browser -->|loads at install| manifest
    User -->|clicks extension icon| uiHTML
    manifest -->|defines resources| uiHTML
    uiHTML -->|renders UI| logic
    uiHTML -->|applies styles| uiCSS
    logic -->|reads devices| data
    logic -->|calls APIs| api
    release -->|packages plugin/| manifest
    release -->|publishes to| webstore

    %% Click Events
    click manifest "https://github.com/amirshnll/custom-device-emulation-chrome/blob/main/plugin/manifest.json"
    click uiHTML "https://github.com/amirshnll/custom-device-emulation-chrome/blob/main/plugin/popup.html"
    click uiCSS "https://github.com/amirshnll/custom-device-emulation-chrome/blob/main/plugin/styles.css"
    click logic "https://github.com/amirshnll/custom-device-emulation-chrome/blob/main/plugin/popup.js"
    click data "https://github.com/amirshnll/custom-device-emulation-chrome/blob/main/device.json"
    click release "https://github.com/amirshnll/custom-device-emulation-chrome/blob/main/release.sh"

    %% Styling
    classDef external fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef frontend fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef data fill:#FFD580,stroke:#000,stroke-width:1px;
    classDef script fill:#D8BFD8,stroke:#000,stroke-width:1px;
    classDef logic fill:#F0E68C,stroke:#000,stroke-width:1px;
```
