# jscraik/diagram-cli architecture

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

- Interactive diagram: https://gitdiagram.com/jscraik/diagram-cli
- Repository: https://github.com/jscraik/diagram-cli

## Overview

Archscope is a Node.js CLI that analyzes a repository and turns the results into architecture evidence for human review and AI-agent handoff. Its central workflow is scan/agent-pr: analyze the target repository, optionally add pull-request impact evidence, then write a manifest-indexed evidence pack. Other documented branches cover diagram generation (including schema-backed ERDs), policy validation, changed-file analysis, dependency explanation, and PR risk reporting. Paths reflect the supplied tree; several command-to-module details are based on README descriptions because those command implementations were not sampled.

Main entry points: [`src/commands/scan.js`](https://github.com/jscraik/diagram-cli/blob/main/src/commands/scan.js) (Scan workflow), [`src/diagram.js`](https://github.com/jscraik/diagram-cli/blob/main/src/diagram.js) (CLI entry point), [`src/commands/generate.js`](https://github.com/jscraik/diagram-cli/blob/main/src/commands/generate.js) (Generate command), [`src/analyzers/index.js`](https://github.com/jscraik/diagram-cli/blob/main/src/analyzers/index.js) (Analyzer registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI workflows"]
  node_cli["CLI entry point<br/>[diagram.js]"]
  node_scan["Scan workflow<br/>[scan.js]"]
  node_agentpr["Agent PR workflow<br/>[agent-pr.js]"]
  node_analyze_cmd["Analyze command<br/>[analyze.js]"]
  node_generate_cmd["Generate command<br/>[generate.js]"]
  node_validate_cmd["Validate command<br/>[validate.js]"]
  node_workflow_pr["PR workflow<br/>[pr-command.js]"]
end

subgraph group_analysis["Repository analysis"]
  node_config["Scan configuration<br/>[diagramrc.js]"]
  node_analyzers["Analyzer registry<br/>[index.js]"]
  node_default_analyzer["Default analyzer"]
  node_core["Analysis engine"]
  node_ir["Architecture IR<br/>[architecture-ir.js]"]
  node_erd["Schema extraction<br/>[erd-extractor.js]"]
end

subgraph group_evidence["Evidence artifacts"]
  node_manifest["Evidence manifest"]
  node_brief["Architecture brief<br/>[brief.js]"]
  node_agent_context["Agent handoff<br/>[agent-context.js]"]
  node_context_pack["Context pack"]
end

subgraph group_outputs["Diagrams and reports"]
  node_diagrams["Mermaid diagrams"]
  node_html_report["HTML report<br/>[report-html.js]"]
  node_formatters["Result formatters<br/>[index.js]"]
end

subgraph group_pr["Pull request impact"]
  node_primpact["Impact and risk<br/>[pr-impact.js]"]
end

node_user(("Engineer or agent"))
node_repo(("Target repository"))

node_user -->|"runs command"| node_cli
node_cli -->|"dispatches"| node_scan
node_cli -->|"dispatches"| node_agentpr
node_cli -->|"dispatches"| node_analyze_cmd
node_cli -->|"dispatches"| node_generate_cmd
node_cli -->|"dispatches"| node_validate_cmd
node_cli -->|"dispatches"| node_workflow_pr
node_repo -->|"provides source"| node_scan
node_scan -->|"resolves defaults"| node_config
node_scan -->|"runs analysis"| node_analyzers
node_analyze_cmd -->|"runs analysis"| node_analyzers
node_generate_cmd -->|"runs analysis"| node_analyzers
node_analyzers -->|"selects analyzer"| node_default_analyzer
node_default_analyzer -->|"analyzes repository"| node_core
node_core -->|"builds representation"| node_ir
node_generate_cmd -->|"supports ERD output"| node_erd
node_scan -->|"indexes artifacts"| node_manifest
node_scan -->|"writes brief"| node_brief
node_scan -->|"writes handoff"| node_agent_context
node_scan -->|"generates evidence"| node_diagrams
node_agentpr -->|"delegates scan"| node_scan
node_agentpr -->|"adds PR evidence"| node_primpact
node_workflow_pr -->|"computes impact"| node_primpact
node_primpact -->|"compares Git refs"| node_repo
node_agent_context -->|"reads artifact status"| node_manifest
node_context_pack -->|"uses artifact index"| node_manifest
node_generate_cmd -->|"generates diagrams"| node_diagrams
node_validate_cmd -->|"formats results"| node_formatters
node_workflow_pr -->|"writes impact report"| node_html_report
node_scan -->|"writes human report"| node_html_report
node_scan -->|"formats machine output"| node_formatters

click node_cli "https://github.com/jscraik/diagram-cli/blob/main/src/diagram.js"
click node_scan "https://github.com/jscraik/diagram-cli/blob/main/src/commands/scan.js"
click node_agentpr "https://github.com/jscraik/diagram-cli/blob/main/src/commands/agent-pr.js"
click node_analyze_cmd "https://github.com/jscraik/diagram-cli/blob/main/src/commands/analyze.js"
click node_generate_cmd "https://github.com/jscraik/diagram-cli/blob/main/src/commands/generate.js"
click node_validate_cmd "https://github.com/jscraik/diagram-cli/blob/main/src/commands/validate.js"
click node_workflow_pr "https://github.com/jscraik/diagram-cli/blob/main/src/workflow/pr-command.js"
click node_config "https://github.com/jscraik/diagram-cli/blob/main/src/config/diagramrc.js"
click node_analyzers "https://github.com/jscraik/diagram-cli/blob/main/src/analyzers/index.js"
click node_default_analyzer "https://github.com/jscraik/diagram-cli/blob/main/src/analyzers/default-analyzer.js"
click node_core "https://github.com/jscraik/diagram-cli/blob/main/src/core/analysis-generation.js"
click node_ir "https://github.com/jscraik/diagram-cli/blob/main/src/ir/architecture-ir.js"
click node_erd "https://github.com/jscraik/diagram-cli/blob/main/src/schema/erd-extractor.js"
click node_primpact "https://github.com/jscraik/diagram-cli/blob/main/src/workflow/pr-impact.js"
click node_manifest "https://github.com/jscraik/diagram-cli/blob/main/src/artifacts/evidence-manifest.js"
click node_brief "https://github.com/jscraik/diagram-cli/blob/main/src/artifacts/brief.js"
click node_agent_context "https://github.com/jscraik/diagram-cli/blob/main/src/artifacts/agent-context.js"
click node_context_pack "https://github.com/jscraik/diagram-cli/blob/main/src/context/build-context-pack.js"
click node_diagrams "https://github.com/jscraik/diagram-cli/blob/main/src/core/analysis-generation-diagrams.js"
click node_html_report "https://github.com/jscraik/diagram-cli/blob/main/src/renderers/report-html.js"
click node_formatters "https://github.com/jscraik/diagram-cli/blob/main/src/formatters/index.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_cli,node_scan,node_agentpr,node_analyze_cmd,node_generate_cmd,node_validate_cmd,node_workflow_pr toneBlue
class node_config,node_analyzers,node_default_analyzer,node_core,node_ir,node_erd toneAmber
class node_manifest,node_brief,node_agent_context,node_context_pack toneMint
class node_diagrams,node_html_report,node_formatters toneRose
class node_primpact,node_user,node_repo toneIndigo
```

## Components

### CLI workflows

- [CLI entry point](https://github.com/jscraik/diagram-cli/blob/main/src/diagram.js): `src/diagram.js`
- [Scan workflow](https://github.com/jscraik/diagram-cli/blob/main/src/commands/scan.js): `src/commands/scan.js`
- [Agent PR workflow](https://github.com/jscraik/diagram-cli/blob/main/src/commands/agent-pr.js): `src/commands/agent-pr.js`
- [Analyze command](https://github.com/jscraik/diagram-cli/blob/main/src/commands/analyze.js): `src/commands/analyze.js`
- [Generate command](https://github.com/jscraik/diagram-cli/blob/main/src/commands/generate.js): `src/commands/generate.js`
- [Validate command](https://github.com/jscraik/diagram-cli/blob/main/src/commands/validate.js): `src/commands/validate.js`
- [PR workflow](https://github.com/jscraik/diagram-cli/blob/main/src/workflow/pr-command.js): `src/workflow/pr-command.js`

### Repository analysis

- [Scan configuration](https://github.com/jscraik/diagram-cli/blob/main/src/config/diagramrc.js): `src/config/diagramrc.js`
- [Analyzer registry](https://github.com/jscraik/diagram-cli/blob/main/src/analyzers/index.js): `src/analyzers/index.js`
- [Default analyzer](https://github.com/jscraik/diagram-cli/blob/main/src/analyzers/default-analyzer.js): `src/analyzers/default-analyzer.js`
- [Analysis engine](https://github.com/jscraik/diagram-cli/blob/main/src/core/analysis-generation.js): `src/core/analysis-generation.js`
- [Architecture IR](https://github.com/jscraik/diagram-cli/blob/main/src/ir/architecture-ir.js): `src/ir/architecture-ir.js`
- [Schema extraction](https://github.com/jscraik/diagram-cli/blob/main/src/schema/erd-extractor.js): `src/schema/erd-extractor.js`

### Evidence artifacts

- [Evidence manifest](https://github.com/jscraik/diagram-cli/blob/main/src/artifacts/evidence-manifest.js): `src/artifacts/evidence-manifest.js`
- [Architecture brief](https://github.com/jscraik/diagram-cli/blob/main/src/artifacts/brief.js): `src/artifacts/brief.js`
- [Agent handoff](https://github.com/jscraik/diagram-cli/blob/main/src/artifacts/agent-context.js): `src/artifacts/agent-context.js`
- [Context pack](https://github.com/jscraik/diagram-cli/blob/main/src/context/build-context-pack.js): `src/context/build-context-pack.js`

### Diagrams and reports

- [Mermaid diagrams](https://github.com/jscraik/diagram-cli/blob/main/src/core/analysis-generation-diagrams.js): `src/core/analysis-generation-diagrams.js`
- [HTML report](https://github.com/jscraik/diagram-cli/blob/main/src/renderers/report-html.js): `src/renderers/report-html.js`
- [Result formatters](https://github.com/jscraik/diagram-cli/blob/main/src/formatters/index.js): `src/formatters/index.js`

### Pull request impact

- [Impact and risk](https://github.com/jscraik/diagram-cli/blob/main/src/workflow/pr-impact.js): `src/workflow/pr-impact.js`

### Other components

- **Engineer or agent**
- **Target repository**

## Connections

- Engineer or agent → CLI entry point: runs command
- CLI entry point → Scan workflow: dispatches
- CLI entry point → Agent PR workflow: dispatches
- CLI entry point → Analyze command: dispatches
- CLI entry point → Generate command: dispatches
- CLI entry point → Validate command: dispatches
- CLI entry point → PR workflow: dispatches
- Target repository → Scan workflow: provides source
- Scan workflow → Scan configuration: resolves defaults
- Scan workflow → Analyzer registry: runs analysis
- Analyze command → Analyzer registry: runs analysis
- Generate command → Analyzer registry: runs analysis
- Analyzer registry → Default analyzer: selects analyzer
- Default analyzer → Analysis engine: analyzes repository
- Analysis engine → Architecture IR: builds representation
- Generate command → Schema extraction: supports ERD output
- Scan workflow → Evidence manifest: indexes artifacts
- Scan workflow → Architecture brief: writes brief
- Scan workflow → Agent handoff: writes handoff
- Scan workflow → Mermaid diagrams: generates evidence
- Agent PR workflow → Scan workflow: delegates scan
- Agent PR workflow → Impact and risk: adds PR evidence
- PR workflow → Impact and risk: computes impact
- Impact and risk → Target repository: compares Git refs
- Agent handoff → Evidence manifest: reads artifact status
- Context pack → Evidence manifest: uses artifact index
- Generate command → Mermaid diagrams: generates diagrams
- Validate command → Result formatters: formats results
- PR workflow → HTML report: writes impact report
- Scan workflow → HTML report: writes human report
- Scan workflow → Result formatters: formats machine output
