# nnxi/nodejs-api-docgen architecture

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

- Interactive diagram: https://gitdiagram.com/nnxi/nodejs-api-docgen
- Repository: https://github.com/nnxi/nodejs-api-docgen

## Overview

nodejs-api-docgen is a command-line tool that turns Express route comments into shareable HTML API documentation. Its workflow reads a selected application or router file, parses JavaScript into an AST, extracts route definitions and their documentation tags (including mounted subrouters), then generates and opens an HTML document. The README also documents strict tag filtering and the generated document’s use as a team-facing API reference. The core workflow is evidenced in the CLI and sampled modules; the output’s later serving is documented in the README.

Main entry points: [`index.js`](https://github.com/nnxi/nodejs-api-docgen/blob/main/index.js) (CLI entry), [`src/extractor.js`](https://github.com/nnxi/nodejs-api-docgen/blob/main/src/extractor.js) (Route extractor), [`src/generator.js`](https://github.com/nnxi/nodejs-api-docgen/blob/main/src/generator.js) (HTML generator), [`src/parser.js`](https://github.com/nnxi/nodejs-api-docgen/blob/main/src/parser.js) (AST parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI workflow"]
  node_cli["CLI entry<br/>[index.js]"]
end

subgraph group_analysis["Route analysis"]
  node_parser["AST parser<br/>[parser.js]"]
  node_extractor["Route extractor<br/>[extractor.js]"]
end

subgraph group_output["Documentation output"]
  node_generator["HTML generator<br/>[generator.js]"]
  node_html["Generated API docs<br/>[api-docs.html]"]
end

node_developer(("Developer"))
node_routefile["Express source"]
node_team(("Team reader"))
node_browser(("Local browser"))

node_developer -->|"runs"| node_cli
node_cli -->|"reads"| node_routefile
node_cli -->|"parses with"| node_parser
node_cli -->|"extracts via"| node_extractor
node_extractor -->|"parses subrouters"| node_parser
node_extractor -->|"recurses into"| node_extractor
node_cli -->|"generates with"| node_generator
node_generator -->|"writes"| node_html
node_generator -->|"opens file in"| node_browser
node_team -->|"views"| node_html

click node_cli "https://github.com/nnxi/nodejs-api-docgen/blob/main/index.js"
click node_parser "https://github.com/nnxi/nodejs-api-docgen/blob/main/src/parser.js"
click node_extractor "https://github.com/nnxi/nodejs-api-docgen/blob/main/src/extractor.js"
click node_generator "https://github.com/nnxi/nodejs-api-docgen/blob/main/src/generator.js"
click node_html "https://github.com/nnxi/nodejs-api-docgen/blob/main/api-docs.html"

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_browser toneBlue
class node_parser,node_extractor toneAmber
class node_generator,node_html toneMint
class node_developer,node_routefile,node_team toneIndigo
```

## Components

### CLI workflow

- [CLI entry](https://github.com/nnxi/nodejs-api-docgen/blob/main/index.js): `index.js`

### Route analysis

- [AST parser](https://github.com/nnxi/nodejs-api-docgen/blob/main/src/parser.js): `src/parser.js`
- [Route extractor](https://github.com/nnxi/nodejs-api-docgen/blob/main/src/extractor.js): `src/extractor.js`

### Documentation output

- [HTML generator](https://github.com/nnxi/nodejs-api-docgen/blob/main/src/generator.js): `src/generator.js`
- [Generated API docs](https://github.com/nnxi/nodejs-api-docgen/blob/main/api-docs.html): `api-docs.html`

### Other components

- **Developer**
- **Express source**
- **Team reader**
- **Local browser**

## Connections

- Developer → CLI entry: runs (evidence: `README.md`)
- CLI entry → Express source: reads (evidence: `index.js`)
- CLI entry → AST parser: parses with (evidence: `index.js`)
- CLI entry → Route extractor: extracts via (evidence: `index.js`)
- Route extractor → AST parser: parses subrouters (evidence: `src/extractor.js`)
- Route extractor → Route extractor: recurses into (evidence: `src/extractor.js`)
- CLI entry → HTML generator: generates with (evidence: `index.js`)
- HTML generator → Generated API docs: writes (evidence: `src/generator.js`)
- HTML generator → Local browser: opens file in (evidence: `src/generator.js`)
- Team reader → Generated API docs: views (evidence: `README.md`)
