# nestmold/notratlatexplugin architecture

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

- Interactive diagram: https://gitdiagram.com/nestmold/notratlatexplugin
- Repository: https://github.com/nestmold/notratlatexplugin

## Overview

Notrat LaTeX 助手 is a Notrat plugin for editing `.tex` documents, navigating their structure, validating references, compiling PDFs, and exporting PDF or self-contained HTML. The main workflow starts when a user opens a LaTeX file in the host: the editor presents visual, source, or split views, while the outline supports navigation; users can then compile, validate, or export through the plugin’s MCP server. The README documents additional backup/history and AI-tool capabilities. Several server implementations were not sampled, so those capabilities are shown at the documented subsystem level without asserting internal call wiring.

Main entry points: [`server/index.js`](https://github.com/nestmold/notratlatexplugin/blob/main/server/index.js) (MCP tool server), [`panels/editor.tsx`](https://github.com/nestmold/notratlatexplugin/blob/main/panels/editor.tsx) (Document editor), [`server/export-html.js`](https://github.com/nestmold/notratlatexplugin/blob/main/server/export-html.js) (Document export), [`panels/main.tsx`](https://github.com/nestmold/notratlatexplugin/blob/main/panels/main.tsx) (Tool panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Plugin interface"]
  node_editor["Document editor<br/>[editor.tsx]"]
  node_panel["Tool panel<br/>[main.tsx]"]
  node_outline["Outline panel<br/>[outline.tsx]"]
  node_codeblock["LaTeX code blocks<br/>[code-renderer.tsx]"]
end

subgraph group_editing["Editing and preview"]
  node_preview["Preview renderer<br/>[preview-core.js]"]
  node_docmodel["Lossless document model<br/>[docmodel.js]"]
  node_wysiwyg["Visual editing core<br/>[wysiwyg.js]"]
  node_txlog["Transaction history<br/>[txlog.js]"]
end

subgraph group_server["MCP services"]
  node_mcp["MCP tool server<br/>[index.js]"]
  node_contrib["Shared server utilities<br/>[contrib.js]"]
  node_engineinstall["Engine installation<br/>[engine-install.js]"]
end

subgraph group_outputs["Compile and export"]
  node_compiler["PDF compilation<br/>[index.js]"]
  node_exporter["Document export<br/>[export-html.js]"]
  node_raster["PDF rasterization<br/>[pdf-raster.js]"]
end

node_user(("LaTeX author"))
node_host["Notrat host"]
node_texfiles[("TeX workspace")]
node_engine["TeX engine"]

node_user -->|"opens document"| node_host
node_host -->|"mounts editor"| node_editor
node_host -->|"mounts tools"| node_panel
node_host -->|"mounts outline"| node_outline
node_host -->|"renders messages"| node_codeblock
node_editor -->|"edits document"| node_texfiles
node_editor -->|"renders preview"| node_preview
node_editor -->|"edits visual blocks"| node_wysiwyg
node_editor -->|"uses document model"| node_docmodel
node_editor -->|"records history"| node_txlog
node_editor -->|"requests assets"| node_mcp
node_outline -->|"requests outline"| node_mcp
node_panel -->|"calls tools"| node_mcp
node_codeblock -->|"loads KaTeX assets"| node_mcp
node_mcp -->|"reads and writes files"| node_texfiles
node_mcp -->|"uses utilities"| node_contrib
node_mcp -->|"dispatches compile"| node_compiler
node_mcp -->|"dispatches export"| node_exporter
node_mcp -->|"requests rasterization"| node_raster
node_compiler -->|"runs compiler"| node_engine
node_compiler -->|"reads source"| node_texfiles
node_exporter -->|"reads source and assets"| node_texfiles
node_exporter -.->|"produces PDF"| node_compiler
node_raster -.->|"uses raster tools"| node_engine
node_engineinstall -.->|"installs engine"| node_engine

click node_editor "https://github.com/nestmold/notratlatexplugin/blob/main/panels/editor.tsx"
click node_panel "https://github.com/nestmold/notratlatexplugin/blob/main/panels/main.tsx"
click node_outline "https://github.com/nestmold/notratlatexplugin/blob/main/panels/outline.tsx"
click node_codeblock "https://github.com/nestmold/notratlatexplugin/blob/main/panels/code-renderer.tsx"
click node_preview "https://github.com/nestmold/notratlatexplugin/blob/main/server/preview-core.js"
click node_docmodel "https://github.com/nestmold/notratlatexplugin/blob/main/server/docmodel.js"
click node_wysiwyg "https://github.com/nestmold/notratlatexplugin/blob/main/server/wysiwyg.js"
click node_txlog "https://github.com/nestmold/notratlatexplugin/blob/main/server/txlog.js"
click node_mcp "https://github.com/nestmold/notratlatexplugin/blob/main/server/index.js"
click node_contrib "https://github.com/nestmold/notratlatexplugin/blob/main/server/contrib.js"
click node_engineinstall "https://github.com/nestmold/notratlatexplugin/blob/main/server/engine-install.js"
click node_compiler "https://github.com/nestmold/notratlatexplugin/blob/main/server/index.js"
click node_exporter "https://github.com/nestmold/notratlatexplugin/blob/main/server/export-html.js"
click node_raster "https://github.com/nestmold/notratlatexplugin/blob/main/server/pdf-raster.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_editor,node_panel,node_outline,node_codeblock toneBlue
class node_preview,node_docmodel,node_wysiwyg,node_txlog,node_texfiles toneAmber
class node_mcp,node_contrib,node_engineinstall toneMint
class node_compiler,node_exporter,node_raster toneRose
class node_user,node_host,node_engine toneIndigo
```

## Components

### Plugin interface

- [Document editor](https://github.com/nestmold/notratlatexplugin/blob/main/panels/editor.tsx): `panels/editor.tsx`
- [Tool panel](https://github.com/nestmold/notratlatexplugin/blob/main/panels/main.tsx): `panels/main.tsx`
- [Outline panel](https://github.com/nestmold/notratlatexplugin/blob/main/panels/outline.tsx): `panels/outline.tsx`
- [LaTeX code blocks](https://github.com/nestmold/notratlatexplugin/blob/main/panels/code-renderer.tsx): `panels/code-renderer.tsx`

### Editing and preview

- [Preview renderer](https://github.com/nestmold/notratlatexplugin/blob/main/server/preview-core.js): `server/preview-core.js`
- [Lossless document model](https://github.com/nestmold/notratlatexplugin/blob/main/server/docmodel.js): `server/docmodel.js`
- [Visual editing core](https://github.com/nestmold/notratlatexplugin/blob/main/server/wysiwyg.js): `server/wysiwyg.js`
- [Transaction history](https://github.com/nestmold/notratlatexplugin/blob/main/server/txlog.js): `server/txlog.js`

### MCP services

- [MCP tool server](https://github.com/nestmold/notratlatexplugin/blob/main/server/index.js): `server/index.js`
- [Shared server utilities](https://github.com/nestmold/notratlatexplugin/blob/main/server/contrib.js): `server/contrib.js`
- [Engine installation](https://github.com/nestmold/notratlatexplugin/blob/main/server/engine-install.js): `server/engine-install.js`

### Compile and export

- [PDF compilation](https://github.com/nestmold/notratlatexplugin/blob/main/server/index.js): `server/index.js`
- [Document export](https://github.com/nestmold/notratlatexplugin/blob/main/server/export-html.js): `server/export-html.js`
- [PDF rasterization](https://github.com/nestmold/notratlatexplugin/blob/main/server/pdf-raster.js): `server/pdf-raster.js`

### Other components

- **LaTeX author**
- **Notrat host**
- **TeX workspace**
- **TeX engine**

## Connections

- LaTeX author → Notrat host: opens document
- Notrat host → Document editor: mounts editor
- Notrat host → Tool panel: mounts tools
- Notrat host → Outline panel: mounts outline
- Notrat host → LaTeX code blocks: renders messages
- Document editor → TeX workspace: edits document
- Document editor → Preview renderer: renders preview
- Document editor → Visual editing core: edits visual blocks
- Document editor → Lossless document model: uses document model
- Document editor → Transaction history: records history
- Document editor → MCP tool server: requests assets
- Outline panel → MCP tool server: requests outline
- Tool panel → MCP tool server: calls tools
- LaTeX code blocks → MCP tool server: loads KaTeX assets
- MCP tool server → TeX workspace: reads and writes files
- MCP tool server → Shared server utilities: uses utilities
- MCP tool server → PDF compilation: dispatches compile
- MCP tool server → Document export: dispatches export
- MCP tool server → PDF rasterization: requests rasterization
- PDF compilation → TeX engine: runs compiler
- PDF compilation → TeX workspace: reads source
- Document export → TeX workspace: reads source and assets
- Document export → PDF compilation: produces PDF
- PDF rasterization → TeX engine: uses raster tools
- Engine installation → TeX engine: installs engine
