Skip to content

Vyuh DOCX Architecture Map

This page is a reviewer map for packages/vyuh_docx. It explains the headless document engine, the rendering pipeline, and the boundary with docx_editor.

What This Package Owns

vyuh_docx is a pure Dart document engine. It reads, builds, transforms, and exports document structure. It has no Flutter editor UI and no workflow authority.

text
DOCX / SFDT / HTML / Markdown / builder input
  -> DocxBuiltDocument AST
  -> resolved source-backed properties
  -> layout model
  -> exporters
  -> DOCX / SFDT / HTML / PDF

Main Layers

LayerMain APIsResponsibility
InputDocxReader, SfdtReader, HtmlParser, MarkdownParser, docx()Convert source formats or generated content into the model.
ModelDocxBuiltDocument, DocxParagraph, DocxText, DocxTable, DocxSectionDef, drawing/comment/revision nodesPreserve document structure and Word/SFDT properties.
LayoutPdfLayoutEngine, PdfLayoutDocument, PdfLayoutBoxMeasure content and create page fragments.
ExportDocxExporter, SfdtExporter, HtmlExporter, PdfExporterWrite model output formats.
UtilitiesDocxDocumentDiff, DocxTemplateEngine, validators, ID helpers, XML helpersSupport comparison, templating, and diagnostics.

Boundary With DOCX Editor

ConcernOwner
Parse DOCX into an ASTvyuh_docx
Convert AST to SFDTvyuh_docx
Convert SFDT to DOCX or PDFvyuh_docx
Host Syncfusion DocumentEditordocx_editor
Enforce actor permissionsHost and docx_editor
Save document versionsHost through docx_editor contracts
Electronic signingHost and docx_editor
Controlled copy allocation and register writesHost and docx_editor

This separation keeps vyuh_docx reusable on servers, command-line tools, tests, and Flutter apps.

Source-Backed Rendering Rule

Renderer behavior must come from one of these sources:

  • DOCX XML;
  • SFDT JSON;
  • generated DocxBuiltDocument fields;
  • a documented Word or OOXML default.

If a needed property is missing, add it to the model first. Do not add file-name-specific or customer-specific renderer branches.

Why The Layout Model Exists

Directly painting AST nodes is not enough for Word-like output. Reviewers should expect layout facts to be explicit:

Layout factWhy it matters
Paragraph line boxesNeeded for wrapping, alignment, tabs, and page breaks.
Table row fragmentsNeeded for rows that split across pages.
Repeated header rowsNeeded for multi-page tables.
Section boxesNeeded for page size, margins, columns, headers, and footers.
Image and shape geometryNeeded for inline and floating positioning.
Page fragmentsNeeded for deterministic PDF painting and diagnostics.

PdfLayoutDocument and the PdfLayoutBox family make those facts testable.

Review Checklist

  • Parsing preserves source-backed properties instead of dropping them early.
  • PDF export uses PdfLayoutEngine before painting pages.
  • Deterministic output options stay in PdfExporter.
  • Workflow concepts such as actor, signing, lifecycle, permissions, and print registers do not enter this package.
  • Any new renderer rule has a DOCX, SFDT, or documented default source.