# charmbracelet/glow architecture

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

## Overview

Glow is a terminal Markdown reader with two principal routes: CLI rendering/paging and an interactive browser for local Markdown files. In the CLI, arguments become readable sources, which are rendered and displayed; the TUI discovers local files, lets users browse them, and opens documents in its pager. GitHub/GitLab README lookup, configuration, styling, and terminal text sizing are additional capabilities. The excerpts show key entry points and UI behavior; unsampled source limits some internal wiring, so undocumented links are omitted.

Main entry points: [`main.go`](https://github.com/charmbracelet/glow/blob/main/main.go) (CLI workflow), [`ui/ui.go`](https://github.com/charmbracelet/glow/blob/main/ui/ui.go) (TUI coordinator), [`url.go`](https://github.com/charmbracelet/glow/blob/main/url.go) (README URL lookup), [`utils/utils.go`](https://github.com/charmbracelet/glow/blob/main/utils/utils.go) (Render utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI Reading"]
  node_cli["CLI workflow<br/>[main.go]"]
  node_source["Source loading<br/>[main.go]"]
  node_config["Configuration command<br/>[config_cmd.go]"]
end

subgraph group_remote["Remote Sources"]
  node_url["README URL lookup<br/>[url.go]"]
  node_github["GitHub README fetch<br/>[github.go]"]
  node_gitlab["GitLab README fetch<br/>[gitlab.go]"]
end

subgraph group_tui["Interactive Browser"]
  node_browser["TUI coordinator<br/>[ui.go]"]
  node_discovery["Local file discovery<br/>[ui.go]"]
  node_library["Document browser<br/>[stash.go]"]
  node_pager["Document pager<br/>[pager.go]"]
  node_pager_help["Pager controls<br/>[stashhelp.go]"]
end

subgraph group_presentation["Rendering &amp; Presentation"]
  node_render["Markdown rendering<br/>[main.go]"]
  node_format["Render utilities<br/>[utils.go]"]
  node_textsize["Terminal text sizing<br/>[textsize.go]"]
  node_ui_styles["Terminal UI styles<br/>[styles.go]"]
  node_style_config["Style command<br/>[style.go]"]
end

node_user(("Reader"))
node_http["HTTP services"]
node_external_pager["Configured pager"]

node_user -->|"provides input"| node_cli
node_cli -->|"loads source"| node_source
node_source -->|"resolves README"| node_url
node_url -->|"routes lookup"| node_github
node_url -->|"routes lookup"| node_gitlab
node_github -->|"requests README"| node_http
node_gitlab -->|"requests README"| node_http
node_cli -->|"renders document"| node_render
node_cli -->|"runs pager"| node_external_pager
node_cli -->|"starts browser"| node_browser
node_cli -->|"offers config"| node_config
node_user -->|"browses files"| node_browser
node_browser -->|"searches locally"| node_discovery
node_browser -->|"updates browser"| node_library
node_browser -->|"coordinates pager"| node_pager
node_pager -->|"uses utilities"| node_format
node_cli -->|"formats code"| node_format
node_cli -->|"sizes output"| node_textsize
node_format -->|"marks headings"| node_textsize
node_browser -->|"creates styles"| node_ui_styles
node_cli -.->|"supports style options"| node_style_config
node_library -.->|"shows help"| node_pager_help

click node_cli "https://github.com/charmbracelet/glow/blob/main/main.go"
click node_source "https://github.com/charmbracelet/glow/blob/main/main.go"
click node_config "https://github.com/charmbracelet/glow/blob/main/config_cmd.go"
click node_url "https://github.com/charmbracelet/glow/blob/main/url.go"
click node_github "https://github.com/charmbracelet/glow/blob/main/github.go"
click node_gitlab "https://github.com/charmbracelet/glow/blob/main/gitlab.go"
click node_browser "https://github.com/charmbracelet/glow/blob/main/ui/ui.go"
click node_discovery "https://github.com/charmbracelet/glow/blob/main/ui/ui.go"
click node_library "https://github.com/charmbracelet/glow/blob/main/ui/stash.go"
click node_pager "https://github.com/charmbracelet/glow/blob/main/ui/pager.go"
click node_pager_help "https://github.com/charmbracelet/glow/blob/main/ui/stashhelp.go"
click node_render "https://github.com/charmbracelet/glow/blob/main/main.go"
click node_format "https://github.com/charmbracelet/glow/blob/main/utils/utils.go"
click node_textsize "https://github.com/charmbracelet/glow/blob/main/utils/textsize.go"
click node_ui_styles "https://github.com/charmbracelet/glow/blob/main/ui/styles.go"
click node_style_config "https://github.com/charmbracelet/glow/blob/main/style.go"

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_cli,node_source,node_config toneBlue
class node_url,node_github,node_gitlab toneAmber
class node_browser,node_discovery,node_library,node_pager,node_pager_help toneMint
class node_render,node_format,node_textsize,node_ui_styles,node_style_config toneRose
class node_user,node_http,node_external_pager toneIndigo
```

## Components

### CLI Reading

- [CLI workflow](https://github.com/charmbracelet/glow/blob/main/main.go): `main.go`
- [Source loading](https://github.com/charmbracelet/glow/blob/main/main.go): `main.go`
- [Configuration command](https://github.com/charmbracelet/glow/blob/main/config_cmd.go): `config_cmd.go`

### Remote Sources

- [README URL lookup](https://github.com/charmbracelet/glow/blob/main/url.go): `url.go`
- [GitHub README fetch](https://github.com/charmbracelet/glow/blob/main/github.go): `github.go`
- [GitLab README fetch](https://github.com/charmbracelet/glow/blob/main/gitlab.go): `gitlab.go`

### Interactive Browser

- [TUI coordinator](https://github.com/charmbracelet/glow/blob/main/ui/ui.go): `ui/ui.go`
- [Local file discovery](https://github.com/charmbracelet/glow/blob/main/ui/ui.go): `ui/ui.go`
- [Document browser](https://github.com/charmbracelet/glow/blob/main/ui/stash.go): `ui/stash.go`
- [Document pager](https://github.com/charmbracelet/glow/blob/main/ui/pager.go): `ui/pager.go`
- [Pager controls](https://github.com/charmbracelet/glow/blob/main/ui/stashhelp.go): `ui/stashhelp.go`

### Rendering & Presentation

- [Markdown rendering](https://github.com/charmbracelet/glow/blob/main/main.go): `main.go`
- [Render utilities](https://github.com/charmbracelet/glow/blob/main/utils/utils.go): `utils/utils.go`
- [Terminal text sizing](https://github.com/charmbracelet/glow/blob/main/utils/textsize.go): `utils/textsize.go`
- [Terminal UI styles](https://github.com/charmbracelet/glow/blob/main/ui/styles.go): `ui/styles.go`
- [Style command](https://github.com/charmbracelet/glow/blob/main/style.go): `style.go`

### Other components

- **Reader**
- **HTTP services**
- **Configured pager**

## Connections

- Reader → CLI workflow: provides input (evidence: `README.md`)
- CLI workflow → Source loading: loads source (evidence: `main.go`)
- Source loading → README URL lookup: resolves README (evidence: `README.md`)
- README URL lookup → GitHub README fetch: routes lookup (evidence: `url.go`)
- README URL lookup → GitLab README fetch: routes lookup (evidence: `url.go`)
- GitHub README fetch → HTTP services: requests README (evidence: `github.go`)
- GitLab README fetch → HTTP services: requests README (evidence: `gitlab.go`)
- CLI workflow → Markdown rendering: renders document (evidence: `main.go`)
- CLI workflow → Configured pager: runs pager (evidence: `README.md`)
- CLI workflow → TUI coordinator: starts browser (evidence: `main.go`)
- CLI workflow → Configuration command: offers config (evidence: `main.go`)
- Reader → TUI coordinator: browses files (evidence: `README.md`)
- TUI coordinator → Local file discovery: searches locally (evidence: `ui/ui.go`)
- TUI coordinator → Document browser: updates browser (evidence: `ui/ui.go`)
- TUI coordinator → Document pager: coordinates pager (evidence: `ui/ui.go`)
- Document pager → Render utilities: uses utilities (evidence: `ui/pager.go`)
- CLI workflow → Render utilities: formats code (evidence: `main.go`)
- CLI workflow → Terminal text sizing: sizes output (evidence: `main.go`)
- Render utilities → Terminal text sizing: marks headings (evidence: `utils/utils.go`)
- TUI coordinator → Terminal UI styles: creates styles (evidence: `ui/ui.go`)
- CLI workflow → Style command: supports style options
- Document browser → Pager controls: shows help
