# aadityasalgarkar/md_render architecture

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

- Interactive diagram: https://gitdiagram.com/aadityasalgarkar/md_render
- Repository: https://github.com/aadityasalgarkar/md_render

## Overview

MD_RENDER is a book-style Markdown reader/editor for desktop and browser use, with an MCP interface for agents. The main workflow opens local or remote documents, renders them with reading and review features, and optionally serves the same experience over HTTP. The graph includes documented extensions such as experiment plots and TikZ. Some connections are based on README descriptions or SOURCE INDEX references rather than inspected implementation, so those edges cite that evidence rather than implying deeper source inspection.

Main entry points: [`src/components/Preview.tsx`](https://github.com/aadityasalgarkar/md_render/blob/main/src/components/Preview.tsx) (Markdown preview), [`src/App.tsx`](https://github.com/aadityasalgarkar/md_render/blob/main/src/App.tsx) (Reader application), [`src-tauri/src/server.rs`](https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/server.rs) (HTTP server), [`src/lib/backend.ts`](https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/backend.ts) (Desktop and server bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_reader["Reader experience"]
  node_app["Reader application<br/>[App.tsx]"]
  node_themes["Theme registry<br/>[themes.ts]"]
  node_index["Document index"]
  node_editor["Split-pane editor<br/>[Editor.tsx]"]
  node_comments["Review comments<br/>[comments.ts]"]
end

subgraph group_render["Document rendering"]
  node_preview["Markdown preview<br/>[Preview.tsx]"]
  node_math["Math rendering<br/>[math.ts]"]
  node_mermaid["Mermaid diagrams<br/>[MermaidDiagram.tsx]"]
  node_quiz["Quiz blocks<br/>[Quiz.tsx]"]
  node_plots["Experiment plots<br/>[ExperimentPlot.tsx]"]
  node_plotdata["Plot parsing and views<br/>[schema.ts]"]
  node_tikzui["TikZ diagram display<br/>[TikzDiagram.tsx]"]
end

subgraph group_runtime["Runtime services"]
  node_cli["Command-line entry<br/>[cli.rs]"]
  node_backend["Desktop and server bridge<br/>[backend.ts]"]
  node_http["HTTP server<br/>[server.rs]"]
  node_documents[("Open-document state<br/>[state.rs]")]
  node_experimentservice["Experiment data service<br/>[experiments.rs]"]
  node_tikzservice["TikZ compilation<br/>[tikz.rs]"]
end

subgraph group_agent["MCP tools"]
  node_mcp["MCP tool registry<br/>[index.ts]"]
  node_mcptools["Document and view tools<br/>[documents.ts]"]
  node_mcpservers["Server management tools<br/>[servers.ts]"]
  node_mcpclient["Typed server client<br/>[client.ts]"]
end

node_user(("Reader or author"))
node_agentactor(("Agent"))

node_user -->|"opens documents"| node_cli
node_cli -->|"starts server"| node_http
node_http -->|"serves open files"| node_documents
node_app -->|"uses backend"| node_backend
node_http -->|"serves reader"| node_app
node_user -->|"reads and edits"| node_app
node_app -->|"renders document"| node_preview
node_app -->|"provides editing"| node_editor
node_app -->|"selects theme"| node_themes
node_app -->|"attaches comments"| node_comments
node_preview -->|"builds heading index"| node_index
node_preview -->|"normalizes math"| node_math
node_preview -->|"renders diagrams"| node_mermaid
node_preview -->|"renders quiz blocks"| node_quiz
node_preview -->|"renders plot blocks"| node_plots
node_plots -->|"parses and derives views"| node_plotdata
node_plots -->|"requests experiment data"| node_backend
node_backend -->|"calls API"| node_http
node_http -->|"serves experiment data"| node_experimentservice
node_preview -->|"renders TikZ blocks"| node_tikzui
node_tikzui -->|"requests compilation"| node_backend
node_backend -->|"compiles diagrams"| node_tikzservice
node_agentactor -->|"uses tools"| node_mcp
node_mcp -->|"registers tools"| node_mcptools
node_mcp -->|"registers tools"| node_mcpservers
node_mcptools -->|"calls server client"| node_mcpclient
node_mcpservers -.->|"uses client"| node_mcpclient
node_mcpclient -->|"sends API requests"| node_http
node_agentactor -.->|"authors plot blocks"| node_plots

click node_cli "https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/cli.rs"
click node_app "https://github.com/aadityasalgarkar/md_render/blob/main/src/App.tsx"
click node_backend "https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/backend.ts"
click node_http "https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/server.rs"
click node_documents "https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/state.rs"
click node_preview "https://github.com/aadityasalgarkar/md_render/blob/main/src/components/Preview.tsx"
click node_themes "https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/themes.ts"
click node_index "https://github.com/aadityasalgarkar/md_render/blob/main/src/components/TableOfContents.tsx"
click node_editor "https://github.com/aadityasalgarkar/md_render/blob/main/src/components/Editor.tsx"
click node_comments "https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/comments.ts"
click node_math "https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/math.ts"
click node_mermaid "https://github.com/aadityasalgarkar/md_render/blob/main/src/components/MermaidDiagram.tsx"
click node_quiz "https://github.com/aadityasalgarkar/md_render/blob/main/src/components/Quiz.tsx"
click node_plots "https://github.com/aadityasalgarkar/md_render/blob/main/src/components/ExperimentPlot.tsx"
click node_plotdata "https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/plots/schema.ts"
click node_experimentservice "https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/experiments.rs"
click node_tikzui "https://github.com/aadityasalgarkar/md_render/blob/main/src/components/TikzDiagram.tsx"
click node_tikzservice "https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/tikz.rs"
click node_mcp "https://github.com/aadityasalgarkar/md_render/blob/main/mcp/src/index.ts"
click node_mcptools "https://github.com/aadityasalgarkar/md_render/blob/main/mcp/src/tools/documents.ts"
click node_mcpservers "https://github.com/aadityasalgarkar/md_render/blob/main/mcp/src/tools/servers.ts"
click node_mcpclient "https://github.com/aadityasalgarkar/md_render/blob/main/mcp/src/client.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_app,node_themes,node_index,node_editor,node_comments toneBlue
class node_preview,node_math,node_mermaid,node_quiz,node_plots,node_plotdata,node_tikzui toneAmber
class node_cli,node_backend,node_http,node_documents,node_experimentservice,node_tikzservice toneMint
class node_mcp,node_mcptools,node_mcpservers,node_mcpclient toneRose
class node_user,node_agentactor toneIndigo
```

## Components

### Reader experience

- [Reader application](https://github.com/aadityasalgarkar/md_render/blob/main/src/App.tsx): `src/App.tsx`
- [Theme registry](https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/themes.ts): `src/lib/themes.ts`
- [Document index](https://github.com/aadityasalgarkar/md_render/blob/main/src/components/TableOfContents.tsx): `src/components/TableOfContents.tsx`
- [Split-pane editor](https://github.com/aadityasalgarkar/md_render/blob/main/src/components/Editor.tsx): `src/components/Editor.tsx`
- [Review comments](https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/comments.ts): `src/lib/comments.ts`

### Document rendering

- [Markdown preview](https://github.com/aadityasalgarkar/md_render/blob/main/src/components/Preview.tsx): `src/components/Preview.tsx`
- [Math rendering](https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/math.ts): `src/lib/math.ts`
- [Mermaid diagrams](https://github.com/aadityasalgarkar/md_render/blob/main/src/components/MermaidDiagram.tsx): `src/components/MermaidDiagram.tsx`
- [Quiz blocks](https://github.com/aadityasalgarkar/md_render/blob/main/src/components/Quiz.tsx): `src/components/Quiz.tsx`
- [Experiment plots](https://github.com/aadityasalgarkar/md_render/blob/main/src/components/ExperimentPlot.tsx): `src/components/ExperimentPlot.tsx`
- [Plot parsing and views](https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/plots/schema.ts): `src/lib/plots/schema.ts`
- [TikZ diagram display](https://github.com/aadityasalgarkar/md_render/blob/main/src/components/TikzDiagram.tsx): `src/components/TikzDiagram.tsx`

### Runtime services

- [Command-line entry](https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/cli.rs): `src-tauri/src/cli.rs`
- [Desktop and server bridge](https://github.com/aadityasalgarkar/md_render/blob/main/src/lib/backend.ts): `src/lib/backend.ts`
- [HTTP server](https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/server.rs): `src-tauri/src/server.rs`
- [Open-document state](https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/state.rs): `src-tauri/src/state.rs`
- [Experiment data service](https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/experiments.rs): `src-tauri/src/experiments.rs`
- [TikZ compilation](https://github.com/aadityasalgarkar/md_render/blob/main/src-tauri/src/tikz.rs): `src-tauri/src/tikz.rs`

### MCP tools

- [MCP tool registry](https://github.com/aadityasalgarkar/md_render/blob/main/mcp/src/index.ts): `mcp/src/index.ts`
- [Document and view tools](https://github.com/aadityasalgarkar/md_render/blob/main/mcp/src/tools/documents.ts): `mcp/src/tools/documents.ts`
- [Server management tools](https://github.com/aadityasalgarkar/md_render/blob/main/mcp/src/tools/servers.ts): `mcp/src/tools/servers.ts`
- [Typed server client](https://github.com/aadityasalgarkar/md_render/blob/main/mcp/src/client.ts): `mcp/src/client.ts`

### Other components

- **Reader or author**
- **Agent**

## Connections

- Reader or author → Command-line entry: opens documents
- Command-line entry → HTTP server: starts server (evidence: `src-tauri/src/cli.rs`)
- HTTP server → Open-document state: serves open files (evidence: `src-tauri/src/server.rs`)
- Reader application → Desktop and server bridge: uses backend (evidence: `src/App.tsx`)
- HTTP server → Reader application: serves reader (evidence: `src-tauri/src/server.rs`)
- Reader or author → Reader application: reads and edits
- Reader application → Markdown preview: renders document (evidence: `src/App.tsx`)
- Reader application → Split-pane editor: provides editing (evidence: `src/App.tsx`)
- Reader application → Theme registry: selects theme (evidence: `src/App.tsx`)
- Reader application → Review comments: attaches comments (evidence: `src/App.tsx`)
- Markdown preview → Document index: builds heading index (evidence: `src/components/Preview.tsx`)
- Markdown preview → Math rendering: normalizes math (evidence: `src/components/Preview.tsx`)
- Markdown preview → Mermaid diagrams: renders diagrams (evidence: `src/components/Preview.tsx`)
- Markdown preview → Quiz blocks: renders quiz blocks (evidence: `src/components/Preview.tsx`)
- Markdown preview → Experiment plots: renders plot blocks (evidence: `src/components/Preview.tsx`)
- Experiment plots → Plot parsing and views: parses and derives views (evidence: `src/components/ExperimentPlot.tsx`)
- Experiment plots → Desktop and server bridge: requests experiment data (evidence: `src/lib/backend.ts`)
- Desktop and server bridge → HTTP server: calls API (evidence: `src/lib/backend.ts`)
- HTTP server → Experiment data service: serves experiment data (evidence: `src-tauri/src/server.rs`)
- Markdown preview → TikZ diagram display: renders TikZ blocks (evidence: `src/components/Preview.tsx`)
- TikZ diagram display → Desktop and server bridge: requests compilation (evidence: `src/lib/backend.ts`)
- Desktop and server bridge → TikZ compilation: compiles diagrams (evidence: `src/lib/backend.ts`)
- Agent → MCP tool registry: uses tools
- MCP tool registry → Document and view tools: registers tools (evidence: `mcp/src/index.ts`)
- MCP tool registry → Server management tools: registers tools (evidence: `mcp/src/index.ts`)
- Document and view tools → Typed server client: calls server client (evidence: `mcp/src/tools/documents.ts`)
- Server management tools → Typed server client: uses client
- Typed server client → HTTP server: sends API requests (evidence: `mcp/src/client.ts`)
- Agent → Experiment plots: authors plot blocks
