# kendroger/io-snapshot architecture

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

- Interactive diagram: https://gitdiagram.com/kendroger/io-snapshot
- Repository: https://github.com/kendroger/io-snapshot

## Overview

io-snapshot is a behavior-preservation tool for refactoring: it instruments exported functions, records real inputs and outputs through a local daemon, restores original files, then replays snapshots against refactored code and reports output drift. Its principal workflow is CLI record → instrumentation → application use and capture → stop/restore → CLI test and verification. The graph also shows the reusable recorder, configuration, and backup support. Source excerpts establish the main calls and data transfers; other README-described capabilities are included where implementation details were not shown.

Main entry points: [`bin/cli.js`](https://github.com/kendroger/io-snapshot/blob/main/bin/cli.js) (Command CLI), [`lib/transformer.js`](https://github.com/kendroger/io-snapshot/blob/main/lib/transformer.js) (Inject and restore), [`lib/daemon.js`](https://github.com/kendroger/io-snapshot/blob/main/lib/daemon.js) (Capture daemon), [`lib/verifier.js`](https://github.com/kendroger/io-snapshot/blob/main/lib/verifier.js) (Replay and diff)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["CLI workflow"]
  node_cli["Command CLI<br/>[cli.js]"]
  node_config["Config loading<br/>[config.js]"]
  node_logger["Logging<br/>[logger.js]"]
end

subgraph group_instrumentation["Instrumentation and backups"]
  node_transformer["Inject and restore<br/>[transformer.js]"]
  node_inline["Injected recorder<br/>[recorder-inline.js]"]
  node_paths["Session paths<br/>[paths.js]"]
  node_backups["Source backups"]
end

subgraph group_capture["Capture runtime"]
  node_recorder["Recorder API<br/>[recorder.js]"]
  node_daemon["Capture daemon<br/>[daemon.js]"]
  node_snapshots[("Snapshot log")]
end

subgraph group_verification["Snapshot verification"]
  node_verifier["Replay and diff<br/>[verifier.js]"]
end

node_user(("Developer"))
node_target["Application functions"]

node_user -->|"runs commands"| node_cli
node_cli -->|"injects or restores"| node_transformer
node_cli -->|"starts verification"| node_verifier
node_cli -->|"controls over HTTP"| node_daemon
node_cli -->|"loads settings"| node_config
node_cli -->|"reports status"| node_logger
node_daemon -->|"loads settings"| node_config
node_transformer -->|"embeds recorder"| node_inline
node_transformer -->|"gets backup paths"| node_paths
node_transformer -->|"writes and restores"| node_backups
node_paths -->|"resolves locations"| node_backups
node_transformer -->|"instruments files"| node_target
node_target -.->|"calls wrapped functions"| node_inline
node_inline -->|"posts telemetry"| node_daemon
node_recorder -->|"posts telemetry"| node_daemon
node_daemon -->|"appends telemetry"| node_snapshots
node_verifier -->|"reads recorded cases"| node_snapshots
node_verifier -->|"imports and replays"| node_target

click node_cli "https://github.com/kendroger/io-snapshot/blob/main/bin/cli.js"
click node_config "https://github.com/kendroger/io-snapshot/blob/main/lib/config.js"
click node_logger "https://github.com/kendroger/io-snapshot/blob/main/lib/logger.js"
click node_transformer "https://github.com/kendroger/io-snapshot/blob/main/lib/transformer.js"
click node_inline "https://github.com/kendroger/io-snapshot/blob/main/lib/recorder-inline.js"
click node_paths "https://github.com/kendroger/io-snapshot/blob/main/lib/paths.js"
click node_recorder "https://github.com/kendroger/io-snapshot/blob/main/lib/recorder.js"
click node_daemon "https://github.com/kendroger/io-snapshot/blob/main/lib/daemon.js"
click node_verifier "https://github.com/kendroger/io-snapshot/blob/main/lib/verifier.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_config,node_logger toneBlue
class node_transformer,node_inline,node_paths,node_backups toneAmber
class node_recorder,node_daemon,node_snapshots toneMint
class node_verifier toneRose
class node_user,node_target toneIndigo
```

## Components

### CLI workflow

- [Command CLI](https://github.com/kendroger/io-snapshot/blob/main/bin/cli.js): `bin/cli.js`
- [Config loading](https://github.com/kendroger/io-snapshot/blob/main/lib/config.js): `lib/config.js`
- [Logging](https://github.com/kendroger/io-snapshot/blob/main/lib/logger.js): `lib/logger.js`

### Instrumentation and backups

- [Inject and restore](https://github.com/kendroger/io-snapshot/blob/main/lib/transformer.js): `lib/transformer.js`
- [Injected recorder](https://github.com/kendroger/io-snapshot/blob/main/lib/recorder-inline.js): `lib/recorder-inline.js`
- [Session paths](https://github.com/kendroger/io-snapshot/blob/main/lib/paths.js): `lib/paths.js`
- **Source backups**

### Capture runtime

- [Recorder API](https://github.com/kendroger/io-snapshot/blob/main/lib/recorder.js): `lib/recorder.js`
- [Capture daemon](https://github.com/kendroger/io-snapshot/blob/main/lib/daemon.js): `lib/daemon.js`
- **Snapshot log**

### Snapshot verification

- [Replay and diff](https://github.com/kendroger/io-snapshot/blob/main/lib/verifier.js): `lib/verifier.js`

### Other components

- **Developer**
- **Application functions**

## Connections

- Developer → Command CLI: runs commands (evidence: `README.md`)
- Command CLI → Inject and restore: injects or restores (evidence: `bin/cli.js`)
- Command CLI → Replay and diff: starts verification (evidence: `bin/cli.js`)
- Command CLI → Capture daemon: controls over HTTP (evidence: `bin/cli.js`)
- Command CLI → Config loading: loads settings (evidence: `bin/cli.js`)
- Command CLI → Logging: reports status (evidence: `bin/cli.js`)
- Capture daemon → Config loading: loads settings (evidence: `lib/daemon.js`)
- Inject and restore → Injected recorder: embeds recorder (evidence: `lib/transformer.js`)
- Inject and restore → Session paths: gets backup paths (evidence: `lib/transformer.js`)
- Inject and restore → Source backups: writes and restores (evidence: `lib/transformer.js`)
- Session paths → Source backups: resolves locations (evidence: `lib/paths.js`)
- Inject and restore → Application functions: instruments files (evidence: `README.md`)
- Application functions → Injected recorder: calls wrapped functions
- Injected recorder → Capture daemon: posts telemetry (evidence: `lib/recorder-inline.js`)
- Recorder API → Capture daemon: posts telemetry (evidence: `lib/recorder.js`)
- Capture daemon → Snapshot log: appends telemetry (evidence: `lib/daemon.js`)
- Replay and diff → Snapshot log: reads recorded cases (evidence: `lib/verifier.js`)
- Replay and diff → Application functions: imports and replays (evidence: `lib/verifier.js`)
