# abir1905/attention-explorer architecture

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

- Interactive diagram: https://gitdiagram.com/abir1905/attention-explorer
- Repository: https://github.com/abir1905/attention-explorer

## Overview

Attention Explorer is a browser-based educational visualizer and a small reusable JavaScript attention library. A learner adjusts dimension, scaling, causal masking, and seed controls; the controller samples Q, K, and V, obtains attention scores, weights, and outputs, then presents the distribution as a heatmap and query-row chart. The core module implements scaled dot-product attention and stable softmax; the controller also has a reference fallback. The README documents the UI capabilities and module roles; some controller-to-renderer wiring is not shown in the excerpts, so those edges cite the README.

Main entry points: [`app.js`](https://github.com/abir1905/attention-explorer/blob/main/app.js) (UI controller), [`index.html`](https://github.com/abir1905/attention-explorer/blob/main/index.html) (Visualizer page), [`attention.js`](https://github.com/abir1905/attention-explorer/blob/main/attention.js) (Attention API), [`style.css`](https://github.com/abir1905/attention-explorer/blob/main/style.css) (Visual styling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Interactive interface"]
  node_page["Visualizer page<br/>[index.html]"]
  node_controller["UI controller<br/>[app.js]"]
end

subgraph group_calculation["Attention calculation"]
  node_sampling["Seeded sampling<br/>[app.js]"]
  node_core["Attention API<br/>[attention.js]"]
  node_fallback["Reference calculation<br/>[app.js]"]
end

subgraph group_presentation["Visualization"]
  node_heatmap["Attention heatmap<br/>[app.js]"]
  node_inspector["Query row chart<br/>[app.js]"]
  node_styles["Visual styling<br/>[style.css]"]
end

node_learner(("Learner"))

node_learner -->|"explores"| node_page
node_page -->|"hosts"| node_controller
node_controller -->|"samples QKV"| node_sampling
node_controller -->|"calls attention"| node_core
node_controller -->|"falls back"| node_fallback
node_controller -->|"renders weights"| node_heatmap
node_controller -->|"renders selected row"| node_inspector
node_page -->|"styled by"| node_styles

click node_page "https://github.com/abir1905/attention-explorer/blob/main/index.html"
click node_controller "https://github.com/abir1905/attention-explorer/blob/main/app.js"
click node_sampling "https://github.com/abir1905/attention-explorer/blob/main/app.js"
click node_core "https://github.com/abir1905/attention-explorer/blob/main/attention.js"
click node_fallback "https://github.com/abir1905/attention-explorer/blob/main/app.js"
click node_heatmap "https://github.com/abir1905/attention-explorer/blob/main/app.js"
click node_inspector "https://github.com/abir1905/attention-explorer/blob/main/app.js"
click node_styles "https://github.com/abir1905/attention-explorer/blob/main/style.css"

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_page,node_controller toneBlue
class node_sampling,node_core,node_fallback toneAmber
class node_heatmap,node_inspector,node_styles toneMint
class node_learner toneIndigo
```

## Components

### Interactive interface

- [Visualizer page](https://github.com/abir1905/attention-explorer/blob/main/index.html): `index.html`
- [UI controller](https://github.com/abir1905/attention-explorer/blob/main/app.js): `app.js`

### Attention calculation

- [Seeded sampling](https://github.com/abir1905/attention-explorer/blob/main/app.js): `app.js`
- [Attention API](https://github.com/abir1905/attention-explorer/blob/main/attention.js): `attention.js`
- [Reference calculation](https://github.com/abir1905/attention-explorer/blob/main/app.js): `app.js`

### Visualization

- [Attention heatmap](https://github.com/abir1905/attention-explorer/blob/main/app.js): `app.js`
- [Query row chart](https://github.com/abir1905/attention-explorer/blob/main/app.js): `app.js`
- [Visual styling](https://github.com/abir1905/attention-explorer/blob/main/style.css): `style.css`

### Other components

- **Learner**

## Connections

- Learner → Visualizer page: explores (evidence: `README.md`)
- Visualizer page → UI controller: hosts (evidence: `README.md`)
- UI controller → Seeded sampling: samples QKV (evidence: `app.js`)
- UI controller → Attention API: calls attention (evidence: `app.js`)
- UI controller → Reference calculation: falls back (evidence: `app.js`)
- UI controller → Attention heatmap: renders weights (evidence: `README.md`)
- UI controller → Query row chart: renders selected row (evidence: `README.md`)
- Visualizer page → Visual styling: styled by (evidence: `README.md`)
