# jraversbcn21/pixelruler architecture

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

- Interactive diagram: https://gitdiagram.com/jraversbcn21/pixelruler
- Repository: https://github.com/jraversbcn21/pixelruler

## Overview

PixelRuler is a Chrome extension for inspecting web-page layout. The main workflow is to activate measurement from the popup or keyboard shortcut, inspect hovered elements and click for details, then optionally compare spacing or copy the tooltip. The graph preserves the documented configuration and inspection capabilities. Some content-script handlers are omitted from the excerpts, so unverified runtime links are left out or marked dashed.

Main entry points: [`content.js`](https://github.com/jraversbcn21/pixelruler/blob/main/content.js) (Element inspector), [`popup.js`](https://github.com/jraversbcn21/pixelruler/blob/main/popup.js) (Popup controls), [`background.js`](https://github.com/jraversbcn21/pixelruler/blob/main/background.js) (Shortcut handler), [`content.css`](https://github.com/jraversbcn21/pixelruler/blob/main/content.css) (Visual overlays)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_controls["Activation and settings"]
  node_popup["Popup controls<br/>[popup.js]"]
  node_shortcut["Shortcut handler<br/>[background.js]"]
  node_manifest["Extension config<br/>[manifest.json]"]
  node_settings[("Saved preferences<br/>[popup.js]")]
end

subgraph group_inspection["Page inspection"]
  node_inspector["Element inspector<br/>[content.js]"]
  node_overlays["Visual overlays<br/>[content.css]"]
  node_element_details["Element details<br/>[content.js]"]
  node_box_model["Box model<br/>[content.js]"]
  node_distance_geometry["Distance geometry<br/>[measure.js]"]
  node_distance_display["Distance display<br/>[content.js]"]
  node_tooltip_copy["Tooltip and copy<br/>[content.js]"]
end

subgraph group_platform["Chrome platform"]
  node_chrome{{"Chrome APIs"}}
end

node_user(("User"))
node_page["Web page"]

node_user -->|"opens"| node_popup
node_user -->|"presses shortcut"| node_shortcut
node_popup -->|"queries active tab"| node_chrome
node_popup -->|"loads and saves"| node_settings
node_inspector -->|"loads preferences"| node_settings
node_popup -->|"activates or injects"| node_inspector
node_popup -->|"injects styles"| node_overlays
node_shortcut -->|"queries active tab"| node_chrome
node_shortcut -->|"toggles or injects"| node_inspector
node_shortcut -->|"injects styles"| node_overlays
node_page -->|"provides elements"| node_inspector
node_inspector -->|"reads dimensions and typography"| node_element_details
node_inspector -->|"reads spacing"| node_box_model
node_inspector -->|"renders highlights"| node_overlays
node_inspector -.->|"requests gap segments"| node_distance_geometry
node_inspector -->|"renders measurements"| node_distance_display
node_inspector -->|"shows details and copies"| node_tooltip_copy
node_manifest -.->|"configures extension"| node_chrome

click node_popup "https://github.com/jraversbcn21/pixelruler/blob/main/popup.js"
click node_shortcut "https://github.com/jraversbcn21/pixelruler/blob/main/background.js"
click node_manifest "https://github.com/jraversbcn21/pixelruler/blob/main/manifest.json"
click node_settings "https://github.com/jraversbcn21/pixelruler/blob/main/popup.js"
click node_inspector "https://github.com/jraversbcn21/pixelruler/blob/main/content.js"
click node_overlays "https://github.com/jraversbcn21/pixelruler/blob/main/content.css"
click node_element_details "https://github.com/jraversbcn21/pixelruler/blob/main/content.js"
click node_box_model "https://github.com/jraversbcn21/pixelruler/blob/main/content.js"
click node_distance_geometry "https://github.com/jraversbcn21/pixelruler/blob/main/measure.js"
click node_distance_display "https://github.com/jraversbcn21/pixelruler/blob/main/content.js"
click node_tooltip_copy "https://github.com/jraversbcn21/pixelruler/blob/main/content.js"

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_popup,node_shortcut,node_manifest,node_settings,node_user toneBlue
class node_inspector,node_overlays,node_element_details,node_box_model,node_distance_geometry,node_distance_display,node_tooltip_copy toneAmber
class node_chrome toneMint
class node_page toneIndigo
```

## Components

### Activation and settings

- [Popup controls](https://github.com/jraversbcn21/pixelruler/blob/main/popup.js): `popup.js`
- [Shortcut handler](https://github.com/jraversbcn21/pixelruler/blob/main/background.js): `background.js`
- [Extension config](https://github.com/jraversbcn21/pixelruler/blob/main/manifest.json): `manifest.json`
- [Saved preferences](https://github.com/jraversbcn21/pixelruler/blob/main/popup.js): `popup.js`

### Page inspection

- [Element inspector](https://github.com/jraversbcn21/pixelruler/blob/main/content.js): `content.js`
- [Visual overlays](https://github.com/jraversbcn21/pixelruler/blob/main/content.css): `content.css`
- [Element details](https://github.com/jraversbcn21/pixelruler/blob/main/content.js): `content.js`
- [Box model](https://github.com/jraversbcn21/pixelruler/blob/main/content.js): `content.js`
- [Distance geometry](https://github.com/jraversbcn21/pixelruler/blob/main/measure.js): `measure.js`
- [Distance display](https://github.com/jraversbcn21/pixelruler/blob/main/content.js): `content.js`
- [Tooltip and copy](https://github.com/jraversbcn21/pixelruler/blob/main/content.js): `content.js`

### Chrome platform

- **Chrome APIs**

### Other components

- **User**
- **Web page**

## Connections

- User → Popup controls: opens (evidence: `README.md`)
- User → Shortcut handler: presses shortcut (evidence: `README.md`)
- Popup controls → Chrome APIs: queries active tab (evidence: `popup.js`)
- Popup controls → Saved preferences: loads and saves (evidence: `popup.js`)
- Element inspector → Saved preferences: loads preferences (evidence: `content.js`)
- Popup controls → Element inspector: activates or injects (evidence: `popup.js`)
- Popup controls → Visual overlays: injects styles (evidence: `popup.js`)
- Shortcut handler → Chrome APIs: queries active tab (evidence: `background.js`)
- Shortcut handler → Element inspector: toggles or injects (evidence: `background.js`)
- Shortcut handler → Visual overlays: injects styles (evidence: `background.js`)
- Web page → Element inspector: provides elements (evidence: `README.md`)
- Element inspector → Element details: reads dimensions and typography (evidence: `README.md`)
- Element inspector → Box model: reads spacing (evidence: `content.js`)
- Element inspector → Visual overlays: renders highlights (evidence: `content.js`)
- Element inspector → Distance geometry: requests gap segments
- Element inspector → Distance display: renders measurements (evidence: `content.js`)
- Element inspector → Tooltip and copy: shows details and copies (evidence: `README.md`)
- Extension config → Chrome APIs: configures extension
