# ultroned/xray-react architecture

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

- Interactive diagram: https://gitdiagram.com/ultroned/xray-react
- Repository: https://github.com/ultroned/xray-react

## Overview

X-Ray React is a development-time React layout inspector. A developer enables it through a Vite or Webpack plugin (or manual imports); the browser overlay exposes rendered component hierarchy, and selecting a component sends its path to a server that resolves and opens the source file in an editor. Source excerpts show plugin injection, scanning/mapping, client socket events, and editor resolution; detailed UI behavior and some server wiring are only partially sampled, so those links are included only where supported by excerpts or README statements.

Main entry points: [`lib/plugins/webpack.js`](https://github.com/ultroned/xray-react/blob/main/lib/plugins/webpack.js) (Webpack Plugin), [`lib/plugins/vite.js`](https://github.com/ultroned/xray-react/blob/main/lib/plugins/vite.js) (Vite Plugin), [`src/ui-utils.js`](https://github.com/ultroned/xray-react/blob/main/src/ui-utils.js) (Inspector UI), [`server.js`](https://github.com/ultroned/xray-react/blob/main/server.js) (Standalone Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Bundler Integration"]
  node_webpack["Webpack Plugin<br/>[webpack.js]"]
  node_vite["Vite Plugin<br/>[vite.js]"]
  node_standalone["Standalone Server<br/>[server.js]"]
end

subgraph group_mapping["Project Mapping"]
  node_scanner["Source Scanner<br/>[source-utils.js]"]
  node_componentmap["Component Mapping<br/>[source-utils.js]"]
end

subgraph group_browser["Browser Inspector"]
  node_overlay["Inspector UI<br/>[ui-utils.js]"]
  node_markup["UI Partials<br/>[partials.js]"]
  node_styles["Overlay Styles<br/>[css.js]"]
  node_uiconstants["UI Constants<br/>[constants.js]"]
  node_client["Socket Client"]
end

subgraph group_open["Source Opening"]
  node_editor["Editor Launcher<br/>[editor-utils.js]"]
end

node_developer(("Developer"))
node_socketio(("Socket.IO Service"))
node_reactapp(("React Application"))
node_cdn(("Socket.IO CDN"))

node_developer -->|"configures"| node_webpack
node_developer -->|"configures"| node_vite
node_developer -->|"runs"| node_standalone
node_webpack -->|"scans sources"| node_scanner
node_webpack -->|"builds maps"| node_componentmap
node_vite -->|"scans sources"| node_scanner
node_vite -->|"resolves components"| node_componentmap
node_standalone -->|"scans sources"| node_scanner
node_standalone -->|"builds maps"| node_componentmap
node_webpack -->|"injects UI"| node_overlay
node_vite -->|"injects UI"| node_overlay
node_reactapp -.->|"renders with"| node_overlay
node_overlay -->|"uses markup"| node_markup
node_overlay -->|"uses styles"| node_styles
node_overlay -->|"uses constants"| node_uiconstants
node_webpack -->|"injects client"| node_client
node_vite -->|"injects client"| node_client
node_developer -->|"imports manually"| node_client
node_client -->|"loads library"| node_cdn
node_client -->|"connects and emits"| node_socketio
node_standalone -->|"serves events"| node_socketio
node_webpack -->|"starts server"| node_socketio
node_vite -->|"starts server"| node_socketio
node_standalone -->|"opens resolved file"| node_editor
node_webpack -->|"opens resolved file"| node_editor
node_vite -->|"opens resolved file"| node_editor

click node_webpack "https://github.com/ultroned/xray-react/blob/main/lib/plugins/webpack.js"
click node_vite "https://github.com/ultroned/xray-react/blob/main/lib/plugins/vite.js"
click node_standalone "https://github.com/ultroned/xray-react/blob/main/server.js"
click node_scanner "https://github.com/ultroned/xray-react/blob/main/lib/source-utils.js"
click node_componentmap "https://github.com/ultroned/xray-react/blob/main/lib/source-utils.js"
click node_overlay "https://github.com/ultroned/xray-react/blob/main/src/ui-utils.js"
click node_markup "https://github.com/ultroned/xray-react/blob/main/src/partials.js"
click node_styles "https://github.com/ultroned/xray-react/blob/main/src/css.js"
click node_uiconstants "https://github.com/ultroned/xray-react/blob/main/src/constants.js"
click node_client "https://github.com/ultroned/xray-react/blob/main/lib/xray-react-client.js"
click node_editor "https://github.com/ultroned/xray-react/blob/main/lib/editor-utils.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_webpack,node_vite,node_standalone toneBlue
class node_scanner,node_componentmap toneAmber
class node_overlay,node_markup,node_styles,node_uiconstants,node_client toneMint
class node_editor toneRose
class node_developer,node_socketio,node_reactapp,node_cdn toneIndigo
```

## Components

### Bundler Integration

- [Webpack Plugin](https://github.com/ultroned/xray-react/blob/main/lib/plugins/webpack.js): `lib/plugins/webpack.js`
- [Vite Plugin](https://github.com/ultroned/xray-react/blob/main/lib/plugins/vite.js): `lib/plugins/vite.js`
- [Standalone Server](https://github.com/ultroned/xray-react/blob/main/server.js): `server.js`

### Project Mapping

- [Source Scanner](https://github.com/ultroned/xray-react/blob/main/lib/source-utils.js): `lib/source-utils.js`
- [Component Mapping](https://github.com/ultroned/xray-react/blob/main/lib/source-utils.js): `lib/source-utils.js`

### Browser Inspector

- [Inspector UI](https://github.com/ultroned/xray-react/blob/main/src/ui-utils.js): `src/ui-utils.js`
- [UI Partials](https://github.com/ultroned/xray-react/blob/main/src/partials.js): `src/partials.js`
- [Overlay Styles](https://github.com/ultroned/xray-react/blob/main/src/css.js): `src/css.js`
- [UI Constants](https://github.com/ultroned/xray-react/blob/main/src/constants.js): `src/constants.js`
- [Socket Client](https://github.com/ultroned/xray-react/blob/main/lib/xray-react-client.js): `lib/xray-react-client.js`

### Source Opening

- [Editor Launcher](https://github.com/ultroned/xray-react/blob/main/lib/editor-utils.js): `lib/editor-utils.js`

### Other components

- **Developer**
- **Socket.IO Service**
- **React Application**
- **Socket.IO CDN**

## Connections

- Developer → Webpack Plugin: configures (evidence: `README.md`)
- Developer → Vite Plugin: configures (evidence: `README.md`)
- Developer → Standalone Server: runs (evidence: `README.md`)
- Webpack Plugin → Source Scanner: scans sources (evidence: `lib/plugins/webpack.js`)
- Webpack Plugin → Component Mapping: builds maps (evidence: `lib/plugins/webpack.js`)
- Vite Plugin → Source Scanner: scans sources (evidence: `lib/plugins/vite.js`)
- Vite Plugin → Component Mapping: resolves components (evidence: `lib/plugins/vite.js`)
- Standalone Server → Source Scanner: scans sources (evidence: `server.js`)
- Standalone Server → Component Mapping: builds maps (evidence: `server.js`)
- Webpack Plugin → Inspector UI: injects UI (evidence: `README.md`)
- Vite Plugin → Inspector UI: injects UI (evidence: `README.md`)
- React Application → Inspector UI: renders with
- Inspector UI → UI Partials: uses markup (evidence: `src/ui-utils.js`)
- Inspector UI → Overlay Styles: uses styles (evidence: `src/ui-utils.js`)
- Inspector UI → UI Constants: uses constants (evidence: `src/ui-utils.js`)
- Webpack Plugin → Socket Client: injects client (evidence: `lib/plugins/webpack.js`)
- Vite Plugin → Socket Client: injects client (evidence: `lib/plugins/vite.js`)
- Developer → Socket Client: imports manually (evidence: `README.md`)
- Socket Client → Socket.IO CDN: loads library (evidence: `lib/xray-react-client.js`)
- Socket Client → Socket.IO Service: connects and emits (evidence: `lib/xray-react-client.js`)
- Standalone Server → Socket.IO Service: serves events (evidence: `server.js`)
- Webpack Plugin → Socket.IO Service: starts server (evidence: `lib/plugins/webpack.js`)
- Vite Plugin → Socket.IO Service: starts server (evidence: `lib/plugins/vite.js`)
- Standalone Server → Editor Launcher: opens resolved file (evidence: `server.js`)
- Webpack Plugin → Editor Launcher: opens resolved file (evidence: `lib/plugins/webpack.js`)
- Vite Plugin → Editor Launcher: opens resolved file (evidence: `lib/plugins/vite.js`)
