# yangziwen/myers-diff architecture

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

- Interactive diagram: https://gitdiagram.com/yangziwen/myers-diff
- Repository: https://github.com/yangziwen/myers-diff

## Overview

Myers Diff is a browser tool for comparing two text inputs and visualizing the paths explored by the Myers algorithm. The main workflow is to enter both texts, run the comparison, inspect the best diff, and select a (d, k) step to inspect another solution. The source excerpts show separate algorithm, chart, editor, and module-loader components, but do not show the page-level wiring between them; only the algorithm-to-chart data relationship is visible in the chart API.

Main entry points: [`js/myers.js`](https://github.com/yangziwen/myers-diff/blob/master/js/myers.js) (Myers algorithm), [`index.html`](https://github.com/yangziwen/myers-diff/blob/master/index.html) (Diff page), [`js/diffchart.js`](https://github.com/yangziwen/myers-diff/blob/master/js/diffchart.js) (Step chart)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Comparison interface"]
  node_page["Diff page<br/>[index.html]"]
  node_text_editors["Text editors<br/>[diffeditor.js]"]
  node_result_editors["Diff editors<br/>[diffeditor.js]"]
end

subgraph group_algorithm["Diff computation"]
  node_myers["Myers algorithm<br/>[myers.js]"]
end

subgraph group_visualization["Result visualization"]
  node_position_chart["Position chart<br/>[diffchart.js]"]
  node_step_chart["Step chart<br/>[diffchart.js]"]
end

subgraph group_runtime["Browser runtime"]
  node_requirejs["RequireJS loader<br/>[require.js]"]
end

node_user(("User"))

node_user -->|"enters texts"| node_page
node_user -->|"runs comparison"| node_page
node_user -->|"selects step"| node_step_chart
node_myers -->|"provides diff"| node_step_chart
node_myers -->|"provides positions"| node_position_chart

click node_page "https://github.com/yangziwen/myers-diff/blob/master/index.html"
click node_text_editors "https://github.com/yangziwen/myers-diff/blob/master/js/diffeditor.js"
click node_result_editors "https://github.com/yangziwen/myers-diff/blob/master/js/diffeditor.js"
click node_myers "https://github.com/yangziwen/myers-diff/blob/master/js/myers.js"
click node_position_chart "https://github.com/yangziwen/myers-diff/blob/master/js/diffchart.js"
click node_step_chart "https://github.com/yangziwen/myers-diff/blob/master/js/diffchart.js"
click node_requirejs "https://github.com/yangziwen/myers-diff/blob/master/js/require.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_page,node_text_editors,node_result_editors,node_user toneBlue
class node_myers toneAmber
class node_position_chart,node_step_chart toneMint
class node_requirejs toneRose
```

## Components

### Comparison interface

- [Diff page](https://github.com/yangziwen/myers-diff/blob/master/index.html): `index.html`
- [Text editors](https://github.com/yangziwen/myers-diff/blob/master/js/diffeditor.js): `js/diffeditor.js`
- [Diff editors](https://github.com/yangziwen/myers-diff/blob/master/js/diffeditor.js): `js/diffeditor.js`

### Diff computation

- [Myers algorithm](https://github.com/yangziwen/myers-diff/blob/master/js/myers.js): `js/myers.js`

### Result visualization

- [Position chart](https://github.com/yangziwen/myers-diff/blob/master/js/diffchart.js): `js/diffchart.js`
- [Step chart](https://github.com/yangziwen/myers-diff/blob/master/js/diffchart.js): `js/diffchart.js`

### Browser runtime

- [RequireJS loader](https://github.com/yangziwen/myers-diff/blob/master/js/require.js): `js/require.js`

### Other components

- **User**

## Connections

- User → Diff page: enters texts (evidence: `README.md`)
- User → Diff page: runs comparison (evidence: `README.md`)
- User → Step chart: selects step (evidence: `README.md`)
- Myers algorithm → Step chart: provides diff (evidence: `js/diffchart.js`)
- Myers algorithm → Position chart: provides positions (evidence: `js/diffchart.js`)
