# speakeasyjs/speakeasy architecture

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

- Interactive diagram: https://gitdiagram.com/speakeasyjs/speakeasy
- Repository: https://github.com/speakeasyjs/speakeasy

## Overview

Speakeasy is a small Node.js library for generating and verifying HOTP/TOTP one-time passcodes, plus generating secrets and authenticator-compatible otpauth URLs. The typical workflow is secret generation, URL creation for authenticator setup, then token generation or verification. The sampled source is incomplete, so internal links not established by the excerpts are omitted; QR rendering and secret persistence belong to the integrating application.

Main entry points: [`index.js`](https://github.com/speakeasyjs/speakeasy/blob/master/index.js) (Speakeasy exports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Library API"]
  node_entry["Speakeasy exports<br/>[index.js]"]
end

subgraph group_otp["Passcode Operations"]
  node_hotp["HOTP generation<br/>[index.js]"]
  node_hotpverify["HOTP verification<br/>[index.js]"]
  node_totp["TOTP generation<br/>[index.js]"]
  node_totpverify["TOTP verification<br/>[index.js]"]
end

subgraph group_setup["Authenticator Setup"]
  node_secret["Secret generation<br/>[index.js]"]
  node_ascii["ASCII key generation<br/>[index.js]"]
  node_otpurl["otpauth URL<br/>[index.js]"]
end

node_consumer(("Integrating application"))
node_base32["base32.js"]
node_crypto["Node crypto"]
node_authapp(("Authenticator app"))

node_consumer -->|"calls"| node_entry
node_entry -->|"exposes"| node_secret
node_entry -->|"exposes"| node_hotp
node_entry -->|"exposes"| node_hotpverify
node_entry -->|"exposes"| node_totp
node_entry -->|"exposes"| node_totpverify
node_entry -->|"exposes"| node_otpurl
node_secret -->|"calls"| node_ascii
node_secret -->|"encodes"| node_base32
node_otpurl -.->|"provides setup URL"| node_authapp
node_consumer -.->|"displays QR"| node_authapp
node_entry -->|"imports"| node_base32
node_entry -->|"imports"| node_crypto

click node_entry "https://github.com/speakeasyjs/speakeasy/blob/master/index.js"
click node_secret "https://github.com/speakeasyjs/speakeasy/blob/master/index.js"
click node_ascii "https://github.com/speakeasyjs/speakeasy/blob/master/index.js"
click node_otpurl "https://github.com/speakeasyjs/speakeasy/blob/master/index.js"
click node_hotp "https://github.com/speakeasyjs/speakeasy/blob/master/index.js"
click node_hotpverify "https://github.com/speakeasyjs/speakeasy/blob/master/index.js"
click node_totp "https://github.com/speakeasyjs/speakeasy/blob/master/index.js"
click node_totpverify "https://github.com/speakeasyjs/speakeasy/blob/master/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_entry toneBlue
class node_hotp,node_hotpverify,node_totp,node_totpverify toneAmber
class node_secret,node_ascii,node_otpurl toneMint
class node_consumer,node_base32,node_crypto,node_authapp toneIndigo
```

## Components

### Library API

- [Speakeasy exports](https://github.com/speakeasyjs/speakeasy/blob/master/index.js): `index.js`

### Passcode Operations

- [HOTP generation](https://github.com/speakeasyjs/speakeasy/blob/master/index.js): `index.js`
- [HOTP verification](https://github.com/speakeasyjs/speakeasy/blob/master/index.js): `index.js`
- [TOTP generation](https://github.com/speakeasyjs/speakeasy/blob/master/index.js): `index.js`
- [TOTP verification](https://github.com/speakeasyjs/speakeasy/blob/master/index.js): `index.js`

### Authenticator Setup

- [Secret generation](https://github.com/speakeasyjs/speakeasy/blob/master/index.js): `index.js`
- [ASCII key generation](https://github.com/speakeasyjs/speakeasy/blob/master/index.js): `index.js`
- [otpauth URL](https://github.com/speakeasyjs/speakeasy/blob/master/index.js): `index.js`

### Other components

- **Integrating application**
- **base32.js**
- **Node crypto**
- **Authenticator app**

## Connections

- Integrating application → Speakeasy exports: calls
- Speakeasy exports → Secret generation: exposes
- Speakeasy exports → HOTP generation: exposes
- Speakeasy exports → HOTP verification: exposes
- Speakeasy exports → TOTP generation: exposes
- Speakeasy exports → TOTP verification: exposes
- Speakeasy exports → otpauth URL: exposes
- Secret generation → ASCII key generation: calls
- Secret generation → base32.js: encodes
- otpauth URL → Authenticator app: provides setup URL
- Integrating application → Authenticator app: displays QR
- Speakeasy exports → base32.js: imports
- Speakeasy exports → Node crypto: imports
