# artisticat1/obsidian-tikzjax architecture

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

- Interactive diagram: https://gitdiagram.com/artisticat1/obsidian-tikzjax
- Repository: https://github.com/artisticat1/obsidian-tikzjax

## Overview

Obsidian TikZJax turns `tikz` code blocks in notes into rendered diagrams. The plugin registers a Markdown processor, cleans the block source, and inserts it for the TikZJax runtime; completed SVGs are then optionally recolored for dark mode and optimized. Settings control recoloring and expose SVG-cache clearing. The README documents supported diagram packages and cached renders. TikZJax internals were not sampled, so runtime-to-cache behavior is shown only as documented, not as inspected implementation.

Main entry points: [`tikzjax.js`](https://github.com/artisticat1/obsidian-tikzjax/blob/main/tikzjax.js) (TikZJax runtime), [`main.ts`](https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts) (SVG post-processing), [`settings.ts`](https://github.com/artisticat1/obsidian-tikzjax/blob/main/settings.ts) (Plugin settings), [`svgo.browser.js`](https://github.com/artisticat1/obsidian-tikzjax/blob/main/svgo.browser.js) (SVG optimization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_obsidian["Obsidian integration"]
  node_obsidian["Obsidian host"]
  node_block["TikZ block processor<br/>[main.ts]"]
  node_source["Source cleanup<br/>[main.ts]"]
  node_windows["Window lifecycle<br/>[main.ts]"]
end

subgraph group_render["Diagram rendering"]
  node_runtime["TikZJax runtime<br/>[tikzjax.js]"]
  node_packages["TikZ packages"]
  node_svg["Rendered SVG<br/>[tikzjax.js]"]
  node_postprocess["SVG post-processing<br/>[main.ts]"]
  node_color["Dark-mode colors<br/>[main.ts]"]
  node_svgo["SVG optimization<br/>[svgo.browser.js]"]
end

subgraph group_settings["Settings and cache"]
  node_settingsui["Plugin settings<br/>[settings.ts]"]
  node_settingsdata[("Saved settings<br/>[main.ts]")]
  node_cache[("SVG cache<br/>[settings.ts]")]
end

node_author(("Note author"))

node_author -->|"writes block"| node_block
node_obsidian -->|"dispatches block"| node_block
node_block -->|"cleans source"| node_source
node_source -->|"inserts script"| node_runtime
node_obsidian -->|"opens windows"| node_windows
node_windows -->|"loads runtime"| node_runtime
node_runtime -->|"supports packages"| node_packages
node_runtime -->|"renders diagrams"| node_svg
node_runtime -.->|"signals completion"| node_postprocess
node_postprocess -->|"optionally recolors"| node_color
node_postprocess -->|"optimizes with"| node_svgo
node_settingsui -->|"saves settings"| node_settingsdata
node_postprocess -->|"reads preference"| node_settingsdata
node_settingsui -->|"clears cache"| node_cache
node_runtime -.->|"stores renders"| node_cache

click node_block "https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts"
click node_source "https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts"
click node_windows "https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts"
click node_runtime "https://github.com/artisticat1/obsidian-tikzjax/blob/main/tikzjax.js"
click node_svg "https://github.com/artisticat1/obsidian-tikzjax/blob/main/tikzjax.js"
click node_postprocess "https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts"
click node_color "https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts"
click node_svgo "https://github.com/artisticat1/obsidian-tikzjax/blob/main/svgo.browser.js"
click node_settingsui "https://github.com/artisticat1/obsidian-tikzjax/blob/main/settings.ts"
click node_settingsdata "https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts"
click node_cache "https://github.com/artisticat1/obsidian-tikzjax/blob/main/settings.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_obsidian,node_block,node_source,node_windows toneBlue
class node_runtime,node_packages,node_svg,node_postprocess,node_color,node_svgo toneAmber
class node_settingsui,node_settingsdata,node_cache toneMint
class node_author toneIndigo
```

## Components

### Obsidian integration

- **Obsidian host**
- [TikZ block processor](https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts): `main.ts`
- [Source cleanup](https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts): `main.ts`
- [Window lifecycle](https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts): `main.ts`

### Diagram rendering

- [TikZJax runtime](https://github.com/artisticat1/obsidian-tikzjax/blob/main/tikzjax.js): `tikzjax.js`
- **TikZ packages**
- [Rendered SVG](https://github.com/artisticat1/obsidian-tikzjax/blob/main/tikzjax.js): `tikzjax.js`
- [SVG post-processing](https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts): `main.ts`
- [Dark-mode colors](https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts): `main.ts`
- [SVG optimization](https://github.com/artisticat1/obsidian-tikzjax/blob/main/svgo.browser.js): `svgo.browser.js`

### Settings and cache

- [Plugin settings](https://github.com/artisticat1/obsidian-tikzjax/blob/main/settings.ts): `settings.ts`
- [Saved settings](https://github.com/artisticat1/obsidian-tikzjax/blob/main/main.ts): `main.ts`
- [SVG cache](https://github.com/artisticat1/obsidian-tikzjax/blob/main/settings.ts): `settings.ts`

### Other components

- **Note author**

## Connections

- Note author → TikZ block processor: writes block (evidence: `README.md`)
- Obsidian host → TikZ block processor: dispatches block (evidence: `main.ts`)
- TikZ block processor → Source cleanup: cleans source (evidence: `main.ts`)
- Source cleanup → TikZJax runtime: inserts script (evidence: `main.ts`)
- Obsidian host → Window lifecycle: opens windows (evidence: `main.ts`)
- Window lifecycle → TikZJax runtime: loads runtime (evidence: `main.ts`)
- TikZJax runtime → TikZ packages: supports packages (evidence: `README.md`)
- TikZJax runtime → Rendered SVG: renders diagrams (evidence: `README.md`)
- TikZJax runtime → SVG post-processing: signals completion
- SVG post-processing → Dark-mode colors: optionally recolors (evidence: `main.ts`)
- SVG post-processing → SVG optimization: optimizes with (evidence: `main.ts`)
- Plugin settings → Saved settings: saves settings (evidence: `main.ts`)
- SVG post-processing → Saved settings: reads preference (evidence: `main.ts`)
- Plugin settings → SVG cache: clears cache (evidence: `settings.ts`)
- TikZJax runtime → SVG cache: stores renders (evidence: `README.md`)
