# mustache/rack-bug-mustache_panel architecture

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

- Interactive diagram: https://gitdiagram.com/mustache/rack-bug-mustache_panel
- Repository: https://github.com/mustache/rack-bug-mustache_panel

## Overview

Rack::Bug::MustachePanel instruments Mustache rendering to collect per-view render times and accessed variables, then presents them in a Rack::Bug panel. The excerpts show the instrumentation, thread-local state, panel view, and configured template; they do not show how applications register or invoke the panel.

Main entry points: [`lib/rack/bug/panels/mustache_panel/mustache_extension.rb`](https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel/mustache_extension.rb) (Render Instrumentation), [`lib/rack/bug/panels/mustache_panel.rb`](https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel.rb) (Mustache Panel), [`lib/rack/bug/panels/mustache_panel/view.mustache`](https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel/view.mustache) (Panel Template)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_instrumentation["Mustache Instrumentation"]
  node_extension["Render Instrumentation"]
  node_state["Thread-local Metrics<br/>[mustache_panel.rb]"]
end

subgraph group_panel["Panel Output"]
  node_panel["Mustache Panel<br/>[mustache_panel.rb]"]
  node_view["Panel View<br/>[mustache_panel.rb]"]
  node_template["Panel Template<br/>[view.mustache]"]
end

node_app(("Application"))
node_mustache["Mustache Engine"]

node_app -.->|"renders views"| node_mustache
node_extension -->|"wraps rendering"| node_mustache
node_extension -->|"records metrics"| node_state
node_panel -->|"reads and resets"| node_state
node_panel -->|"renders"| node_view
node_view -->|"uses template"| node_template

click node_extension "https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel/mustache_extension.rb"
click node_state "https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel.rb"
click node_panel "https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel.rb"
click node_view "https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel.rb"
click node_template "https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel/view.mustache"

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_extension,node_state toneBlue
class node_panel,node_view,node_template toneAmber
class node_app,node_mustache toneIndigo
```

## Components

### Mustache Instrumentation

- [Render Instrumentation](https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel/mustache_extension.rb): `lib/rack/bug/panels/mustache_panel/mustache_extension.rb`
- [Thread-local Metrics](https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel.rb): `lib/rack/bug/panels/mustache_panel.rb`

### Panel Output

- [Mustache Panel](https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel.rb): `lib/rack/bug/panels/mustache_panel.rb`
- [Panel View](https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel.rb): `lib/rack/bug/panels/mustache_panel.rb`
- [Panel Template](https://github.com/mustache/rack-bug-mustache_panel/blob/master/lib/rack/bug/panels/mustache_panel/view.mustache): `lib/rack/bug/panels/mustache_panel/view.mustache`

### Other components

- **Application**
- **Mustache Engine**

## Connections

- Application → Mustache Engine: renders views
- Render Instrumentation → Mustache Engine: wraps rendering (evidence: `lib/rack/bug/panels/mustache_panel/mustache_extension.rb`)
- Render Instrumentation → Thread-local Metrics: records metrics (evidence: `lib/rack/bug/panels/mustache_panel/mustache_extension.rb`)
- Mustache Panel → Thread-local Metrics: reads and resets (evidence: `lib/rack/bug/panels/mustache_panel.rb`)
- Mustache Panel → Panel View: renders (evidence: `lib/rack/bug/panels/mustache_panel.rb`)
- Panel View → Panel Template: uses template (evidence: `lib/rack/bug/panels/mustache_panel.rb`)
