# ivaishnavraj/crx-blueprint architecture

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

- Interactive diagram: https://gitdiagram.com/ivaishnavraj/crx-blueprint
- Repository: https://github.com/ivaishnavraj/crx-blueprint

## Overview

1. **Project type and boundary**
   - This is a **Chromium browser extension** for inspecting extension packages, not a server app.
   - The whole system stays inside the browser: there is no backend, API, or external processing service in the architecture.

2. **Top-level modules**
   - `manifest.json` defines the extension entrypoints and permissions.
   - `popup/` provides the user-facing launcher UI.
   - `background/` contains the long-lived orchestration logic.
   - `editor/` is the in-browser file/package viewer.
   - `lib/` bundles third-party parsing/rendering libraries.
   - `icons/` and `legal/` are supporting assets and static compliance pages.

3. **User entry points**
   - The extension appears to support two main entry flows:
     - opening the **popup** from the browser toolbar,
     - using the **right-click/context-menu** style flow described in the README.
   - Both paths ultimately hand a selected `.crx`, `.zip`, or extension source package into the same processing pipeline.

4. **Background orchestration layer**
   - `background/background.js` is the coordination boundary between browser events and the viewer UI.
   - It likely receives the user’s selection, prepares package data, and opens or feeds the editor view.
   - This layer is where browser-extension lifecycle concerns live: event handling, tab/window messaging, and package handoff.

5. **Package ingestion and CRX handling**
   - A core architectural step is converting a **CRX binary package** into something the extension can inspect.
   - The README indicates this is done with low-level binary parsing using **`DataView`** to read CRX headers and then extract the embedded ZIP payload.
   - This creates an in-memory archive representation that is passed forward for inspection, without writing to a server.

6. **Archive and file abstraction**
   - `lib/jszip.js` provides archive decompression and file enumeration.
   - Once the package is unpacked, the system treats it as a virtual file tree, allowing the editor to browse files as separate documents.
   - This is the main data model boundary: “package bytes” → “archive entries” → “rendered file views.”

7. **Viewer/editor subsystem**
   - `editor/viewer.html` and `editor/viewer.js` implement the main inspection workspace.
   - This is where the extension source is displayed, navigated, and rendered.
   - The editor is responsible for choosing the right presentation mode per file type rather than treating all files as plain text.

8. **Rendering pipeline**
   - The repo includes several specialized renderers in `lib/`:
     - **Prism.js** and language grammars for syntax highlighting,
     - **beautify.js / beautify-html.js / beautify-css.js** for formatting/minification reversal,
     - **prism-markdown.js** and **prism-json.js** for common structured formats.
   - The viewer likely routes files through this pipeline based on extension/MIME-like inference.

9. **Asset preview subsystem**
   - The README describes support for images, audio, video, fonts, and document/data formats.
   - Architecturally, this implies the editor has multiple preview modes:
     - code viewer,
     - image renderer,
     - media player,
     - font preview,
     - raw text/data viewer.
   - This is a key boundary for diagramming: a single package fan-outs into specialized renderers.

10. **Local-only privacy model**
   - The extension’s security model is “zero persistence”: all unpacking and rendering happen **in-browser and in-memory**.
   - Closing the viewer tab is intended to drop the extracted data.
   - That means the architecture deliberately avoids storage, sync, or network dependencies in the processing path.

11. **Static compliance and branding**
   - `legal/privacy.html` serves the privacy notice inside the extension context.
   - `icons/` provides browser UI branding and install-time visuals.
   - These are supporting surfaces, not part of the package-processing pipeline.

12. **Main data flow to capture in a diagram**
   - **User action** → popup/context/menu trigger → background orchestration → CRX/ZIP ingestion → binary header parsing / archive extraction → in-memory file tree → editor/viewer rendering → file-type-specific preview/formatting.
   - The clearest architectural boundary is between **package extraction** and **rendering**, with the background script acting as the bridge.

13. **Key technologies that materially shape the design**
   - The repo is built with **vanilla JavaScript, HTML, and CSS**.
   - **JSZip** and **DataView** are foundational to the archive pipeline.
   - **Prism.js** and beautifiers define the inspection experience.
   - The absence of a backend is a core architectural property, not just an implementation detail.

Main entry points: [`manifest.json`](https://github.com/ivaishnavraj/crx-blueprint/blob/main/manifest.json) (Manifest), [`editor/viewer.js`](https://github.com/ivaishnavraj/crx-blueprint/blob/main/editor/viewer.js) (Viewer logic), [`background/background.js`](https://github.com/ivaishnavraj/crx-blueprint/blob/main/background/background.js) (Background), [`editor/viewer.html`](https://github.com/ivaishnavraj/crx-blueprint/blob/main/editor/viewer.html) (Viewer shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_manifest["Manifest<br/>[manifest.json]"]
  node_popup_ui["Popup UI<br/>launcher ui<br/>[popup.html]"]
  node_popup_logic["Popup logic<br/>ui script<br/>[popup.js]"]
end

subgraph group_orchestration["Background orchestration"]
  node_background["Background<br/>orchestrator<br/>[background.js]"]
  node_context_flow(("Context flow<br/>menu entry"))
  node_crx_parser["CRX parser<br/>binary parser"]
  node_archive_model[("Archive model<br/>in-memory tree")]
end

subgraph group_inspection["Viewer and rendering"]
  node_viewer_shell["Viewer shell<br/>inspection app<br/>[viewer.html]"]
  node_viewer_logic["Viewer logic<br/>viewer controller<br/>[viewer.js]"]
  node_code_render["Code render<br/>syntax view"]
  node_preview_modes["Preview modes<br/>media/render views"]
end

subgraph group_libraries["Parsing and render libs"]
  node_jszip["JSZip<br/>archive library<br/>[jszip.js]"]
  node_prism_core["Prism<br/>syntax highlighter<br/>[prism.js]"]
  node_prism_json["JSON grammar<br/>[prism-json.js]"]
  node_prism_md["Markdown grammar<br/>[prism-markdown.js]"]
  node_beautify_core["Beautify<br/>formatter<br/>[beautify.js]"]
end

subgraph group_support["Support assets"]
  node_privacy_page["Privacy page<br/>static page<br/>[privacy.html]"]
  node_branding(("Branding<br/>icons"))
end

node_manifest -->|"declares"| node_popup_ui
node_manifest -->|"declares"| node_background
node_manifest -->|"declares"| node_viewer_shell
node_popup_ui -->|"drives"| node_popup_logic
node_popup_logic -->|"launches"| node_background
node_context_flow -->|"routes to"| node_background
node_background -->|"parses"| node_crx_parser
node_crx_parser -->|"hands off"| node_jszip
node_jszip -->|"builds"| node_archive_model
node_background -->|"opens"| node_viewer_shell
node_viewer_shell -->|"boots"| node_viewer_logic
node_viewer_logic -->|"browses"| node_archive_model
node_viewer_logic -->|"renders"| node_code_render
node_viewer_logic -->|"renders"| node_preview_modes
node_code_render -->|"uses"| node_prism_core
node_code_render -->|"extends"| node_prism_json
node_code_render -->|"extends"| node_prism_md
node_viewer_logic -->|"formats"| node_beautify_core
node_manifest -->|"exposes"| node_privacy_page
node_manifest -->|"uses"| node_branding

click node_manifest "https://github.com/ivaishnavraj/crx-blueprint/blob/main/manifest.json"
click node_popup_ui "https://github.com/ivaishnavraj/crx-blueprint/blob/main/popup/popup.html"
click node_popup_logic "https://github.com/ivaishnavraj/crx-blueprint/blob/main/popup/popup.js"
click node_background "https://github.com/ivaishnavraj/crx-blueprint/blob/main/background/background.js"
click node_viewer_shell "https://github.com/ivaishnavraj/crx-blueprint/blob/main/editor/viewer.html"
click node_viewer_logic "https://github.com/ivaishnavraj/crx-blueprint/blob/main/editor/viewer.js"
click node_jszip "https://github.com/ivaishnavraj/crx-blueprint/blob/main/lib/jszip.js"
click node_prism_core "https://github.com/ivaishnavraj/crx-blueprint/blob/main/lib/prism.js"
click node_prism_json "https://github.com/ivaishnavraj/crx-blueprint/blob/main/lib/prism-json.js"
click node_prism_md "https://github.com/ivaishnavraj/crx-blueprint/blob/main/lib/prism-markdown.js"
click node_beautify_core "https://github.com/ivaishnavraj/crx-blueprint/blob/main/lib/beautify.js"
click node_privacy_page "https://github.com/ivaishnavraj/crx-blueprint/blob/main/legal/privacy.html"
click node_branding "https://github.com/ivaishnavraj/crx-blueprint/tree/main/icons"

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_manifest,node_popup_ui,node_popup_logic toneBlue
class node_background,node_context_flow,node_crx_parser,node_archive_model toneAmber
class node_viewer_shell,node_viewer_logic,node_code_render,node_preview_modes toneMint
class node_jszip,node_prism_core,node_prism_json,node_prism_md,node_beautify_core toneRose
class node_privacy_page,node_branding toneIndigo
```

## Components

### Entry points

Toolbar popup and extension entry surfaces

- [Manifest](https://github.com/ivaishnavraj/crx-blueprint/blob/main/manifest.json): extension manifest · Declares extension entrypoints, permissions, and wiring · `manifest.json`
- [Popup UI](https://github.com/ivaishnavraj/crx-blueprint/blob/main/popup/popup.html): launcher ui · Toolbar entry point for starting inspection · `popup/popup.html`
- [Popup logic](https://github.com/ivaishnavraj/crx-blueprint/blob/main/popup/popup.js): ui script · Handles popup interactions and dispatches selection flow · `popup/popup.js`

### Background orchestration

Browser event handling and package handoff

- [Background](https://github.com/ivaishnavraj/crx-blueprint/blob/main/background/background.js): orchestrator · Long-lived coordination boundary for browser events and viewer handoff · `background/background.js`
- **Context flow**: menu entry · Right-click style entry path into the same package pipeline
- **CRX parser**: binary parser · Reads CRX headers from bytes and extracts the embedded archive payload
- **Archive model**: in-memory tree · Virtual file tree built from extracted package contents

### Viewer and rendering

In-browser package inspection workspace

- [Viewer shell](https://github.com/ivaishnavraj/crx-blueprint/blob/main/editor/viewer.html): inspection app · Main in-browser workspace for browsing and inspecting package files · `editor/viewer.html`
- [Viewer logic](https://github.com/ivaishnavraj/crx-blueprint/blob/main/editor/viewer.js): viewer controller · Coordinates file selection, preview choice, and rendering · `editor/viewer.js`
- **Code render**: syntax view · Syntax highlighting for source and structured text files
- **Preview modes**: media/render views · Specialized previews for images, audio, video, fonts, and documents

### Parsing and render libs

Third-party and bundled rendering helpers

- [JSZip](https://github.com/ivaishnavraj/crx-blueprint/blob/main/lib/jszip.js): archive library · Unpacks archive entries and enumerates package files · `lib/jszip.js`
- [Prism](https://github.com/ivaishnavraj/crx-blueprint/blob/main/lib/prism.js): syntax highlighter · Core syntax highlighting engine · `lib/prism.js`
- [JSON grammar](https://github.com/ivaishnavraj/crx-blueprint/blob/main/lib/prism-json.js): grammar · Adds JSON highlighting support · `lib/prism-json.js`
- [Markdown grammar](https://github.com/ivaishnavraj/crx-blueprint/blob/main/lib/prism-markdown.js): grammar · Adds Markdown highlighting support · `lib/prism-markdown.js`
- [Beautify](https://github.com/ivaishnavraj/crx-blueprint/blob/main/lib/beautify.js): formatter · Formatting helpers used to improve readable source display · `lib/beautify.js`

### Support assets

Static compliance and branding assets

- [Privacy page](https://github.com/ivaishnavraj/crx-blueprint/blob/main/legal/privacy.html): static page · In-extension privacy notice · `legal/privacy.html`
- [Branding](https://github.com/ivaishnavraj/crx-blueprint/tree/main/icons): icons · Extension icons and install-time visuals · `icons`

## Connections

- Manifest → Popup UI: declares · Manifest wires the popup launcher
- Manifest → Background: declares · Manifest registers the background orchestration script
- Manifest → Viewer shell: declares · Manifest exposes the inspection workspace
- Popup UI → Popup logic: drives · Popup UI events are handled by popup script
- Popup logic → Background: launches · Popup sends the selected package into background orchestration
- Context flow → Background: routes to · Context-menu style entry also lands in background orchestration
- Background → CRX parser: parses · Background turns CRX bytes into an embedded archive payload
- CRX parser → JSZip: hands off · Extracted archive bytes are passed to archive handling
- JSZip → Archive model: builds · Archive entries become an in-memory file tree
- Background → Viewer shell: opens · Background hands the package off to the viewer workspace
- Viewer shell → Viewer logic: boots · Viewer page loads the inspection controller
- Viewer logic → Archive model: browses · Viewer reads the virtual file tree for navigation and selection
- Viewer logic → Code render: renders · Source and text files go through syntax-highlighted code views
- Viewer logic → Preview modes: renders · Binary and media assets use specialized preview modes
- Code render → Prism: uses · Syntax highlighting is provided by Prism core
- Code render → JSON grammar: extends · JSON files use a dedicated Prism grammar
- Code render → Markdown grammar: extends · Markdown files use a dedicated Prism grammar
- Viewer logic → Beautify: formats · Beautifiers improve readability before display
- Manifest → Privacy page: exposes · Privacy notice is part of the extension package
- Manifest → Branding: uses · Icons supply browser UI branding
