# hadiuzzamanbappy/api-response-beautifier architecture

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

- Interactive diagram: https://gitdiagram.com/hadiuzzamanbappy/api-response-beautifier
- Repository: https://github.com/hadiuzzamanbappy/api-response-beautifier

## Overview

1. **Project shape**
   - This is a **Chrome extension** built with **React 19, TypeScript, Tailwind CSS, and Vite**.
   - The repo is organized around two UI entrypoints: a **page/injected viewer** and a **browser action popup**, with a **background script** coordinating extension behavior.

2. **Extension manifest as the integration boundary**
   - `public/manifest.json` is the main browser-facing contract.
   - It defines how the extension loads, what icons it uses, and which scripts/pages Chrome wires together.
   - `public/icons/` provides the extension branding assets used by Chrome’s extension UI.

3. **Build/runtime separation**
   - `vite.config.ts` and the TS config files drive the build pipeline.
   - `package.json`/`package-lock.json` indicate a standard Node-based toolchain for bundling the React apps and extension assets into `dist/`.
   - `postcss.config.js`, `tailwind.config.js`, and `eslint.config.js` support styling and code quality but are not runtime subsystems.

4. **Background layer**
   - `src/background/index.ts` is the extension’s non-UI runtime entrypoint.
   - Architecturally, this is the place where Chrome-extension concerns live: lifecycle handling, tab/context coordination, and message passing between extension surfaces.
   - It is the likely bridge between browser events and the React UI.

5. **Main viewer UI**
   - `src/App.tsx` is the primary application shell for the core JSON viewer experience.
   - `src/index.tsx` bootstraps that shell into the DOM for the main runtime surface.
   - Given the README, this surface is where raw JSON is parsed and rendered into the interactive beautified tree.

6. **Popup UI as a separate surface**
   - `popup.html`, `src/popup/index.tsx`, and `src/popup/Popup.tsx` form a second React root dedicated to the extension popup.
   - This is a distinct boundary from the main viewer, so the popup can provide compact controls or status without sharing the same mount target as the full-page interface.

7. **Recursive JSON rendering subsystem**
   - `src/components/JsonNode.tsx` is the core data-visualization component.
   - Its role is to recursively render objects and arrays as a collapsible tree, which is the central visualization described in the README.
   - This component is the main structural engine of the UI: it turns nested JSON data into a navigable hierarchy.

8. **Search and navigation subsystem**
   - `src/hooks/useJsonSearch.ts` encapsulates search state and derived traversal behavior.
   - It likely powers key/value matching, match counting, and auto-expansion of branches that contain results.
   - This hook is the main data-flow layer between the search UI and the recursive tree renderer.

9. **Shared UI utility layer**
   - `src/utils/cn.ts` is a small but important cross-cutting helper for composing CSS class names.
   - In a Tailwind-based UI, this kind of utility is typically used throughout the component tree to keep styling conditional and consistent.

10. **Styling and presentation**
   - `src/index.css` plus Tailwind provide the visual system for the extension.
   - The README’s theme handling, glassmorphism, and state-driven visual feedback imply that most UI state is reflected through class-based styling rather than imperative DOM manipulation.

11. **Primary data flow**
   - Raw JSON arrives from the page/extension context, is parsed into a JavaScript object, and then passed into the tree renderer.
   - Search input updates hook state, which filters/highlights matches and drives auto-expansion in the node tree.
   - User interactions such as collapsing nodes, copying paths/values, or toggling raw mode feed back into the same UI state layer.

12. **Boundary between browser content and React rendering**
   - The README indicates the extension works by **content-script injection at `document_start`**, which means the viewer is intended to run in the page context very early.
   - That creates a clear separation: **browser/DOM interception and messaging** in the extension runtime, and **pure React rendering/state** in the UI layer.

13. **What to diagram**
   - A good architecture diagram would show:
     - Chrome/extension runtime on one side
     - `background` script as the coordinator
     - the injected/main React app as the JSON viewer
     - the popup React app as a separate UI surface
     - shared components/hooks/utilities used by the main viewer
     - manifest/build tooling as the packaging layer that connects everything

Main entry points: [`src/App.tsx`](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/App.tsx) (Viewer shell), [`vite.config.ts`](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/vite.config.ts) (Vite config), [`public/manifest.json`](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/public/manifest.json) (Manifest), [`src/background/index.ts`](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/background/index.ts) (Background)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_extension["Extension runtime"]
  node_node_background["Background<br/>extension runtime<br/>[index.ts]"]
end

subgraph group_group_viewer["Main viewer"]
  node_node_app_shell["Viewer shell<br/>react app<br/>[App.tsx]"]
  node_node_bootstrap["Main entry<br/>react bootstrap<br/>[index.tsx]"]
end

subgraph group_group_popup["Popup UI"]
  node_node_popup_html["Popup page<br/>extension page<br/>[popup.html]"]
  node_node_popup_bootstrap["Popup entry<br/>react bootstrap<br/>[index.tsx]"]
  node_node_popup_ui["Popup UI<br/>react component<br/>[Popup.tsx]"]
end

subgraph group_group_shared["Shared UI"]
  node_node_jsonnode["JSON node<br/>tree renderer<br/>[JsonNode.tsx]"]
  node_node_search["Search hook<br/>state hook<br/>[useJsonSearch.ts]"]
  node_node_cn["Class util<br/>helper<br/>[cn.ts]"]
  node_node_styles["Styles<br/>styling<br/>[index.css]"]
end

subgraph group_group_build["Build and manifest"]
  node_node_manifest["Manifest<br/>[manifest.json]"]
  node_node_icons["Icons<br/>asset set"]
  node_node_vite["Vite config<br/>build config<br/>[vite.config.ts]"]
  node_node_tsconfig["TS configs<br/>typecheck config<br/>[tsconfig.json]"]
  node_node_node_tsconfig["Node TS<br/>typecheck config<br/>[tsconfig.node.json]"]
  node_node_app_tsconfig["App TS<br/>typecheck config<br/>[tsconfig.app.json]"]
  node_node_package["Package<br/>toolchain<br/>[package.json]"]
end

node_node_manifest -->|"loads"| node_node_background
node_node_manifest -->|"injects"| node_node_bootstrap
node_node_manifest -->|"opens"| node_node_popup_html
node_node_manifest -->|"references"| node_node_icons
node_node_package -->|"drives"| node_node_vite
node_node_vite -->|"bundles"| node_node_manifest
node_node_vite -->|"compiles"| node_node_bootstrap
node_node_vite -->|"compiles"| node_node_popup_bootstrap
node_node_vite -->|"bundles"| node_node_background
node_node_tsconfig -->|"extends"| node_node_app_tsconfig
node_node_tsconfig -->|"extends"| node_node_node_tsconfig
node_node_bootstrap -->|"mounts"| node_node_app_shell
node_node_app_shell -->|"renders"| node_node_jsonnode
node_node_app_shell -->|"uses"| node_node_search
node_node_jsonnode -->|"reacts to"| node_node_search
node_node_jsonnode -->|"styles"| node_node_cn
node_node_app_shell -->|"styles"| node_node_cn
node_node_app_shell -->|"styled by"| node_node_styles
node_node_popup_bootstrap -->|"mounts"| node_node_popup_ui
node_node_popup_ui -->|"styles"| node_node_cn
node_node_popup_ui -->|"styled by"| node_node_styles
node_node_background -.->|"messages"| node_node_app_shell
node_node_background -.->|"messages"| node_node_popup_ui

click node_node_manifest "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/public/manifest.json"
click node_node_icons "https://github.com/hadiuzzamanbappy/api-response-beautifier/tree/main/public/icons"
click node_node_vite "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/vite.config.ts"
click node_node_tsconfig "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/tsconfig.json"
click node_node_node_tsconfig "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/tsconfig.node.json"
click node_node_app_tsconfig "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/tsconfig.app.json"
click node_node_package "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/package.json"
click node_node_background "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/background/index.ts"
click node_node_app_shell "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/App.tsx"
click node_node_bootstrap "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/index.tsx"
click node_node_jsonnode "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/components/JsonNode.tsx"
click node_node_search "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/hooks/useJsonSearch.ts"
click node_node_cn "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/utils/cn.ts"
click node_node_styles "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/index.css"
click node_node_popup_html "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/popup.html"
click node_node_popup_bootstrap "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/popup/index.tsx"
click node_node_popup_ui "https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/popup/Popup.tsx"

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_node_background toneBlue
class node_node_app_shell,node_node_bootstrap toneAmber
class node_node_popup_html,node_node_popup_bootstrap,node_node_popup_ui toneMint
class node_node_jsonnode,node_node_search,node_node_cn,node_node_styles toneRose
class node_node_manifest,node_node_icons,node_node_vite,node_node_tsconfig,node_node_node_tsconfig,node_node_app_tsconfig,node_node_package toneIndigo
```

## Components

### Extension runtime

Chrome extension entrypoints and browser-facing wiring.

- [Background](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/background/index.ts): extension runtime · Non-UI extension entrypoint coordinating lifecycle and messaging. · `src/background/index.ts`

### Main viewer

Injected/page UI for rendering and interacting with JSON.

- [Viewer shell](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/App.tsx): react app · Main JSON viewer application shell. · `src/App.tsx`
- [Main entry](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/index.tsx): react bootstrap · Bootstraps the main viewer into the page DOM. · `src/index.tsx`

### Popup UI

Compact extension popup surface.

- [Popup page](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/popup.html): extension page · HTML mount page for the popup surface. · `popup.html`
- [Popup entry](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/popup/index.tsx): react bootstrap · Bootstraps the popup React root. · `src/popup/index.tsx`
- [Popup UI](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/popup/Popup.tsx): react component · Popup interface for compact extension controls or status. · `src/popup/Popup.tsx`

### Shared UI

Reusable components, hooks, and styling used by the viewer.

- [JSON node](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/components/JsonNode.tsx): tree renderer · Recursive collapsible renderer for objects and arrays. · `src/components/JsonNode.tsx`
- [Search hook](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/hooks/useJsonSearch.ts): state hook · Search state and traversal logic for matching and expansion. · `src/hooks/useJsonSearch.ts`
- [Class util](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/utils/cn.ts): helper · CSS class composition helper used across the UI. · `src/utils/cn.ts`
- [Styles](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/src/index.css): styling · Global styles and Tailwind-driven presentation layer. · `src/index.css`

### Build and manifest

Packaging, configuration, and extension assets.

- [Manifest](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/public/manifest.json): chrome manifest · Browser contract that declares extension entrypoints, permissions, and assets. · `public/manifest.json`
- [Icons](https://github.com/hadiuzzamanbappy/api-response-beautifier/tree/main/public/icons): asset set · Extension branding assets referenced by Chrome UI. · `public/icons`
- [Vite config](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/vite.config.ts): build config · Build pipeline and bundling setup for the extension. · `vite.config.ts`
- [TS configs](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/tsconfig.json): typecheck config · TypeScript project configuration for app and node builds. · `tsconfig.json`
- [Node TS](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/tsconfig.node.json): typecheck config · TypeScript settings for Node-side tooling. · `tsconfig.node.json`
- [App TS](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/tsconfig.app.json): typecheck config · TypeScript settings for the React extension app. · `tsconfig.app.json`
- [Package](https://github.com/hadiuzzamanbappy/api-response-beautifier/blob/main/package.json): toolchain · Node dependency and script metadata for the extension build. · `package.json`

## Connections

- Manifest → Background: loads · Manifest wires the background runtime into the extension.
- Manifest → Main entry: injects · Manifest defines the main viewer entrypoint used in the page context.
- Manifest → Popup page: opens · Manifest registers the popup surface as an extension page.
- Manifest → Icons: references · Manifest points Chrome to the extension icon assets.
- Package → Vite config: drives · Package scripts invoke the build pipeline.
- Vite config → Manifest: bundles · Build output packages the extension contract and assets.
- Vite config → Main entry: compiles · Vite builds the main React viewer entry.
- Vite config → Popup entry: compiles · Vite builds the popup React entry.
- Vite config → Background: bundles · Vite includes the background runtime entry.
- TS configs → App TS: extends · Root TypeScript configuration informs the app build.
- TS configs → Node TS: extends · Root TypeScript configuration informs the Node/tooling build.
- Main entry → Viewer shell: mounts · Main entry renders the viewer shell.
- Viewer shell → JSON node: renders · Viewer shell delegates tree visualization to the recursive node renderer.
- Viewer shell → Search hook: uses · Viewer shell uses search state to drive filtering and expansion.
- JSON node → Search hook: reacts to · Tree renderer responds to search matches and expansion state.
- JSON node → Class util: styles · Node renderer uses shared class composition.
- Viewer shell → Class util: styles · Viewer shell uses shared class composition.
- Viewer shell → Styles: styled by · Viewer shell is presented through global and utility styling.
- Popup entry → Popup UI: mounts · Popup entry renders the popup component.
- Popup UI → Class util: styles · Popup UI uses the shared class helper.
- Popup UI → Styles: styled by · Popup UI uses the shared styling system.
- Background → Viewer shell: messages · Background coordinates data and events with the main viewer.
- Background → Popup UI: messages · Background can coordinate popup-driven extension actions.
