# amarjaleelbanbhan/veripatch architecture

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

- Interactive diagram: https://gitdiagram.com/amarjaleelbanbhan/veripatch
- Repository: https://github.com/amarjaleelbanbhan/veripatch

## Overview

VeriPatch is a CLI for npm vulnerability scanning and evidence-backed remediation. Its main workflow parses a dependency lockfile, retrieves advisories, ranks findings, verifies a candidate fix in an isolated Docker sandbox, independently rescans, runs build and tests, and reports evidence. The graph also includes documented baseline, cache, diagnostics, and update capabilities. Some command and adapter internals were not sampled, so their relationships are shown only where the README or excerpts support them.

Main entry points: [`src/services/scan.ts`](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/services/scan.ts) (Scan service), [`src/cli/commands`](https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/cli/commands) (Other commands), [`src/adapters/sandbox/index.ts`](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/sandbox/index.ts) (Docker sandbox), [`src/cli/index.ts`](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/index.ts) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_cli["CLI entry<br/>[index.ts]"]
  node_scan_command["Scan command<br/>[scan.ts]"]
  node_verify_command["Verify command<br/>[verify.ts]"]
  node_other_commands["Other commands"]
  node_doctor["Environment diagnostics<br/>[doctor.ts]"]
  node_update["Apply verified fix<br/>[update.ts]"]
end

subgraph group_scan["Scan"]
  node_scan_service["Scan service<br/>[scan.ts]"]
  node_lockfile["Lockfile parsers"]
  node_osv_source["OSV advisory source<br/>[index.ts]"]
  node_osv_client["OSV HTTP client<br/>[client.ts]"]
end

subgraph group_verify["Verification"]
  node_verify_service["Verification service<br/>[verify.ts]"]
  node_sandbox["Docker sandbox<br/>[index.ts]"]
  node_docker_runtime["Docker runtime<br/>[docker.ts]"]
  node_sandbox_steps["Remediation steps"]
  node_rescan_step["Independent rescan<br/>[rescan.ts]"]
end

subgraph group_evidence["Evidence"]
  node_report_service["Report service<br/>[report.ts]"]
  node_report_formats["Report formats"]
  node_baseline_service["Baseline service<br/>[baseline.ts]"]
  node_cache[("Advisory cache<br/>[db.ts]")]
end

subgraph group_core["Core domain"]
  node_rules["Matching and ranking"]
  node_domain_models["Scan and fix models"]
end

node_developer(("Developer"))
node_osv{{"OSV.dev"}}
node_docker{{"Docker daemon"}}

node_developer -->|"runs"| node_cli
node_cli -->|"dispatches"| node_scan_command
node_cli -->|"dispatches"| node_verify_command
node_cli -->|"dispatches"| node_other_commands
node_scan_command -.->|"runs scan"| node_scan_service
node_verify_command -->|"runs scan"| node_scan_service
node_scan_service -->|"parses dependencies"| node_lockfile
node_scan_service -->|"fetches advisories"| node_osv_source
node_scan_service -->|"matches and ranks"| node_rules
node_scan_service -->|"produces scan output"| node_domain_models
node_osv_source -->|"queries"| node_osv_client
node_osv_client -->|"requests advisories"| node_osv
node_verify_command -->|"verifies candidate"| node_verify_service
node_verify_service -.->|"runs verification"| node_sandbox
node_sandbox -->|"uses runtime"| node_docker_runtime
node_docker_runtime -.->|"controls container"| node_docker
node_sandbox -->|"runs steps"| node_sandbox_steps
node_sandbox -->|"rescans tree"| node_rescan_step
node_rescan_step -->|"parses tree"| node_lockfile
node_rescan_step -->|"checks advisories"| node_osv_source
node_sandbox -->|"returns step results"| node_domain_models
node_other_commands -.->|"renders evidence"| node_report_service
node_report_service -.->|"writes reports"| node_report_formats
node_other_commands -->|"manages baseline"| node_baseline_service
node_osv_source -->|"caches advisories"| node_cache
node_other_commands -->|"checks environment"| node_doctor
node_other_commands -->|"applies remediation"| node_update
node_update -->|"detects lockfile"| node_lockfile

click node_cli "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/index.ts"
click node_scan_command "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/commands/scan.ts"
click node_verify_command "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/commands/verify.ts"
click node_other_commands "https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/cli/commands"
click node_scan_service "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/services/scan.ts"
click node_lockfile "https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/adapters/lockfile"
click node_osv_source "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/osv/index.ts"
click node_osv_client "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/osv/client.ts"
click node_rules "https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/core/rules"
click node_domain_models "https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/core/models"
click node_verify_service "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/services/verify.ts"
click node_sandbox "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/sandbox/index.ts"
click node_docker_runtime "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/sandbox/docker.ts"
click node_sandbox_steps "https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/adapters/sandbox/steps"
click node_rescan_step "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/sandbox/steps/rescan.ts"
click node_report_service "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/services/report.ts"
click node_report_formats "https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/adapters/report"
click node_baseline_service "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/services/baseline.ts"
click node_cache "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/cache/db.ts"
click node_doctor "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/commands/doctor.ts"
click node_update "https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/commands/update.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_cli,node_scan_command,node_verify_command,node_other_commands,node_doctor,node_update toneBlue
class node_scan_service,node_lockfile,node_osv_source,node_osv_client toneAmber
class node_verify_service,node_sandbox,node_docker_runtime,node_sandbox_steps,node_rescan_step toneMint
class node_report_service,node_report_formats,node_baseline_service,node_cache toneRose
class node_rules,node_domain_models,node_developer,node_osv,node_docker toneIndigo
```

## Components

### CLI

- [CLI entry](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/index.ts): `src/cli/index.ts`
- [Scan command](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/commands/scan.ts): `src/cli/commands/scan.ts`
- [Verify command](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/commands/verify.ts): `src/cli/commands/verify.ts`
- [Other commands](https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/cli/commands): `src/cli/commands`
- [Environment diagnostics](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/commands/doctor.ts): `src/cli/commands/doctor.ts`
- [Apply verified fix](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/cli/commands/update.ts): `src/cli/commands/update.ts`

### Scan

- [Scan service](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/services/scan.ts): `src/services/scan.ts`
- [Lockfile parsers](https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/adapters/lockfile): `src/adapters/lockfile`
- [OSV advisory source](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/osv/index.ts): `src/adapters/osv/index.ts`
- [OSV HTTP client](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/osv/client.ts): `src/adapters/osv/client.ts`

### Verification

- [Verification service](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/services/verify.ts): `src/services/verify.ts`
- [Docker sandbox](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/sandbox/index.ts): `src/adapters/sandbox/index.ts`
- [Docker runtime](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/sandbox/docker.ts): `src/adapters/sandbox/docker.ts`
- [Remediation steps](https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/adapters/sandbox/steps): `src/adapters/sandbox/steps`
- [Independent rescan](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/sandbox/steps/rescan.ts): `src/adapters/sandbox/steps/rescan.ts`

### Evidence

- [Report service](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/services/report.ts): `src/services/report.ts`
- [Report formats](https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/adapters/report): `src/adapters/report`
- [Baseline service](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/services/baseline.ts): `src/services/baseline.ts`
- [Advisory cache](https://github.com/amarjaleelbanbhan/veripatch/blob/main/src/adapters/cache/db.ts): `src/adapters/cache/db.ts`

### Core domain

- [Matching and ranking](https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/core/rules): `src/core/rules`
- [Scan and fix models](https://github.com/amarjaleelbanbhan/veripatch/tree/main/src/core/models): `src/core/models`

### Other components

- **Developer**
- **OSV.dev**
- **Docker daemon**

## Connections

- Developer → CLI entry: runs (evidence: `README.md`)
- CLI entry → Scan command: dispatches (evidence: `src/cli/index.ts`)
- CLI entry → Verify command: dispatches (evidence: `src/cli/index.ts`)
- CLI entry → Other commands: dispatches (evidence: `src/cli/index.ts`)
- Scan command → Scan service: runs scan
- Verify command → Scan service: runs scan (evidence: `src/cli/commands/verify.ts`)
- Scan service → Lockfile parsers: parses dependencies (evidence: `src/services/scan.ts`)
- Scan service → OSV advisory source: fetches advisories (evidence: `src/services/scan.ts`)
- Scan service → Matching and ranking: matches and ranks (evidence: `src/services/scan.ts`)
- Scan service → Scan and fix models: produces scan output (evidence: `src/services/scan.ts`)
- OSV advisory source → OSV HTTP client: queries (evidence: `src/adapters/osv/index.ts`)
- OSV HTTP client → OSV.dev: requests advisories (evidence: `src/adapters/osv/client.ts`)
- Verify command → Verification service: verifies candidate (evidence: `src/cli/commands/verify.ts`)
- Verification service → Docker sandbox: runs verification
- Docker sandbox → Docker runtime: uses runtime (evidence: `src/adapters/sandbox/index.ts`)
- Docker runtime → Docker daemon: controls container
- Docker sandbox → Remediation steps: runs steps (evidence: `src/adapters/sandbox/index.ts`)
- Docker sandbox → Independent rescan: rescans tree (evidence: `src/adapters/sandbox/index.ts`)
- Independent rescan → Lockfile parsers: parses tree
- Independent rescan → OSV advisory source: checks advisories
- Docker sandbox → Scan and fix models: returns step results (evidence: `src/adapters/sandbox/index.ts`)
- Other commands → Report service: renders evidence
- Report service → Report formats: writes reports
- Other commands → Baseline service: manages baseline (evidence: `src/cli/commands/baseline.ts`)
- OSV advisory source → Advisory cache: caches advisories (evidence: `src/adapters/osv/index.ts`)
- Other commands → Environment diagnostics: checks environment (evidence: `src/cli/index.ts`)
- Other commands → Apply verified fix: applies remediation (evidence: `src/cli/index.ts`)
- Apply verified fix → Lockfile parsers: detects lockfile (evidence: `src/cli/commands/update.ts`)
