# nodesecure/js-x-ray architecture

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

- Interactive diagram: https://gitdiagram.com/nodesecure/js-x-ray
- Repository: https://github.com/nodesecure/js-x-ray

## Overview

JS-X-Ray is a JavaScript/TypeScript static security analyzer: users submit source for parsing, AST-based analysis, dependency tracing, and security warnings. Its companion AI workspace enriches an existing analysis report and source with a structured LLM review. The core control-flow links are supported by the README and source-index references; links within unsampled subsystems are left out rather than inferred.

Main entry points: [`workspaces/js-x-ray/src/AstAnalyser.ts`](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/AstAnalyser.ts) (AST analyzer), [`workspaces/js-x-ray/src/ProbeRunner.ts`](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/ProbeRunner.ts) (Probe runner), [`workspaces/js-x-ray/src/probes/isRequire/isRequire.ts`](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/probes/isRequire/isRequire.ts) (Import tracing), [`workspaces/js-x-ray-ai/src/AiAstAnalyzer.ts`](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray-ai/src/AiAstAnalyzer.ts) (AI report analyzer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Analysis workflow"]
  node_analyzer["AST analyzer<br/>[AstAnalyser.ts]"]
  node_jsparser["JavaScript parser<br/>[JsSourceParser.ts]"]
  node_tsparser["TypeScript parser<br/>[TsSourceParser.ts]"]
  node_source["Source state<br/>[SourceFile.ts]"]
  node_pipeline["Analysis pipelines"]
  node_deobfuscator["Deobfuscation<br/>[Deobfuscator.ts]"]
  node_obfuscators["Obfuscator detectors"]
end

subgraph group_ast["AST and tracing"]
  node_walker["AST walker<br/>[walker.sync.ts]"]
  node_estree["ESTree helpers<br/>[toLiteral.ts]"]
  node_tracer["Variable tracing<br/>[VariableTracer.ts]"]
end

subgraph group_security["Security detection"]
  node_proberunner["Probe runner<br/>[ProbeRunner.ts]"]
  node_importprobe["Import tracing<br/>[isRequire.ts]"]
  node_cryptoprobes["Crypto checks"]
  node_securityprobes["Security probes"]
  node_warnings["Warnings and reports<br/>[warnings.ts]"]
end

subgraph group_ai["AI review"]
  node_ai_analyzer["AI report analyzer<br/>[AiAstAnalyzer.ts]"]
  node_prompt["Review prompt<br/>[prompt.ts]"]
  node_google["Google provider<br/>[GoogleProvider.ts]"]
  node_openai["OpenAI provider<br/>[OpenAiProvider.ts]"]
end

node_user(("Analyst"))
node_llm(("LLM service"))

node_user -->|"submits source"| node_analyzer
node_analyzer -->|"parses JavaScript"| node_jsparser
node_analyzer -->|"parses TypeScript"| node_tsparser
node_analyzer -->|"runs analysis"| node_pipeline
node_analyzer -->|"runs probes"| node_proberunner
node_analyzer -->|"creates source state"| node_source
node_analyzer -->|"checks obfuscation"| node_deobfuscator
node_deobfuscator -->|"identifies patterns"| node_obfuscators
node_proberunner -->|"dispatches probes"| node_importprobe
node_proberunner -->|"dispatches probes"| node_securityprobes
node_proberunner -->|"dispatches probes"| node_cryptoprobes
node_importprobe -->|"resolves imports"| node_tracer
node_importprobe -->|"reads AST values"| node_estree
node_securityprobes -->|"generates findings"| node_warnings
node_user -->|"requests AI review"| node_ai_analyzer
node_ai_analyzer -->|"selects provider"| node_google
node_ai_analyzer -->|"selects provider"| node_openai
node_google -->|"builds prompt"| node_prompt
node_openai -->|"builds prompt"| node_prompt
node_google -->|"requests completion"| node_llm
node_openai -.->|"requests completion"| node_llm

click node_analyzer "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/AstAnalyser.ts"
click node_jsparser "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/parsers/JsSourceParser.ts"
click node_tsparser "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/parsers/TsSourceParser.ts"
click node_source "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/SourceFile.ts"
click node_pipeline "https://github.com/nodesecure/js-x-ray/tree/master/workspaces/js-x-ray/src/pipelines"
click node_deobfuscator "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/Deobfuscator.ts"
click node_obfuscators "https://github.com/nodesecure/js-x-ray/tree/master/workspaces/js-x-ray/src/obfuscators"
click node_walker "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/walker/walker.sync.ts"
click node_estree "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/estree/functions/toLiteral.ts"
click node_tracer "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/VariableTracer.ts"
click node_proberunner "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/ProbeRunner.ts"
click node_importprobe "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/probes/isRequire/isRequire.ts"
click node_cryptoprobes "https://github.com/nodesecure/js-x-ray/tree/master/workspaces/js-x-ray/src/probes/crypto"
click node_securityprobes "https://github.com/nodesecure/js-x-ray/tree/master/workspaces/js-x-ray/src/probes"
click node_warnings "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/warnings.ts"
click node_ai_analyzer "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray-ai/src/AiAstAnalyzer.ts"
click node_prompt "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray-ai/src/providers/prompt.ts"
click node_google "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray-ai/src/providers/GoogleProvider.ts"
click node_openai "https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray-ai/src/providers/OpenAiProvider.ts"

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_analyzer,node_jsparser,node_tsparser,node_source,node_pipeline,node_deobfuscator,node_obfuscators toneBlue
class node_walker,node_estree,node_tracer toneAmber
class node_proberunner,node_importprobe,node_cryptoprobes,node_securityprobes,node_warnings toneMint
class node_ai_analyzer,node_prompt,node_google,node_openai toneRose
class node_user,node_llm toneIndigo
```

## Components

### Analysis workflow

- [AST analyzer](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/AstAnalyser.ts): `workspaces/js-x-ray/src/AstAnalyser.ts`
- [JavaScript parser](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/parsers/JsSourceParser.ts): `workspaces/js-x-ray/src/parsers/JsSourceParser.ts`
- [TypeScript parser](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/parsers/TsSourceParser.ts): `workspaces/js-x-ray/src/parsers/TsSourceParser.ts`
- [Source state](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/SourceFile.ts): `workspaces/js-x-ray/src/SourceFile.ts`
- [Analysis pipelines](https://github.com/nodesecure/js-x-ray/tree/master/workspaces/js-x-ray/src/pipelines): `workspaces/js-x-ray/src/pipelines`
- [Deobfuscation](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/Deobfuscator.ts): `workspaces/js-x-ray/src/Deobfuscator.ts`
- [Obfuscator detectors](https://github.com/nodesecure/js-x-ray/tree/master/workspaces/js-x-ray/src/obfuscators): `workspaces/js-x-ray/src/obfuscators`

### AST and tracing

- [AST walker](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/walker/walker.sync.ts): `workspaces/js-x-ray/src/walker/walker.sync.ts`
- [ESTree helpers](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/estree/functions/toLiteral.ts): `workspaces/js-x-ray/src/estree/functions/toLiteral.ts`
- [Variable tracing](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/VariableTracer.ts): `workspaces/js-x-ray/src/VariableTracer.ts`

### Security detection

- [Probe runner](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/ProbeRunner.ts): `workspaces/js-x-ray/src/ProbeRunner.ts`
- [Import tracing](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/probes/isRequire/isRequire.ts): `workspaces/js-x-ray/src/probes/isRequire/isRequire.ts`
- [Crypto checks](https://github.com/nodesecure/js-x-ray/tree/master/workspaces/js-x-ray/src/probes/crypto): `workspaces/js-x-ray/src/probes/crypto`
- [Security probes](https://github.com/nodesecure/js-x-ray/tree/master/workspaces/js-x-ray/src/probes): `workspaces/js-x-ray/src/probes`
- [Warnings and reports](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray/src/warnings.ts): `workspaces/js-x-ray/src/warnings.ts`

### AI review

- [AI report analyzer](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray-ai/src/AiAstAnalyzer.ts): `workspaces/js-x-ray-ai/src/AiAstAnalyzer.ts`
- [Review prompt](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray-ai/src/providers/prompt.ts): `workspaces/js-x-ray-ai/src/providers/prompt.ts`
- [Google provider](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray-ai/src/providers/GoogleProvider.ts): `workspaces/js-x-ray-ai/src/providers/GoogleProvider.ts`
- [OpenAI provider](https://github.com/nodesecure/js-x-ray/blob/master/workspaces/js-x-ray-ai/src/providers/OpenAiProvider.ts): `workspaces/js-x-ray-ai/src/providers/OpenAiProvider.ts`

### Other components

- **Analyst**
- **LLM service**

## Connections

- Analyst → AST analyzer: submits source (evidence: `README.md`)
- AST analyzer → JavaScript parser: parses JavaScript (evidence: `workspaces/js-x-ray/src/AstAnalyser.ts`)
- AST analyzer → TypeScript parser: parses TypeScript (evidence: `workspaces/js-x-ray/src/AstAnalyser.ts`)
- AST analyzer → Analysis pipelines: runs analysis (evidence: `workspaces/js-x-ray/src/AstAnalyser.ts`)
- AST analyzer → Probe runner: runs probes (evidence: `workspaces/js-x-ray/src/AstAnalyser.ts`)
- AST analyzer → Source state: creates source state (evidence: `workspaces/js-x-ray/src/AstAnalyser.ts`)
- AST analyzer → Deobfuscation: checks obfuscation (evidence: `workspaces/js-x-ray/src/AstAnalyser.ts`)
- Deobfuscation → Obfuscator detectors: identifies patterns (evidence: `workspaces/js-x-ray/src/obfuscators/jjencode.ts`)
- Probe runner → Import tracing: dispatches probes (evidence: `workspaces/js-x-ray/src/ProbeRunner.ts`)
- Probe runner → Security probes: dispatches probes (evidence: `workspaces/js-x-ray/src/ProbeRunner.ts`)
- Probe runner → Crypto checks: dispatches probes (evidence: `workspaces/js-x-ray/src/ProbeRunner.ts`)
- Import tracing → Variable tracing: resolves imports (evidence: `workspaces/js-x-ray/src/probes/isRequire/isRequire.ts`)
- Import tracing → ESTree helpers: reads AST values (evidence: `workspaces/js-x-ray/src/probes/isRequire/isRequire.ts`)
- Security probes → Warnings and reports: generates findings (evidence: `workspaces/js-x-ray/src/probes/unsafe-vm-context.ts`)
- Analyst → AI report analyzer: requests AI review (evidence: `workspaces/js-x-ray-ai/src/AiAstAnalyzer.ts`)
- AI report analyzer → Google provider: selects provider (evidence: `workspaces/js-x-ray-ai/src/AiAstAnalyzer.ts`)
- AI report analyzer → OpenAI provider: selects provider (evidence: `workspaces/js-x-ray-ai/src/AiAstAnalyzer.ts`)
- Google provider → Review prompt: builds prompt (evidence: `workspaces/js-x-ray-ai/src/providers/GoogleProvider.ts`)
- OpenAI provider → Review prompt: builds prompt (evidence: `workspaces/js-x-ray-ai/src/providers/OpenAiProvider.ts`)
- Google provider → LLM service: requests completion (evidence: `workspaces/js-x-ray-ai/src/providers/GoogleProvider.ts`)
- OpenAI provider → LLM service: requests completion
