# emilk/egui architecture

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

- Interactive diagram: https://gitdiagram.com/emilk/egui
- Repository: https://github.com/emilk/egui

## Overview

egui is a portable immediate-mode Rust GUI stack, with eframe providing app runtimes for native and web targets. The typical flow is app code building UI each frame, egui handling interaction and state, epaint shaping text and tessellating shapes, then a backend presenting output. The workspace also provides layout/math and color foundations, optional image and table extensions, inspection, and UI testing. Edges below are limited to README statements or visible module references/calls; several unsampled backend details are represented by their exact source directories.

Main entry points: [`crates/egui/src/context.rs`](https://github.com/emilk/egui/blob/main/crates/egui/src/context.rs) (UI context), [`crates/epaint/src/text/text_layout.rs`](https://github.com/emilk/egui/blob/main/crates/epaint/src/text/text_layout.rs) (Shapes and text), [`crates/eframe/src/lib.rs`](https://github.com/emilk/egui/blob/main/crates/eframe/src/lib.rs) (App framework), [`crates/eframe/src/native`](https://github.com/emilk/egui/tree/main/crates/eframe/src/native) (Native runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Immediate UI"]
  node_egui["UI context<br/>[context.rs]"]
  node_widgets["Widgets"]
  node_containers["Layout containers"]
  node_response["Interaction response<br/>[response.rs]"]
  node_input["Input model"]
end

subgraph group_render["Paint and Render"]
  node_epaint["Shapes and text<br/>[text_layout.rs]"]
  node_tessellator["Mesh tessellation<br/>[tessellator.rs]"]
  node_glow["Glow renderer<br/>[painter.rs]"]
  node_wgpu["WGPU renderer<br/>[renderer.rs]"]
end

subgraph group_runtime["App Runtimes"]
  node_eframe["App framework<br/>[lib.rs]"]
  node_native["Native runtime"]
  node_web["Web runtime<br/>[app_runner.rs]"]
  node_winit["Native input<br/>[lib.rs]"]
  node_webinput["Browser input<br/>[events.rs]"]
  node_storage[("Web persistence<br/>[storage.rs]")]
end

subgraph group_extensions["Extensions"]
  node_extras["Images and tables"]
  node_inspection["UI inspection<br/>[plugin.rs]"]
  node_kittest["UI harness<br/>[lib.rs]"]
end

subgraph group_foundations["Core Foundations"]
  node_math["2D math<br/>[rect.rs]"]
  node_colors["Color types<br/>[color32.rs]"]
end

node_user(("App developer"))
node_actor(("End user"))

node_user -.->|"starts app"| node_eframe
node_user -->|"builds UI"| node_egui
node_eframe -.->|"runs natively"| node_native
node_eframe -.->|"runs on web"| node_web
node_web -->|"persists memory"| node_storage
node_winit -->|"translates events"| node_input
node_webinput -.->|"supplies events"| node_input
node_eframe -.->|"calls app UI"| node_egui
node_egui -.->|"builds widgets"| node_widgets
node_egui -.->|"organizes UI"| node_containers
node_widgets -->|"reports interaction"| node_response
node_input -.->|"drives interaction"| node_egui
node_egui -.->|"produces shapes"| node_epaint
node_epaint -->|"tessellates shapes"| node_tessellator
node_native -.->|"handles platform"| node_winit
node_native -.->|"renders frames"| node_wgpu
node_web -.->|"renders frames"| node_wgpu
node_native -.->|"renders frames"| node_glow
node_web -.->|"renders frames"| node_glow
node_epaint -.->|"supports images"| node_extras
node_egui -.->|"exposes state"| node_inspection
node_kittest -->|"runs UI frames"| node_egui
node_egui -.->|"uses geometry"| node_math
node_epaint -.->|"uses colors"| node_colors
node_wgpu -.->|"presents UI"| node_actor
node_glow -.->|"presents UI"| node_actor

click node_egui "https://github.com/emilk/egui/blob/main/crates/egui/src/context.rs"
click node_widgets "https://github.com/emilk/egui/tree/main/crates/egui/src/widgets"
click node_containers "https://github.com/emilk/egui/tree/main/crates/egui/src/containers"
click node_response "https://github.com/emilk/egui/blob/main/crates/egui/src/response.rs"
click node_input "https://github.com/emilk/egui/tree/main/crates/egui/src/data/input"
click node_epaint "https://github.com/emilk/egui/blob/main/crates/epaint/src/text/text_layout.rs"
click node_tessellator "https://github.com/emilk/egui/blob/main/crates/epaint/src/tessellator.rs"
click node_glow "https://github.com/emilk/egui/blob/main/crates/egui_glow/src/painter.rs"
click node_wgpu "https://github.com/emilk/egui/blob/main/crates/egui-wgpu/src/renderer.rs"
click node_eframe "https://github.com/emilk/egui/blob/main/crates/eframe/src/lib.rs"
click node_native "https://github.com/emilk/egui/tree/main/crates/eframe/src/native"
click node_web "https://github.com/emilk/egui/blob/main/crates/eframe/src/web/app_runner.rs"
click node_winit "https://github.com/emilk/egui/blob/main/crates/egui-winit/src/lib.rs"
click node_webinput "https://github.com/emilk/egui/blob/main/crates/eframe/src/web/events.rs"
click node_storage "https://github.com/emilk/egui/blob/main/crates/eframe/src/web/storage.rs"
click node_extras "https://github.com/emilk/egui/tree/main/crates/egui_extras/src"
click node_inspection "https://github.com/emilk/egui/blob/main/crates/egui_inspection/src/plugin.rs"
click node_kittest "https://github.com/emilk/egui/blob/main/crates/egui_kittest/src/lib.rs"
click node_math "https://github.com/emilk/egui/blob/main/crates/emath/src/rect.rs"
click node_colors "https://github.com/emilk/egui/blob/main/crates/ecolor/src/color32.rs"

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_egui,node_widgets,node_containers,node_response,node_input,node_actor toneBlue
class node_epaint,node_tessellator,node_glow,node_wgpu toneAmber
class node_eframe,node_native,node_web,node_winit,node_webinput,node_storage toneMint
class node_extras,node_inspection,node_kittest toneRose
class node_math,node_colors,node_user toneIndigo
```

## Components

### Immediate UI

- [UI context](https://github.com/emilk/egui/blob/main/crates/egui/src/context.rs): `crates/egui/src/context.rs`
- [Widgets](https://github.com/emilk/egui/tree/main/crates/egui/src/widgets): `crates/egui/src/widgets`
- [Layout containers](https://github.com/emilk/egui/tree/main/crates/egui/src/containers): `crates/egui/src/containers`
- [Interaction response](https://github.com/emilk/egui/blob/main/crates/egui/src/response.rs): `crates/egui/src/response.rs`
- [Input model](https://github.com/emilk/egui/tree/main/crates/egui/src/data/input): `crates/egui/src/data/input`

### Paint and Render

- [Shapes and text](https://github.com/emilk/egui/blob/main/crates/epaint/src/text/text_layout.rs): `crates/epaint/src/text/text_layout.rs`
- [Mesh tessellation](https://github.com/emilk/egui/blob/main/crates/epaint/src/tessellator.rs): `crates/epaint/src/tessellator.rs`
- [Glow renderer](https://github.com/emilk/egui/blob/main/crates/egui_glow/src/painter.rs): `crates/egui_glow/src/painter.rs`
- [WGPU renderer](https://github.com/emilk/egui/blob/main/crates/egui-wgpu/src/renderer.rs): `crates/egui-wgpu/src/renderer.rs`

### App Runtimes

- [App framework](https://github.com/emilk/egui/blob/main/crates/eframe/src/lib.rs): `crates/eframe/src/lib.rs`
- [Native runtime](https://github.com/emilk/egui/tree/main/crates/eframe/src/native): `crates/eframe/src/native`
- [Web runtime](https://github.com/emilk/egui/blob/main/crates/eframe/src/web/app_runner.rs): `crates/eframe/src/web/app_runner.rs`
- [Native input](https://github.com/emilk/egui/blob/main/crates/egui-winit/src/lib.rs): `crates/egui-winit/src/lib.rs`
- [Browser input](https://github.com/emilk/egui/blob/main/crates/eframe/src/web/events.rs): `crates/eframe/src/web/events.rs`
- [Web persistence](https://github.com/emilk/egui/blob/main/crates/eframe/src/web/storage.rs): `crates/eframe/src/web/storage.rs`

### Extensions

- [Images and tables](https://github.com/emilk/egui/tree/main/crates/egui_extras/src): `crates/egui_extras/src`
- [UI inspection](https://github.com/emilk/egui/blob/main/crates/egui_inspection/src/plugin.rs): `crates/egui_inspection/src/plugin.rs`
- [UI harness](https://github.com/emilk/egui/blob/main/crates/egui_kittest/src/lib.rs): `crates/egui_kittest/src/lib.rs`

### Core Foundations

- [2D math](https://github.com/emilk/egui/blob/main/crates/emath/src/rect.rs): `crates/emath/src/rect.rs`
- [Color types](https://github.com/emilk/egui/blob/main/crates/ecolor/src/color32.rs): `crates/ecolor/src/color32.rs`

### Other components

- **App developer**
- **End user**

## Connections

- App developer → App framework: starts app (evidence: `README.md`)
- App developer → UI context: builds UI (evidence: `README.md`)
- App framework → Native runtime: runs natively (evidence: `README.md`)
- App framework → Web runtime: runs on web (evidence: `README.md`)
- Web runtime → Web persistence: persists memory (evidence: `crates/eframe/src/web/storage.rs`)
- Native input → Input model: translates events (evidence: `crates/egui-winit/src/lib.rs`)
- Browser input → Input model: supplies events
- App framework → UI context: calls app UI (evidence: `README.md`)
- UI context → Widgets: builds widgets (evidence: `README.md`)
- UI context → Layout containers: organizes UI (evidence: `README.md`)
- Widgets → Interaction response: reports interaction (evidence: `crates/egui/src/widgets/drag_value.rs`)
- Input model → UI context: drives interaction (evidence: `README.md`)
- UI context → Shapes and text: produces shapes (evidence: `README.md`)
- Shapes and text → Mesh tessellation: tessellates shapes (evidence: `crates/epaint/src/tessellator.rs`)
- Native runtime → Native input: handles platform
- Native runtime → WGPU renderer: renders frames (evidence: `README.md`)
- Web runtime → WGPU renderer: renders frames
- Native runtime → Glow renderer: renders frames
- Web runtime → Glow renderer: renders frames
- Shapes and text → Images and tables: supports images (evidence: `README.md`)
- UI context → UI inspection: exposes state
- UI harness → UI context: runs UI frames (evidence: `crates/egui_kittest/src/lib.rs`)
- UI context → 2D math: uses geometry
- Shapes and text → Color types: uses colors
- WGPU renderer → End user: presents UI (evidence: `README.md`)
- Glow renderer → End user: presents UI (evidence: `README.md`)
