# chrisryugj/kordoc architecture

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

- Interactive diagram: https://gitdiagram.com/chrisryugj/kordoc
- Repository: https://github.com/chrisryugj/kordoc

## Overview

Kordoc converts Korean and office documents into Markdown and structured blocks, with CLI, library, and MCP entry points. The main workflow detects an input format, parses it into a shared document representation, and returns Markdown, page content, and metadata. Separate product branches support document creation, form filling, visual rendering, comparison and layout-preserving edits, OCR, and review/redaction. The README documents these capabilities; unsampled implementation details are represented at their existing source paths, without asserting unshown internal calls.

Main entry points: [`src/index.ts`](https://github.com/chrisryugj/kordoc/blob/main/src/index.ts) (Library API), [`src/cli.ts`](https://github.com/chrisryugj/kordoc/blob/main/src/cli.ts) (CLI), [`src/mcp.ts`](https://github.com/chrisryugj/kordoc/blob/main/src/mcp.ts) (MCP server), [`src/detect.ts`](https://github.com/chrisryugj/kordoc/blob/main/src/detect.ts) (Format detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI<br/>[cli.ts]"]
  node_mcp["MCP server<br/>[mcp.ts]"]
  node_api["Library API<br/>[index.ts]"]
end

subgraph group_parsing["Document parsing"]
  node_detect["Format detection<br/>[detect.ts]"]
  node_hwp3["HWP 3 parser<br/>[parser.ts]"]
  node_hwp5["HWP 5 parser<br/>[parser.ts]"]
  node_hwpx["HWPX parser<br/>[parser.ts]"]
  node_pdf["PDF parser<br/>[parser.ts]"]
  node_spreadsheets["XLS and XLSX<br/>[parser.ts]"]
  node_docx["DOCX parser<br/>[parser.ts]"]
  node_other_formats["Other formats<br/>[parser.ts]"]
end

subgraph group_document_ops["Document operations"]
  node_render["Document rendering<br/>[svg-render.ts]"]
  node_generate["HWPX generation<br/>[generator.ts]"]
  node_forms["Form filling<br/>[filler.ts]"]
  node_compare["Document comparison<br/>[compare.ts]"]
  node_patch["Layout-preserving edits<br/>[session.ts]"]
end

subgraph group_review["Review and OCR"]
  node_ocr["Local OCR<br/>[engine.ts]"]
  node_redact["Privacy redaction<br/>[redact.ts]"]
  node_validate["Document validation<br/>[validate.ts]"]
end

subgraph group_shared["Shared document model"]
  node_table["Table and Markdown conversion<br/>[builder.ts]"]
  node_result["Markdown and structured result<br/>[types.ts]"]
end

node_user(("User or agent"))

node_user -->|"runs commands"| node_cli
node_user -->|"uses tools"| node_mcp
node_user -->|"calls library"| node_api
node_cli -.->|"requests parsing"| node_api
node_mcp -.->|"offers document tools"| node_api
node_api -->|"detects format"| node_detect
node_api -->|"dispatches HWP3"| node_hwp3
node_api -->|"dispatches HWP5"| node_hwp5
node_api -->|"dispatches HWPX"| node_hwpx
node_api -->|"dispatches PDF"| node_pdf
node_api -->|"dispatches XLSX"| node_spreadsheets
node_api -->|"dispatches DOCX"| node_docx
node_api -->|"dispatches PPTX"| node_other_formats
node_api -->|"converts blocks"| node_table
node_api -->|"returns parsed content"| node_result
node_user -->|"requests OCR"| node_ocr
node_user -->|"requests preview"| node_render
node_user -->|"requests creation"| node_generate
node_user -->|"fills template"| node_forms
node_user -->|"compares documents"| node_compare
node_user -->|"requests edits"| node_patch
node_user -->|"requests masking"| node_redact
node_user -->|"requests review"| node_validate

click node_cli "https://github.com/chrisryugj/kordoc/blob/main/src/cli.ts"
click node_mcp "https://github.com/chrisryugj/kordoc/blob/main/src/mcp.ts"
click node_api "https://github.com/chrisryugj/kordoc/blob/main/src/index.ts"
click node_detect "https://github.com/chrisryugj/kordoc/blob/main/src/detect.ts"
click node_hwp3 "https://github.com/chrisryugj/kordoc/blob/main/src/hwp3/parser.ts"
click node_hwp5 "https://github.com/chrisryugj/kordoc/blob/main/src/hwp5/parser.ts"
click node_hwpx "https://github.com/chrisryugj/kordoc/blob/main/src/hwpx/parser.ts"
click node_pdf "https://github.com/chrisryugj/kordoc/blob/main/src/pdf/parser.ts"
click node_spreadsheets "https://github.com/chrisryugj/kordoc/blob/main/src/xlsx/parser.ts"
click node_docx "https://github.com/chrisryugj/kordoc/blob/main/src/docx/parser.ts"
click node_other_formats "https://github.com/chrisryugj/kordoc/blob/main/src/pptx/parser.ts"
click node_ocr "https://github.com/chrisryugj/kordoc/blob/main/src/ocr/engine.ts"
click node_render "https://github.com/chrisryugj/kordoc/blob/main/src/render/svg-render.ts"
click node_generate "https://github.com/chrisryugj/kordoc/blob/main/src/hwpx/generator.ts"
click node_forms "https://github.com/chrisryugj/kordoc/blob/main/src/form/filler.ts"
click node_compare "https://github.com/chrisryugj/kordoc/blob/main/src/diff/compare.ts"
click node_patch "https://github.com/chrisryugj/kordoc/blob/main/src/roundtrip/session.ts"
click node_redact "https://github.com/chrisryugj/kordoc/blob/main/src/redact.ts"
click node_validate "https://github.com/chrisryugj/kordoc/blob/main/src/validate.ts"
click node_table "https://github.com/chrisryugj/kordoc/blob/main/src/table/builder.ts"
click node_result "https://github.com/chrisryugj/kordoc/blob/main/src/types.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_mcp,node_api,node_user toneBlue
class node_detect,node_hwp3,node_hwp5,node_hwpx,node_pdf,node_spreadsheets,node_docx,node_other_formats toneAmber
class node_render,node_generate,node_forms,node_compare,node_patch toneMint
class node_ocr,node_redact,node_validate toneRose
class node_table,node_result toneIndigo
```

## Components

### User interfaces

- [CLI](https://github.com/chrisryugj/kordoc/blob/main/src/cli.ts): `src/cli.ts`
- [MCP server](https://github.com/chrisryugj/kordoc/blob/main/src/mcp.ts): `src/mcp.ts`
- [Library API](https://github.com/chrisryugj/kordoc/blob/main/src/index.ts): `src/index.ts`

### Document parsing

- [Format detection](https://github.com/chrisryugj/kordoc/blob/main/src/detect.ts): `src/detect.ts`
- [HWP 3 parser](https://github.com/chrisryugj/kordoc/blob/main/src/hwp3/parser.ts): `src/hwp3/parser.ts`
- [HWP 5 parser](https://github.com/chrisryugj/kordoc/blob/main/src/hwp5/parser.ts): `src/hwp5/parser.ts`
- [HWPX parser](https://github.com/chrisryugj/kordoc/blob/main/src/hwpx/parser.ts): `src/hwpx/parser.ts`
- [PDF parser](https://github.com/chrisryugj/kordoc/blob/main/src/pdf/parser.ts): `src/pdf/parser.ts`
- [XLS and XLSX](https://github.com/chrisryugj/kordoc/blob/main/src/xlsx/parser.ts): `src/xlsx/parser.ts`
- [DOCX parser](https://github.com/chrisryugj/kordoc/blob/main/src/docx/parser.ts): `src/docx/parser.ts`
- [Other formats](https://github.com/chrisryugj/kordoc/blob/main/src/pptx/parser.ts): `src/pptx/parser.ts`

### Document operations

- [Document rendering](https://github.com/chrisryugj/kordoc/blob/main/src/render/svg-render.ts): `src/render/svg-render.ts`
- [HWPX generation](https://github.com/chrisryugj/kordoc/blob/main/src/hwpx/generator.ts): `src/hwpx/generator.ts`
- [Form filling](https://github.com/chrisryugj/kordoc/blob/main/src/form/filler.ts): `src/form/filler.ts`
- [Document comparison](https://github.com/chrisryugj/kordoc/blob/main/src/diff/compare.ts): `src/diff/compare.ts`
- [Layout-preserving edits](https://github.com/chrisryugj/kordoc/blob/main/src/roundtrip/session.ts): `src/roundtrip/session.ts`

### Review and OCR

- [Local OCR](https://github.com/chrisryugj/kordoc/blob/main/src/ocr/engine.ts): `src/ocr/engine.ts`
- [Privacy redaction](https://github.com/chrisryugj/kordoc/blob/main/src/redact.ts): `src/redact.ts`
- [Document validation](https://github.com/chrisryugj/kordoc/blob/main/src/validate.ts): `src/validate.ts`

### Shared document model

- [Table and Markdown conversion](https://github.com/chrisryugj/kordoc/blob/main/src/table/builder.ts): `src/table/builder.ts`
- [Markdown and structured result](https://github.com/chrisryugj/kordoc/blob/main/src/types.ts): `src/types.ts`

### Other components

- **User or agent**

## Connections

- User or agent → CLI: runs commands (evidence: `README.md`)
- User or agent → MCP server: uses tools (evidence: `README.md`)
- User or agent → Library API: calls library (evidence: `README.md`)
- CLI → Library API: requests parsing
- MCP server → Library API: offers document tools
- Library API → Format detection: detects format (evidence: `src/index.ts`)
- Library API → HWP 3 parser: dispatches HWP3 (evidence: `src/index.ts`)
- Library API → HWP 5 parser: dispatches HWP5 (evidence: `src/index.ts`)
- Library API → HWPX parser: dispatches HWPX (evidence: `src/index.ts`)
- Library API → PDF parser: dispatches PDF (evidence: `src/index.ts`)
- Library API → XLS and XLSX: dispatches XLSX (evidence: `src/index.ts`)
- Library API → DOCX parser: dispatches DOCX (evidence: `src/index.ts`)
- Library API → Other formats: dispatches PPTX (evidence: `src/index.ts`)
- Library API → Table and Markdown conversion: converts blocks (evidence: `src/index.ts`)
- Library API → Markdown and structured result: returns parsed content (evidence: `README.md`)
- User or agent → Local OCR: requests OCR (evidence: `README.md`)
- User or agent → Document rendering: requests preview (evidence: `README.md`)
- User or agent → HWPX generation: requests creation (evidence: `README.md`)
- User or agent → Form filling: fills template (evidence: `README.md`)
- User or agent → Document comparison: compares documents (evidence: `README.md`)
- User or agent → Layout-preserving edits: requests edits (evidence: `README.md`)
- User or agent → Privacy redaction: requests masking (evidence: `README.md`)
- User or agent → Document validation: requests review (evidence: `README.md`)
