# demike/tsuml2 architecture

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

- Interactive diagram: https://gitdiagram.com/demike/tsuml2
- Repository: https://github.com/demike/tsuml2

## Overview

TsUML2 is an offline TypeScript-to-UML diagram generator and library. The principal workflow takes a user’s source-file glob and options, parses TypeScript declarations (optionally deriving member associations), then emits SVG/nomnoml DSL and/or Mermaid DSL to requested files. The graph also shows the shared declaration model, diagnostics, and separate renderer templates. The parser and settings excerpts are incomplete; arrows are limited to calls visible in excerpts, SOURCE INDEX references, or README statements.

Main entry points: [`src/core/diagram-engine.ts`](https://github.com/demike/tsuml2/blob/master/src/core/diagram-engine.ts) (Project orchestration), [`src/core/index.ts`](https://github.com/demike/tsuml2/blob/master/src/core/index.ts) (Core API and writes), [`src/lib/index.ts`](https://github.com/demike/tsuml2/blob/master/src/lib/index.ts) (Library exports), [`src/bin/index.ts`](https://github.com/demike/tsuml2/blob/master/src/bin/index.ts) (CLI entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and settings"]
  node_cli["CLI entry<br/>[index.ts]"]
  node_settings["Settings parsing<br/>[parse-settings.ts]"]
  node_options["Diagram options<br/>[tsuml2-settings.ts]"]
end

subgraph group_analysis["Type analysis"]
  node_project["Project orchestration<br/>[diagram-engine.ts]"]
  node_ast["TypeScript AST parsing<br/>[parser.ts]"]
  node_declarations["Declaration model<br/>[model.ts]"]
  node_associations["Member associations<br/>[associations.ts]"]
  node_diagnostics["Diagnostics<br/>[diagnostics.ts]"]
end

subgraph group_render["Diagram rendering"]
  node_emitter["DSL emitter<br/>[emitter.ts]"]
  node_template["Renderer template contract<br/>[template.ts]"]
  node_nomnoml["Nomnoml template"]
  node_mermaid["Mermaid template"]
end

subgraph group_outputs["Outputs and API"]
  node_io["SVG rendering<br/>[io.ts]"]
  node_svg_links["SVG type links<br/>[emitter.ts]"]
  node_api["Core API and writes<br/>[index.ts]"]
  node_library["Library exports<br/>[index.ts]"]
end

node_user(("User"))
node_nomnoml_engine["nomnoml renderer"]
node_filesystem[("Filesystem")]

node_user -->|"runs"| node_cli
node_cli -->|"parses options"| node_settings
node_settings -->|"configures"| node_options
node_cli -->|"invokes"| node_api
node_api -->|"parses project"| node_project
node_project -->|"uses settings"| node_options
node_project -->|"parses declarations"| node_ast
node_ast -->|"creates model"| node_declarations
node_project -->|"derives associations"| node_associations
node_ast -->|"reports issues"| node_diagnostics
node_project -->|"emits DSL"| node_emitter
node_emitter -->|"reads declarations"| node_declarations
node_emitter -->|"uses contract"| node_template
node_project -->|"selects template"| node_nomnoml
node_project -->|"selects template"| node_mermaid
node_nomnoml -->|"implements"| node_template
node_mermaid -->|"implements"| node_template
node_project -->|"renders SVG"| node_io
node_project -->|"post-processes SVG"| node_svg_links
node_project -->|"reads options"| node_options
node_api -->|"writes outputs"| node_filesystem
node_io -.->|"renders diagram"| node_nomnoml_engine
node_library -->|"re-exports API"| node_api
node_library -->|"re-exports renderer"| node_io
node_library -->|"re-exports helper"| node_svg_links

click node_cli "https://github.com/demike/tsuml2/blob/master/src/bin/index.ts"
click node_settings "https://github.com/demike/tsuml2/blob/master/src/core/parse-settings.ts"
click node_options "https://github.com/demike/tsuml2/blob/master/src/core/tsuml2-settings.ts"
click node_project "https://github.com/demike/tsuml2/blob/master/src/core/diagram-engine.ts"
click node_ast "https://github.com/demike/tsuml2/blob/master/src/core/parser/parser.ts"
click node_declarations "https://github.com/demike/tsuml2/blob/master/src/core/model.ts"
click node_associations "https://github.com/demike/tsuml2/blob/master/src/core/parser/associations.ts"
click node_diagnostics "https://github.com/demike/tsuml2/blob/master/src/core/diagnostics.ts"
click node_emitter "https://github.com/demike/tsuml2/blob/master/src/core/emitter.ts"
click node_template "https://github.com/demike/tsuml2/blob/master/src/core/renderer/template.ts"
click node_nomnoml "https://github.com/demike/tsuml2/blob/master/src/core/renderer/nomnoml-template.ts"
click node_mermaid "https://github.com/demike/tsuml2/blob/master/src/core/renderer/mermaid-template.ts"
click node_io "https://github.com/demike/tsuml2/blob/master/src/core/io.ts"
click node_svg_links "https://github.com/demike/tsuml2/blob/master/src/core/emitter.ts"
click node_api "https://github.com/demike/tsuml2/blob/master/src/core/index.ts"
click node_library "https://github.com/demike/tsuml2/blob/master/src/lib/index.ts"

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_settings,node_options,node_user toneBlue
class node_project,node_ast,node_declarations,node_associations,node_diagnostics,node_filesystem toneAmber
class node_emitter,node_template,node_nomnoml,node_mermaid toneMint
class node_io,node_svg_links,node_api,node_library toneRose
class node_nomnoml_engine toneIndigo
```

## Components

### Entry and settings

- [CLI entry](https://github.com/demike/tsuml2/blob/master/src/bin/index.ts): `src/bin/index.ts`
- [Settings parsing](https://github.com/demike/tsuml2/blob/master/src/core/parse-settings.ts): `src/core/parse-settings.ts`
- [Diagram options](https://github.com/demike/tsuml2/blob/master/src/core/tsuml2-settings.ts): `src/core/tsuml2-settings.ts`

### Type analysis

- [Project orchestration](https://github.com/demike/tsuml2/blob/master/src/core/diagram-engine.ts): `src/core/diagram-engine.ts`
- [TypeScript AST parsing](https://github.com/demike/tsuml2/blob/master/src/core/parser/parser.ts): `src/core/parser/parser.ts`
- [Declaration model](https://github.com/demike/tsuml2/blob/master/src/core/model.ts): `src/core/model.ts`
- [Member associations](https://github.com/demike/tsuml2/blob/master/src/core/parser/associations.ts): `src/core/parser/associations.ts`
- [Diagnostics](https://github.com/demike/tsuml2/blob/master/src/core/diagnostics.ts): `src/core/diagnostics.ts`

### Diagram rendering

- [DSL emitter](https://github.com/demike/tsuml2/blob/master/src/core/emitter.ts): `src/core/emitter.ts`
- [Renderer template contract](https://github.com/demike/tsuml2/blob/master/src/core/renderer/template.ts): `src/core/renderer/template.ts`
- [Nomnoml template](https://github.com/demike/tsuml2/blob/master/src/core/renderer/nomnoml-template.ts): `src/core/renderer/nomnoml-template.ts`
- [Mermaid template](https://github.com/demike/tsuml2/blob/master/src/core/renderer/mermaid-template.ts): `src/core/renderer/mermaid-template.ts`

### Outputs and API

- [SVG rendering](https://github.com/demike/tsuml2/blob/master/src/core/io.ts): `src/core/io.ts`
- [SVG type links](https://github.com/demike/tsuml2/blob/master/src/core/emitter.ts): `src/core/emitter.ts`
- [Core API and writes](https://github.com/demike/tsuml2/blob/master/src/core/index.ts): `src/core/index.ts`
- [Library exports](https://github.com/demike/tsuml2/blob/master/src/lib/index.ts): `src/lib/index.ts`

### Other components

- **User**
- **nomnoml renderer**
- **Filesystem**

## Connections

- User → CLI entry: runs (evidence: `README.md`)
- CLI entry → Settings parsing: parses options (evidence: `src/bin/index.ts`)
- Settings parsing → Diagram options: configures (evidence: `src/core/parse-settings.ts`)
- CLI entry → Core API and writes: invokes (evidence: `src/bin/index.ts`)
- Core API and writes → Project orchestration: parses project (evidence: `src/core/index.ts`)
- Project orchestration → Diagram options: uses settings (evidence: `src/core/diagram-engine.ts`)
- Project orchestration → TypeScript AST parsing: parses declarations (evidence: `src/core/diagram-engine.ts`)
- TypeScript AST parsing → Declaration model: creates model (evidence: `src/core/parser/parser.ts`)
- Project orchestration → Member associations: derives associations (evidence: `src/core/diagram-engine.ts`)
- TypeScript AST parsing → Diagnostics: reports issues (evidence: `src/core/parser/parser.ts`)
- Project orchestration → DSL emitter: emits DSL (evidence: `src/core/diagram-engine.ts`)
- DSL emitter → Declaration model: reads declarations (evidence: `src/core/emitter.ts`)
- DSL emitter → Renderer template contract: uses contract (evidence: `src/core/emitter.ts`)
- Project orchestration → Nomnoml template: selects template (evidence: `src/core/diagram-engine.ts`)
- Project orchestration → Mermaid template: selects template (evidence: `src/core/diagram-engine.ts`)
- Nomnoml template → Renderer template contract: implements (evidence: `src/core/renderer/nomnoml-template.ts`)
- Mermaid template → Renderer template contract: implements (evidence: `src/core/renderer/mermaid-template.ts`)
- Project orchestration → SVG rendering: renders SVG (evidence: `src/core/diagram-engine.ts`)
- Project orchestration → SVG type links: post-processes SVG (evidence: `src/core/diagram-engine.ts`)
- Project orchestration → Diagram options: reads options (evidence: `src/core/diagram-engine.ts`)
- Core API and writes → Filesystem: writes outputs (evidence: `src/core/index.ts`)
- SVG rendering → nomnoml renderer: renders diagram (evidence: `README.md`)
- Library exports → Core API and writes: re-exports API (evidence: `src/lib/index.ts`)
- Library exports → SVG rendering: re-exports renderer (evidence: `src/lib/index.ts`)
- Library exports → SVG type links: re-exports helper (evidence: `src/lib/index.ts`)
