# mustache/mustache-sinatra architecture

> Architecture diagram of the GitHub repository mustache/mustache-sinatra, 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/mustache-sinatra
- Repository: https://github.com/mustache/mustache-sinatra

## Overview

Mustache::Sinatra integrates Mustache rendering into Sinatra. A Sinatra route calls the installed `mustache` helper, which resolves or compiles a view class, renders it, and optionally wraps the result in a layout. The README also documents direct Mustache subclasses and template-only fallback. Runtime behavior is concentrated in the helper module; templates, view classes, Sinatra, and Mustache itself are supplied by the host application or dependencies.

Main entry points: [`lib/mustache/sinatra/helpers.rb`](https://github.com/mustache/mustache-sinatra/blob/master/lib/mustache/sinatra/helpers.rb) (Render helper), [`lib/mustache/sinatra.rb`](https://github.com/mustache/mustache-sinatra/blob/master/lib/mustache/sinatra.rb) (Extension registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Sinatra integration"]
  node_extension["Extension registration<br/>[sinatra.rb]"]
  node_helper["Render helper<br/>[helpers.rb]"]
end

subgraph group_rendering["Mustache rendering"]
  node_resolver["View resolution<br/>[helpers.rb]"]
  node_view_classes["View classes"]
  node_templates["Mustache templates"]
  node_engine["Mustache engine"]
end

node_app["Sinatra app"]

node_app -->|"registers"| node_extension
node_extension -->|"installs helpers"| node_app
node_app -->|"calls helper"| node_helper
node_helper -->|"resolves view"| node_resolver
node_resolver -->|"looks up"| node_view_classes
node_helper -->|"renders view"| node_engine
node_helper -->|"renders layout"| node_engine
node_engine -->|"renders from"| node_templates

click node_extension "https://github.com/mustache/mustache-sinatra/blob/master/lib/mustache/sinatra.rb"
click node_helper "https://github.com/mustache/mustache-sinatra/blob/master/lib/mustache/sinatra/helpers.rb"
click node_resolver "https://github.com/mustache/mustache-sinatra/blob/master/lib/mustache/sinatra/helpers.rb"

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_helper toneBlue
class node_resolver,node_view_classes,node_templates,node_engine toneAmber
class node_app toneIndigo
```

## Components

### Sinatra integration

- [Extension registration](https://github.com/mustache/mustache-sinatra/blob/master/lib/mustache/sinatra.rb): `lib/mustache/sinatra.rb`
- [Render helper](https://github.com/mustache/mustache-sinatra/blob/master/lib/mustache/sinatra/helpers.rb): `lib/mustache/sinatra/helpers.rb`

### Mustache rendering

- [View resolution](https://github.com/mustache/mustache-sinatra/blob/master/lib/mustache/sinatra/helpers.rb): `lib/mustache/sinatra/helpers.rb`
- **View classes**
- **Mustache templates**
- **Mustache engine**

### Other components

- **Sinatra app**

## Connections

- Sinatra app → Extension registration: registers (evidence: `README.md`)
- Extension registration → Sinatra app: installs helpers (evidence: `lib/mustache/sinatra.rb`)
- Sinatra app → Render helper: calls helper (evidence: `README.md`)
- Render helper → View resolution: resolves view (evidence: `lib/mustache/sinatra/helpers.rb`)
- View resolution → View classes: looks up (evidence: `lib/mustache/sinatra/helpers.rb`)
- Render helper → Mustache engine: renders view (evidence: `lib/mustache/sinatra/helpers.rb`)
- Render helper → Mustache engine: renders layout (evidence: `lib/mustache/sinatra/helpers.rb`)
- Mustache engine → Mustache templates: renders from (evidence: `README.md`)
