# tj/dox architecture

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

- Interactive diagram: https://gitdiagram.com/tj/dox
- Repository: https://github.com/tj/dox

## Overview

Dox turns JavaScript source comments into structured JSON, with a CLI for stdin/stdout and a programmatic API. Its principal workflow scans source for comments, associates comments with code context, parses JSDoc tags and types, and renders descriptions as Markdown; callers can then consume the structured result or request generated API Markdown. The graph reflects documented behavior and visible imports. The CLI implementation and portions of the parser are unsampled, so those links rely on the README rather than claims about unseen internals.

Main entry points: [`lib/dox.js`](https://github.com/tj/dox/blob/master/lib/dox.js) (Comment scanner), [`bin/dox`](https://github.com/tj/dox/blob/master/bin/dox) (Dox CLI), [`index.js`](https://github.com/tj/dox/blob/master/index.js) (Public API), [`lib/api.js`](https://github.com/tj/dox/blob/master/lib/api.js) (API Markdown)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["Dox CLI"]
  node_public_api["Public API<br/>[index.js]"]
end

subgraph group_parsing["Comment parsing"]
  node_scanner["Comment scanner<br/>[dox.js]"]
  node_context["Code context<br/>[dox.js]"]
  node_tag_parser["Tag parser<br/>[dox.js]"]
  node_type_parser["Type parser<br/>[dox.js]"]
  node_markdown["Markdown rendering<br/>[dox.js]"]
end

subgraph group_outputs["Output generation"]
  node_api_docs["API Markdown<br/>[api.js]"]
end

node_user(("Developer"))
node_markdown_it["markdown-it"]
node_jsdoctypeparser["jsdoctypeparser"]

node_user -->|"invokes"| node_cli
node_cli -->|"parses stdin"| node_scanner
node_user -->|"calls"| node_public_api
node_public_api -->|"exports parser"| node_scanner
node_scanner -.->|"identifies context"| node_context
node_scanner -.->|"parses tags"| node_tag_parser
node_tag_parser -.->|"parses types"| node_type_parser
node_type_parser -->|"uses"| node_jsdoctypeparser
node_scanner -.->|"renders descriptions"| node_markdown
node_markdown -->|"uses"| node_markdown_it
node_cli -->|"requests API Markdown"| node_api_docs
node_public_api -->|"exports generator"| node_api_docs

click node_cli "https://github.com/tj/dox/blob/master/bin/dox"
click node_public_api "https://github.com/tj/dox/blob/master/index.js"
click node_scanner "https://github.com/tj/dox/blob/master/lib/dox.js"
click node_context "https://github.com/tj/dox/blob/master/lib/dox.js"
click node_tag_parser "https://github.com/tj/dox/blob/master/lib/dox.js"
click node_type_parser "https://github.com/tj/dox/blob/master/lib/dox.js"
click node_markdown "https://github.com/tj/dox/blob/master/lib/dox.js"
click node_api_docs "https://github.com/tj/dox/blob/master/lib/api.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_public_api toneBlue
class node_scanner,node_context,node_tag_parser,node_type_parser,node_markdown toneAmber
class node_api_docs toneMint
class node_user,node_markdown_it,node_jsdoctypeparser toneIndigo
```

## Components

### Entry points

- [Dox CLI](https://github.com/tj/dox/blob/master/bin/dox): `bin/dox`
- [Public API](https://github.com/tj/dox/blob/master/index.js): `index.js`

### Comment parsing

- [Comment scanner](https://github.com/tj/dox/blob/master/lib/dox.js): `lib/dox.js`
- [Code context](https://github.com/tj/dox/blob/master/lib/dox.js): `lib/dox.js`
- [Tag parser](https://github.com/tj/dox/blob/master/lib/dox.js): `lib/dox.js`
- [Type parser](https://github.com/tj/dox/blob/master/lib/dox.js): `lib/dox.js`
- [Markdown rendering](https://github.com/tj/dox/blob/master/lib/dox.js): `lib/dox.js`

### Output generation

- [API Markdown](https://github.com/tj/dox/blob/master/lib/api.js): `lib/api.js`

### Other components

- **Developer**
- **markdown-it**
- **jsdoctypeparser**

## Connections

- Developer → Dox CLI: invokes (evidence: `Readme.md`)
- Dox CLI → Comment scanner: parses stdin (evidence: `Readme.md`)
- Developer → Public API: calls (evidence: `Readme.md`)
- Public API → Comment scanner: exports parser (evidence: `index.js`)
- Comment scanner → Code context: identifies context (evidence: `lib/dox.js`)
- Comment scanner → Tag parser: parses tags (evidence: `lib/dox.js`)
- Tag parser → Type parser: parses types (evidence: `lib/dox.js`)
- Type parser → jsdoctypeparser: uses (evidence: `lib/dox.js`)
- Comment scanner → Markdown rendering: renders descriptions (evidence: `lib/dox.js`)
- Markdown rendering → markdown-it: uses (evidence: `lib/dox.js`)
- Dox CLI → API Markdown: requests API Markdown (evidence: `Readme.md`)
- Public API → API Markdown: exports generator
