# marko-js/marko architecture

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

- Interactive diagram: https://gitdiagram.com/marko-js/marko
- Repository: https://github.com/marko-js/marko

## Overview

Marko is a declarative, HTML-based language for building reactive web interfaces. A principal workflow is authoring a Marko template, parsing and compiling it through the compiler and translator, then rendering output through HTML or DOM runtime code. The repository also contains the class-based component runtime, including virtual-DOM support and legacy compatibility. The graph highlights those product stages and documented capabilities; source excerpts are incomplete, so some runtime connections are omitted rather than assumed.

Main entry points: [`packages/compiler/src/index.js`](https://github.com/marko-js/marko/blob/main/packages/compiler/src/index.js) (Compiler API), [`packages/compiler/src/taglib/index.js`](https://github.com/marko-js/marko/blob/main/packages/compiler/src/taglib/index.js) (Taglib Discovery), [`packages/runtime-tags/src/translator/util/runtime.ts`](https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/translator/util/runtime.ts) (Runtime Imports), [`packages/runtime-tags/src/translator/index.ts`](https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/translator/index.ts) (Marko Translator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Compiler"]
  node_compiler_api["Compiler API<br/>[index.js]"]
  node_template_parser["Template Parser<br/>[parser.js]"]
  node_diagnostics["Compile Diagnostics"]
  node_taglib_discovery["Taglib Discovery<br/>[index.js]"]
  node_taglib_loader["Taglib Loading"]
  node_tag_lookup["Tag Lookup<br/>[index.js]"]
  node_babel_plugin["Babel Plugin<br/>[index.js]"]
end

subgraph group_translation["Translation"]
  node_translator["Marko Translator<br/>[index.ts]"]
  node_program_translation["Program Translation<br/>[index.ts]"]
  node_translation_utilities["Translation Utilities"]
  node_runtime_imports["Runtime Imports<br/>[runtime.ts]"]
end

subgraph group_modern_runtime["Runtime Tags"]
  node_html_serializer["HTML Serialization<br/>[serializer.ts]"]
  node_html_writer["HTML Writer<br/>[writer.ts]"]
  node_dom_control_flow["DOM Control Flow<br/>[control-flow.ts]"]
  node_dom_renderer["DOM Renderer<br/>[renderer.ts]"]
end

subgraph group_class_runtime["Class Runtime"]
  node_class_components["Components<br/>[Component.js]"]
  node_vnode["Virtual DOM Nodes<br/>[VNode.js]"]
  node_fragment_morphing["Fragment Morphing<br/>[fragment.js]"]
  node_legacy_jquery["jQuery Compatibility<br/>[jquery.js]"]
end

node_author(("Template Author"))

node_author -.->|"compiles template"| node_compiler_api
node_compiler_api -->|"configures transform"| node_babel_plugin
node_template_parser -->|"builds errors"| node_diagnostics
node_compiler_api -->|"builds tag lookup"| node_taglib_discovery
node_taglib_discovery -->|"loads taglibs"| node_taglib_loader
node_taglib_discovery -->|"populates lookup"| node_tag_lookup
node_translator -->|"registers visitor"| node_program_translation
node_program_translation -->|"uses analysis helpers"| node_translation_utilities
node_translator -->|"configures runtime"| node_runtime_imports
node_runtime_imports -->|"imports HTML runtime"| node_html_serializer
node_runtime_imports -->|"imports DOM runtime"| node_dom_control_flow
node_html_serializer -->|"writes output"| node_html_writer
node_dom_control_flow -->|"calls renderer"| node_dom_renderer
node_vnode -.->|"supports fragment nodes"| node_fragment_morphing
node_legacy_jquery -->|"patches component"| node_class_components

click node_compiler_api "https://github.com/marko-js/marko/blob/main/packages/compiler/src/index.js"
click node_template_parser "https://github.com/marko-js/marko/blob/main/packages/compiler/src/babel-plugin/parser.js"
click node_diagnostics "https://github.com/marko-js/marko/blob/main/packages/compiler/src/util/build-code-frame.js"
click node_taglib_discovery "https://github.com/marko-js/marko/blob/main/packages/compiler/src/taglib/index.js"
click node_taglib_loader "https://github.com/marko-js/marko/tree/main/packages/compiler/src/taglib/loader"
click node_tag_lookup "https://github.com/marko-js/marko/blob/main/packages/compiler/src/taglib/lookup/index.js"
click node_babel_plugin "https://github.com/marko-js/marko/blob/main/packages/compiler/src/babel-plugin/index.js"
click node_translator "https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/translator/index.ts"
click node_program_translation "https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/translator/visitors/program/index.ts"
click node_translation_utilities "https://github.com/marko-js/marko/tree/main/packages/runtime-tags/src/translator/util"
click node_runtime_imports "https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/translator/util/runtime.ts"
click node_html_serializer "https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/html/serializer.ts"
click node_html_writer "https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/html/writer.ts"
click node_dom_control_flow "https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/dom/control-flow.ts"
click node_dom_renderer "https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/dom/renderer.ts"
click node_class_components "https://github.com/marko-js/marko/blob/main/packages/runtime-class/src/runtime/components/Component.js"
click node_vnode "https://github.com/marko-js/marko/blob/main/packages/runtime-class/src/runtime/vdom/VNode.js"
click node_fragment_morphing "https://github.com/marko-js/marko/blob/main/packages/runtime-class/src/runtime/vdom/morphdom/fragment.js"
click node_legacy_jquery "https://github.com/marko-js/marko/blob/main/packages/runtime-class/src/runtime/components/legacy/jquery.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_compiler_api,node_template_parser,node_diagnostics,node_taglib_discovery,node_taglib_loader,node_tag_lookup,node_babel_plugin toneBlue
class node_translator,node_program_translation,node_translation_utilities,node_runtime_imports toneAmber
class node_html_serializer,node_html_writer,node_dom_control_flow,node_dom_renderer toneMint
class node_class_components,node_vnode,node_fragment_morphing,node_legacy_jquery toneRose
class node_author toneIndigo
```

## Components

### Compiler

- [Compiler API](https://github.com/marko-js/marko/blob/main/packages/compiler/src/index.js): `packages/compiler/src/index.js`
- [Template Parser](https://github.com/marko-js/marko/blob/main/packages/compiler/src/babel-plugin/parser.js): `packages/compiler/src/babel-plugin/parser.js`
- [Compile Diagnostics](https://github.com/marko-js/marko/blob/main/packages/compiler/src/util/build-code-frame.js): `packages/compiler/src/util/build-code-frame.js`
- [Taglib Discovery](https://github.com/marko-js/marko/blob/main/packages/compiler/src/taglib/index.js): `packages/compiler/src/taglib/index.js`
- [Taglib Loading](https://github.com/marko-js/marko/tree/main/packages/compiler/src/taglib/loader): `packages/compiler/src/taglib/loader`
- [Tag Lookup](https://github.com/marko-js/marko/blob/main/packages/compiler/src/taglib/lookup/index.js): `packages/compiler/src/taglib/lookup/index.js`
- [Babel Plugin](https://github.com/marko-js/marko/blob/main/packages/compiler/src/babel-plugin/index.js): `packages/compiler/src/babel-plugin/index.js`

### Translation

- [Marko Translator](https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/translator/index.ts): `packages/runtime-tags/src/translator/index.ts`
- [Program Translation](https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/translator/visitors/program/index.ts): `packages/runtime-tags/src/translator/visitors/program/index.ts`
- [Translation Utilities](https://github.com/marko-js/marko/tree/main/packages/runtime-tags/src/translator/util): `packages/runtime-tags/src/translator/util`
- [Runtime Imports](https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/translator/util/runtime.ts): `packages/runtime-tags/src/translator/util/runtime.ts`

### Runtime Tags

- [HTML Serialization](https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/html/serializer.ts): `packages/runtime-tags/src/html/serializer.ts`
- [HTML Writer](https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/html/writer.ts): `packages/runtime-tags/src/html/writer.ts`
- [DOM Control Flow](https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/dom/control-flow.ts): `packages/runtime-tags/src/dom/control-flow.ts`
- [DOM Renderer](https://github.com/marko-js/marko/blob/main/packages/runtime-tags/src/dom/renderer.ts): `packages/runtime-tags/src/dom/renderer.ts`

### Class Runtime

- [Components](https://github.com/marko-js/marko/blob/main/packages/runtime-class/src/runtime/components/Component.js): `packages/runtime-class/src/runtime/components/Component.js`
- [Virtual DOM Nodes](https://github.com/marko-js/marko/blob/main/packages/runtime-class/src/runtime/vdom/VNode.js): `packages/runtime-class/src/runtime/vdom/VNode.js`
- [Fragment Morphing](https://github.com/marko-js/marko/blob/main/packages/runtime-class/src/runtime/vdom/morphdom/fragment.js): `packages/runtime-class/src/runtime/vdom/morphdom/fragment.js`
- [jQuery Compatibility](https://github.com/marko-js/marko/blob/main/packages/runtime-class/src/runtime/components/legacy/jquery.js): `packages/runtime-class/src/runtime/components/legacy/jquery.js`

### Other components

- **Template Author**

## Connections

- Template Author → Compiler API: compiles template (evidence: `README.md`)
- Compiler API → Babel Plugin: configures transform (evidence: `packages/compiler/src/index.js`)
- Template Parser → Compile Diagnostics: builds errors (evidence: `packages/compiler/src/babel-plugin/parser.js`)
- Compiler API → Taglib Discovery: builds tag lookup (evidence: `packages/compiler/src/index.js`)
- Taglib Discovery → Taglib Loading: loads taglibs (evidence: `packages/compiler/src/taglib/index.js`)
- Taglib Discovery → Tag Lookup: populates lookup (evidence: `packages/compiler/src/taglib/index.js`)
- Marko Translator → Program Translation: registers visitor (evidence: `packages/runtime-tags/src/translator/index.ts`)
- Program Translation → Translation Utilities: uses analysis helpers (evidence: `packages/runtime-tags/src/translator/visitors/program/index.ts`)
- Marko Translator → Runtime Imports: configures runtime (evidence: `packages/runtime-tags/src/translator/index.ts`)
- Runtime Imports → HTML Serialization: imports HTML runtime (evidence: `packages/runtime-tags/src/translator/util/runtime.ts`)
- Runtime Imports → DOM Control Flow: imports DOM runtime (evidence: `packages/runtime-tags/src/translator/util/runtime.ts`)
- HTML Serialization → HTML Writer: writes output (evidence: `packages/runtime-tags/src/html/serializer.ts`)
- DOM Control Flow → DOM Renderer: calls renderer (evidence: `packages/runtime-tags/src/dom/control-flow.ts`)
- Virtual DOM Nodes → Fragment Morphing: supports fragment nodes
- jQuery Compatibility → Components: patches component (evidence: `packages/runtime-class/src/runtime/components/legacy/jquery.js`)
