# sindresorhus/yocto-spinner architecture

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

- Interactive diagram: https://gitdiagram.com/sindresorhus/yocto-spinner
- Repository: https://github.com/sindresorhus/yocto-spinner
- Video tour (about a minute): https://gitdiagram.com/sindresorhus/yocto-spinner/video

## Overview

yocto-spinner is a small Node.js terminal-spinner library. A caller creates and starts a spinner; it selects interactive or non-interactive rendering, writes animated frames and text to a writable stream, and can stop with a final status symbol. The implementation also handles terminal redraw around concurrent writes and optionally cleans up on process signals. README documents customization and status methods; the graph focuses on runtime behavior in index.js. No separate source modules were sampled.

Main entry points: [`index.js`](https://github.com/sindresorhus/yocto-spinner/blob/main/index.js) (Spinner Instance)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Spinner API"]
  node_factory["Spinner Factory<br/>[index.js]"]
  node_instance["Spinner Instance<br/>[index.js]"]
end

subgraph group_render["Terminal Rendering"]
  node_color["Color Symbols<br/>[index.js]"]
  node_mode["Terminal Mode<br/>[index.js]"]
  node_frame["Frame Renderer<br/>[index.js]"]
  node_redraw["Stream Redraw Hook<br/>[index.js]"]
end

subgraph group_lifecycle["Lifecycle Handling"]
  node_signals["Signal Cleanup<br/>[index.js]"]
end

node_caller(("Application"))
node_terminal["Writable Terminal"]
node_process["Node Process"]

node_caller -->|"creates spinner"| node_factory
node_factory -->|"constructs"| node_instance
node_caller -->|"starts and controls"| node_instance
node_instance -->|"checks interactivity"| node_mode
node_instance -->|"renders frames"| node_frame
node_frame -->|"colors output"| node_color
node_frame -->|"writes output"| node_terminal
node_instance -->|"installs hook"| node_redraw
node_redraw -->|"intercepts writes"| node_terminal
node_instance -->|"registers listeners"| node_signals
node_signals -->|"handles signals"| node_process
node_instance -->|"uses defaults"| node_process

click node_factory "https://github.com/sindresorhus/yocto-spinner/blob/main/index.js"
click node_instance "https://github.com/sindresorhus/yocto-spinner/blob/main/index.js"
click node_color "https://github.com/sindresorhus/yocto-spinner/blob/main/index.js"
click node_mode "https://github.com/sindresorhus/yocto-spinner/blob/main/index.js"
click node_frame "https://github.com/sindresorhus/yocto-spinner/blob/main/index.js"
click node_redraw "https://github.com/sindresorhus/yocto-spinner/blob/main/index.js"
click node_signals "https://github.com/sindresorhus/yocto-spinner/blob/main/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_factory,node_instance toneBlue
class node_color,node_mode,node_frame,node_redraw toneAmber
class node_signals toneMint
class node_caller,node_terminal,node_process toneIndigo
```

## Components

### Spinner API

- [Spinner Factory](https://github.com/sindresorhus/yocto-spinner/blob/main/index.js): `index.js`
- [Spinner Instance](https://github.com/sindresorhus/yocto-spinner/blob/main/index.js): `index.js`

### Terminal Rendering

- [Color Symbols](https://github.com/sindresorhus/yocto-spinner/blob/main/index.js): `index.js`
- [Terminal Mode](https://github.com/sindresorhus/yocto-spinner/blob/main/index.js): `index.js`
- [Frame Renderer](https://github.com/sindresorhus/yocto-spinner/blob/main/index.js): `index.js`
- [Stream Redraw Hook](https://github.com/sindresorhus/yocto-spinner/blob/main/index.js): `index.js`

### Lifecycle Handling

- [Signal Cleanup](https://github.com/sindresorhus/yocto-spinner/blob/main/index.js): `index.js`

### Other components

- **Application**
- **Writable Terminal**
- **Node Process**

## Connections

- Application → Spinner Factory: creates spinner (evidence: `readme.md`)
- Spinner Factory → Spinner Instance: constructs (evidence: `index.js`)
- Application → Spinner Instance: starts and controls (evidence: `readme.md`)
- Spinner Instance → Terminal Mode: checks interactivity (evidence: `index.js`)
- Spinner Instance → Frame Renderer: renders frames (evidence: `index.js`)
- Frame Renderer → Color Symbols: colors output (evidence: `index.js`)
- Frame Renderer → Writable Terminal: writes output (evidence: `index.js`)
- Spinner Instance → Stream Redraw Hook: installs hook (evidence: `index.js`)
- Stream Redraw Hook → Writable Terminal: intercepts writes (evidence: `index.js`)
- Spinner Instance → Signal Cleanup: registers listeners (evidence: `index.js`)
- Signal Cleanup → Node Process: handles signals (evidence: `index.js`)
- Spinner Instance → Node Process: uses defaults (evidence: `index.js`)
