# eimza-kep/udf2md architecture

> Architecture diagram of the GitHub repository eimza-kep/udf2md, 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/eimza-kep/udf2md
- Repository: https://github.com/eimza-kep/udf2md

## Overview

udf2md converts UYAP .udf documents into Markdown and JSON through a browser interface or CLI. The main workflow is file input, archive/XML and image handling, document conversion, then output or metadata. The CLI and browser engine are separate implementations; sampled CLI code shows its own ZIP and XML handling, while the README describes the browser workflow. The UI source is unsampled, so browser wiring details are limited to that documentation.

Main entry points: [`js/udf2md-engine.js`](https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.js) (Browser converter), [`cli.js`](https://github.com/eimza-kep/udf2md/blob/master/cli.js) (CLI command), [`index.html`](https://github.com/eimza-kep/udf2md/blob/master/index.html) (Browser interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser workflow"]
  node_browser_ui["Browser interface<br/>[index.html]"]
  node_browser_engine["Browser converter<br/>[udf2md-engine.js]"]
end

subgraph group_cli["CLI workflow"]
  node_cli_entry["CLI command<br/>[cli.js]"]
  node_cli_unpack["CLI archive handling<br/>[cli.js]"]
  node_cli_output["CLI output options<br/>[cli.js]"]
end

subgraph group_conversion["Conversion engine"]
  node_engine_input["Input and archive handling<br/>[udf2md-engine.js]"]
  node_xml_converter["XML to Markdown<br/>[udf2md-engine.js]"]
  node_format_handlers["Document formatting<br/>[udf2md-engine.js]"]
  node_images["Image extraction<br/>[udf2md-engine.js]"]
end

node_user(("Document user"))
node_markdown_result["Markdown result"]
node_json_result["JSON and metadata"]

node_user -->|"selects file"| node_browser_ui
node_browser_ui -->|"converts file"| node_browser_engine
node_browser_engine -->|"returns Markdown"| node_markdown_result
node_browser_engine -->|"returns images"| node_images
node_user -->|"runs command"| node_cli_entry
node_cli_entry -->|"opens archive"| node_cli_unpack
node_cli_entry -->|"selects output"| node_cli_output
node_cli_output -->|"writes Markdown"| node_markdown_result
node_cli_output -->|"writes JSON"| node_json_result
node_engine_input -->|"passes XML"| node_xml_converter
node_xml_converter -->|"renders elements"| node_format_handlers
node_xml_converter -->|"renders references"| node_images
node_format_handlers -->|"produces Markdown"| node_markdown_result

click node_browser_ui "https://github.com/eimza-kep/udf2md/blob/master/index.html"
click node_browser_engine "https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.js"
click node_cli_entry "https://github.com/eimza-kep/udf2md/blob/master/cli.js"
click node_cli_unpack "https://github.com/eimza-kep/udf2md/blob/master/cli.js"
click node_cli_output "https://github.com/eimza-kep/udf2md/blob/master/cli.js"
click node_engine_input "https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.js"
click node_xml_converter "https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.js"
click node_format_handlers "https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.js"
click node_images "https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.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_browser_ui,node_browser_engine,node_user toneBlue
class node_cli_entry,node_cli_unpack,node_cli_output toneAmber
class node_engine_input,node_xml_converter,node_format_handlers,node_images toneMint
class node_markdown_result,node_json_result toneIndigo
```

## Components

### Browser workflow

- [Browser interface](https://github.com/eimza-kep/udf2md/blob/master/index.html): `index.html`
- [Browser converter](https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.js): `js/udf2md-engine.js`

### CLI workflow

- [CLI command](https://github.com/eimza-kep/udf2md/blob/master/cli.js): `cli.js`
- [CLI archive handling](https://github.com/eimza-kep/udf2md/blob/master/cli.js): `cli.js`
- [CLI output options](https://github.com/eimza-kep/udf2md/blob/master/cli.js): `cli.js`

### Conversion engine

- [Input and archive handling](https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.js): `js/udf2md-engine.js`
- [XML to Markdown](https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.js): `js/udf2md-engine.js`
- [Document formatting](https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.js): `js/udf2md-engine.js`
- [Image extraction](https://github.com/eimza-kep/udf2md/blob/master/js/udf2md-engine.js): `js/udf2md-engine.js`

### Other components

- **Document user**
- **Markdown result**
- **JSON and metadata**

## Connections

- Document user → Browser interface: selects file (evidence: `README.md`)
- Browser interface → Browser converter: converts file (evidence: `README.md`)
- Browser converter → Markdown result: returns Markdown (evidence: `js/udf2md-engine.js`)
- Browser converter → Image extraction: returns images (evidence: `js/udf2md-engine.js`)
- Document user → CLI command: runs command (evidence: `README.md`)
- CLI command → CLI archive handling: opens archive (evidence: `cli.js`)
- CLI command → CLI output options: selects output (evidence: `cli.js`)
- CLI output options → Markdown result: writes Markdown (evidence: `README.md`)
- CLI output options → JSON and metadata: writes JSON (evidence: `cli.js`)
- Input and archive handling → XML to Markdown: passes XML (evidence: `js/udf2md-engine.js`)
- XML to Markdown → Document formatting: renders elements (evidence: `js/udf2md-engine.js`)
- XML to Markdown → Image extraction: renders references (evidence: `js/udf2md-engine.js`)
- Document formatting → Markdown result: produces Markdown (evidence: `js/udf2md-engine.js`)
