# schniz/fnm architecture

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

- Interactive diagram: https://gitdiagram.com/schniz/fnm
- Repository: https://github.com/schniz/fnm

## Overview

fnm is a cross-platform Node.js version manager. Users invoke its CLI to install versions from Node distributions, select versions directly or from `.node-version`/`.nvmrc` files, and expose the selected installation through shell initialization; commands also manage aliases, defaults, listings, and removal. The graph separates command workflows, version resolution, installation/storage, and shell integration. Edges are limited to relationships visible in excerpts, the source index, or README; several unsampled command implementations are represented at their exact directory paths.

Main entry points: [`src/commands/install.rs`](https://github.com/schniz/fnm/blob/master/src/commands/install.rs) (Install version), [`src/commands/use.rs`](https://github.com/schniz/fnm/blob/master/src/commands/use.rs) (Select version), [`src/user_version_reader.rs`](https://github.com/schniz/fnm/blob/master/src/user_version_reader.rs) (Input reader), [`src/version_files.rs`](https://github.com/schniz/fnm/blob/master/src/version_files.rs) (Version file lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commands["CLI commands"]
  node_cli["CLI dispatch<br/>[cli.rs]"]
  node_command["Command interface<br/>[command.rs]"]
  node_use_cmd["Select version<br/>[use.rs]"]
  node_exec_cmd["Run with version<br/>[exec.rs]"]
  node_install_cmd["Install version<br/>[install.rs]"]
  node_other_cmds["Other commands"]
end

subgraph group_resolve["Version resolution"]
  node_config["Configuration<br/>[config.rs]"]
  node_version["Version model<br/>[version.rs]"]
  node_user_version["Version input<br/>[user_version.rs]"]
  node_version_reader["Input reader"]
  node_version_files["Version file lookup<br/>[version_files.rs]"]
  node_choose["Version selection"]
end

subgraph group_install["Install and storage"]
  node_remote_index["Remote version index"]
  node_downloader["Node downloader<br/>[downloader.rs]"]
  node_archive["Archive extraction<br/>[mod.rs]"]
  node_http["HTTP client<br/>[http.rs]"]
  node_installed["Installed versions"]
  node_aliases[("Alias storage<br/>[alias.rs]")]
  node_filesystem["Filesystem operations<br/>[fs.rs]"]
end

subgraph group_shell["Shell integration"]
  node_env_cmd["Shell environment<br/>[env.rs]"]
  node_shells["Shell adapters"]
end

node_user(("Terminal user"))

node_user -->|"invokes"| node_cli
node_cli -->|"dispatches"| node_command
node_use_cmd -->|"reads input"| node_version_reader
node_use_cmd -->|"resolves files"| node_version_files
node_use_cmd -->|"checks versions"| node_installed
node_use_cmd -->|"installs missing"| node_install_cmd
node_exec_cmd -->|"selects version"| node_choose
node_exec_cmd -->|"reads input"| node_version_reader
node_install_cmd -->|"resolves directory"| node_version_files
node_install_cmd -->|"lists releases"| node_remote_index
node_install_cmd -->|"installs distribution"| node_downloader
node_install_cmd -->|"creates aliases"| node_aliases
node_downloader -->|"downloads archive"| node_http
node_downloader -->|"extracts archive"| node_archive
node_remote_index -->|"fetches index"| node_http
node_version_reader -->|"reads files"| node_version_files
node_version_reader -->|"parses version"| node_user_version
node_version_files -->|"parses contents"| node_user_version
node_choose -->|"matches input"| node_user_version
node_choose -->|"checks installed"| node_installed
node_env_cmd -->|"renders environment"| node_shells
node_user -->|"requests setup"| node_env_cmd

click node_cli "https://github.com/schniz/fnm/blob/master/src/cli.rs"
click node_command "https://github.com/schniz/fnm/blob/master/src/commands/command.rs"
click node_use_cmd "https://github.com/schniz/fnm/blob/master/src/commands/use.rs"
click node_exec_cmd "https://github.com/schniz/fnm/blob/master/src/commands/exec.rs"
click node_install_cmd "https://github.com/schniz/fnm/blob/master/src/commands/install.rs"
click node_other_cmds "https://github.com/schniz/fnm/tree/master/src/commands"
click node_config "https://github.com/schniz/fnm/blob/master/src/config.rs"
click node_version "https://github.com/schniz/fnm/blob/master/src/version.rs"
click node_user_version "https://github.com/schniz/fnm/blob/master/src/user_version.rs"
click node_version_reader "https://github.com/schniz/fnm/blob/master/src/user_version_reader.rs"
click node_version_files "https://github.com/schniz/fnm/blob/master/src/version_files.rs"
click node_choose "https://github.com/schniz/fnm/blob/master/src/choose_version_for_user_input.rs"
click node_remote_index "https://github.com/schniz/fnm/blob/master/src/remote_node_index.rs"
click node_downloader "https://github.com/schniz/fnm/blob/master/src/downloader.rs"
click node_archive "https://github.com/schniz/fnm/blob/master/src/archive/mod.rs"
click node_http "https://github.com/schniz/fnm/blob/master/src/http.rs"
click node_installed "https://github.com/schniz/fnm/blob/master/src/installed_versions.rs"
click node_aliases "https://github.com/schniz/fnm/blob/master/src/alias.rs"
click node_filesystem "https://github.com/schniz/fnm/blob/master/src/fs.rs"
click node_env_cmd "https://github.com/schniz/fnm/blob/master/src/commands/env.rs"
click node_shells "https://github.com/schniz/fnm/tree/master/src/shell"

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_command,node_use_cmd,node_exec_cmd,node_install_cmd,node_other_cmds,node_user toneBlue
class node_config,node_version,node_user_version,node_version_reader,node_version_files,node_choose toneAmber
class node_remote_index,node_downloader,node_archive,node_http,node_installed,node_aliases,node_filesystem toneMint
class node_env_cmd,node_shells toneRose
```

## Components

### CLI commands

- [CLI dispatch](https://github.com/schniz/fnm/blob/master/src/cli.rs): `src/cli.rs`
- [Command interface](https://github.com/schniz/fnm/blob/master/src/commands/command.rs): `src/commands/command.rs`
- [Select version](https://github.com/schniz/fnm/blob/master/src/commands/use.rs): `src/commands/use.rs`
- [Run with version](https://github.com/schniz/fnm/blob/master/src/commands/exec.rs): `src/commands/exec.rs`
- [Install version](https://github.com/schniz/fnm/blob/master/src/commands/install.rs): `src/commands/install.rs`
- [Other commands](https://github.com/schniz/fnm/tree/master/src/commands): `src/commands`

### Version resolution

- [Configuration](https://github.com/schniz/fnm/blob/master/src/config.rs): `src/config.rs`
- [Version model](https://github.com/schniz/fnm/blob/master/src/version.rs): `src/version.rs`
- [Version input](https://github.com/schniz/fnm/blob/master/src/user_version.rs): `src/user_version.rs`
- [Input reader](https://github.com/schniz/fnm/blob/master/src/user_version_reader.rs): `src/user_version_reader.rs`
- [Version file lookup](https://github.com/schniz/fnm/blob/master/src/version_files.rs): `src/version_files.rs`
- [Version selection](https://github.com/schniz/fnm/blob/master/src/choose_version_for_user_input.rs): `src/choose_version_for_user_input.rs`

### Install and storage

- [Remote version index](https://github.com/schniz/fnm/blob/master/src/remote_node_index.rs): `src/remote_node_index.rs`
- [Node downloader](https://github.com/schniz/fnm/blob/master/src/downloader.rs): `src/downloader.rs`
- [Archive extraction](https://github.com/schniz/fnm/blob/master/src/archive/mod.rs): `src/archive/mod.rs`
- [HTTP client](https://github.com/schniz/fnm/blob/master/src/http.rs): `src/http.rs`
- [Installed versions](https://github.com/schniz/fnm/blob/master/src/installed_versions.rs): `src/installed_versions.rs`
- [Alias storage](https://github.com/schniz/fnm/blob/master/src/alias.rs): `src/alias.rs`
- [Filesystem operations](https://github.com/schniz/fnm/blob/master/src/fs.rs): `src/fs.rs`

### Shell integration

- [Shell environment](https://github.com/schniz/fnm/blob/master/src/commands/env.rs): `src/commands/env.rs`
- [Shell adapters](https://github.com/schniz/fnm/tree/master/src/shell): `src/shell`

### Other components

- **Terminal user**

## Connections

- Terminal user → CLI dispatch: invokes
- CLI dispatch → Command interface: dispatches
- Select version → Input reader: reads input (evidence: `src/commands/use.rs`)
- Select version → Version file lookup: resolves files (evidence: `src/commands/use.rs`)
- Select version → Installed versions: checks versions (evidence: `src/commands/use.rs`)
- Select version → Install version: installs missing (evidence: `src/commands/use.rs`)
- Run with version → Version selection: selects version (evidence: `src/commands/exec.rs`)
- Run with version → Input reader: reads input (evidence: `src/commands/exec.rs`)
- Install version → Version file lookup: resolves directory (evidence: `src/commands/install.rs`)
- Install version → Remote version index: lists releases (evidence: `src/commands/install.rs`)
- Install version → Node downloader: installs distribution (evidence: `src/commands/install.rs`)
- Install version → Alias storage: creates aliases (evidence: `src/commands/install.rs`)
- Node downloader → HTTP client: downloads archive (evidence: `src/downloader.rs`)
- Node downloader → Archive extraction: extracts archive (evidence: `src/downloader.rs`)
- Remote version index → HTTP client: fetches index (evidence: `src/remote_node_index.rs`)
- Input reader → Version file lookup: reads files (evidence: `src/user_version_reader.rs`)
- Input reader → Version input: parses version (evidence: `src/user_version_reader.rs`)
- Version file lookup → Version input: parses contents (evidence: `src/version_files.rs`)
- Version selection → Version input: matches input (evidence: `src/choose_version_for_user_input.rs`)
- Version selection → Installed versions: checks installed (evidence: `src/choose_version_for_user_input.rs`)
- Shell environment → Shell adapters: renders environment (evidence: `src/commands/env.rs`)
- Terminal user → Shell environment: requests setup
