# gokselb/udfpdf architecture

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

## Overview

udfpdf converts UYAP UDF archives into PDF, DOCX, HTML, Markdown, or plain text through a CLI or programmatic API. The main workflow extracts archive files, parses UYAP XML and metadata, builds a styled document model, then renders the selected format; the CLI writes the result to a file. The graph also shows style resolution as an internal layer. Renderer capabilities are documented in the README; extraction and XML-parser connections are supported by the source index, but those implementations were not excerpted.

Main entry points: [`src/index.ts`](https://github.com/gokselb/udfpdf/blob/main/src/index.ts) (Parse and convert API), [`src/cli.ts`](https://github.com/gokselb/udfpdf/blob/main/src/cli.ts) (CLI), [`src/parser/document-model.ts`](https://github.com/gokselb/udfpdf/blob/main/src/parser/document-model.ts) (Model builder), [`src/utils/style-resolver.ts`](https://github.com/gokselb/udfpdf/blob/main/src/utils/style-resolver.ts) (Style resolution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_cli["CLI<br/>[cli.ts]"]
  node_api["Parse and convert API<br/>[index.ts]"]
end

subgraph group_parsing["UDF parsing"]
  node_archive["Archive extraction<br/>[unzip.ts]"]
  node_xml["UYAP XML parsing<br/>[xml-parser.ts]"]
end

subgraph group_model["Document model"]
  node_builder["Model builder<br/>[document-model.ts]"]
  node_styles["Style resolution<br/>[style-resolver.ts]"]
  node_colors["Color conversion<br/>[color.ts]"]
end

subgraph group_rendering["Output rendering"]
  node_text["Text renderer<br/>[text.ts]"]
  node_html["HTML renderer<br/>[html.ts]"]
  node_markdown["Markdown renderer<br/>[markdown.ts]"]
  node_pdf["PDF renderer<br/>[pdf.ts]"]
  node_docx["DOCX renderer<br/>[docx.ts]"]
end

node_user(("User or API client"))
node_filesystem[("Output filesystem")]

node_user -->|"runs conversion"| node_cli
node_user -->|"calls API"| node_api
node_cli -->|"parses input"| node_api
node_api -->|"extracts archive"| node_archive
node_api -->|"parses XML"| node_xml
node_api -->|"builds model"| node_builder
node_builder -->|"resolves styles"| node_styles
node_styles -->|"converts colors"| node_colors
node_api -->|"renders text"| node_text
node_api -->|"renders HTML"| node_html
node_api -->|"renders Markdown"| node_markdown
node_api -->|"renders PDF"| node_pdf
node_api -->|"renders DOCX"| node_docx
node_cli -->|"renders text"| node_text
node_cli -->|"renders HTML"| node_html
node_cli -->|"renders Markdown"| node_markdown
node_cli -->|"renders PDF"| node_pdf
node_cli -->|"renders DOCX"| node_docx
node_cli -->|"writes output"| node_filesystem

click node_cli "https://github.com/gokselb/udfpdf/blob/main/src/cli.ts"
click node_api "https://github.com/gokselb/udfpdf/blob/main/src/index.ts"
click node_archive "https://github.com/gokselb/udfpdf/blob/main/src/parser/unzip.ts"
click node_xml "https://github.com/gokselb/udfpdf/blob/main/src/parser/xml-parser.ts"
click node_builder "https://github.com/gokselb/udfpdf/blob/main/src/parser/document-model.ts"
click node_styles "https://github.com/gokselb/udfpdf/blob/main/src/utils/style-resolver.ts"
click node_colors "https://github.com/gokselb/udfpdf/blob/main/src/utils/color.ts"
click node_text "https://github.com/gokselb/udfpdf/blob/main/src/renderers/text.ts"
click node_html "https://github.com/gokselb/udfpdf/blob/main/src/renderers/html.ts"
click node_markdown "https://github.com/gokselb/udfpdf/blob/main/src/renderers/markdown.ts"
click node_pdf "https://github.com/gokselb/udfpdf/blob/main/src/renderers/pdf.ts"
click node_docx "https://github.com/gokselb/udfpdf/blob/main/src/renderers/docx.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_api,node_user toneBlue
class node_archive,node_xml,node_filesystem toneAmber
class node_builder,node_styles,node_colors toneMint
class node_text,node_html,node_markdown,node_pdf,node_docx toneRose
```

## Components

### Entry points

- [CLI](https://github.com/gokselb/udfpdf/blob/main/src/cli.ts): `src/cli.ts`
- [Parse and convert API](https://github.com/gokselb/udfpdf/blob/main/src/index.ts): `src/index.ts`

### UDF parsing

- [Archive extraction](https://github.com/gokselb/udfpdf/blob/main/src/parser/unzip.ts): `src/parser/unzip.ts`
- [UYAP XML parsing](https://github.com/gokselb/udfpdf/blob/main/src/parser/xml-parser.ts): `src/parser/xml-parser.ts`

### Document model

- [Model builder](https://github.com/gokselb/udfpdf/blob/main/src/parser/document-model.ts): `src/parser/document-model.ts`
- [Style resolution](https://github.com/gokselb/udfpdf/blob/main/src/utils/style-resolver.ts): `src/utils/style-resolver.ts`
- [Color conversion](https://github.com/gokselb/udfpdf/blob/main/src/utils/color.ts): `src/utils/color.ts`

### Output rendering

- [Text renderer](https://github.com/gokselb/udfpdf/blob/main/src/renderers/text.ts): `src/renderers/text.ts`
- [HTML renderer](https://github.com/gokselb/udfpdf/blob/main/src/renderers/html.ts): `src/renderers/html.ts`
- [Markdown renderer](https://github.com/gokselb/udfpdf/blob/main/src/renderers/markdown.ts): `src/renderers/markdown.ts`
- [PDF renderer](https://github.com/gokselb/udfpdf/blob/main/src/renderers/pdf.ts): `src/renderers/pdf.ts`
- [DOCX renderer](https://github.com/gokselb/udfpdf/blob/main/src/renderers/docx.ts): `src/renderers/docx.ts`

### Other components

- **User or API client**
- **Output filesystem**

## Connections

- User or API client → CLI: runs conversion (evidence: `README.md`)
- User or API client → Parse and convert API: calls API (evidence: `README.md`)
- CLI → Parse and convert API: parses input (evidence: `src/cli.ts`)
- Parse and convert API → Archive extraction: extracts archive (evidence: `src/index.ts`)
- Parse and convert API → UYAP XML parsing: parses XML (evidence: `src/index.ts`)
- Parse and convert API → Model builder: builds model (evidence: `src/index.ts`)
- Model builder → Style resolution: resolves styles (evidence: `src/parser/document-model.ts`)
- Style resolution → Color conversion: converts colors (evidence: `src/utils/style-resolver.ts`)
- Parse and convert API → Text renderer: renders text (evidence: `src/index.ts`)
- Parse and convert API → HTML renderer: renders HTML (evidence: `src/index.ts`)
- Parse and convert API → Markdown renderer: renders Markdown (evidence: `src/index.ts`)
- Parse and convert API → PDF renderer: renders PDF (evidence: `src/index.ts`)
- Parse and convert API → DOCX renderer: renders DOCX (evidence: `src/index.ts`)
- CLI → Text renderer: renders text (evidence: `src/cli.ts`)
- CLI → HTML renderer: renders HTML (evidence: `src/cli.ts`)
- CLI → Markdown renderer: renders Markdown (evidence: `src/cli.ts`)
- CLI → PDF renderer: renders PDF (evidence: `src/cli.ts`)
- CLI → DOCX renderer: renders DOCX (evidence: `src/cli.ts`)
- CLI → Output filesystem: writes output (evidence: `src/cli.ts`)
