# elshadhu/systui architecture

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

- Interactive diagram: https://gitdiagram.com/elshadhu/systui
- Repository: https://github.com/elshadhu/systui
- Video tour (about a minute): https://gitdiagram.com/elshadhu/systui/video

## Overview

systui is a cross-platform terminal monitor. Its main loop refreshes system metrics and process samples, groups processes into apps, updates history and list state, then renders the selected view and status lines. The graph preserves the documented Apps, Lifetime and Overview capabilities, plus process grouping, insights and platform-specific metrics. Edges are limited to sampled calls/import references and README-described behavior; unsampled implementation details and some internal view wiring are omitted.

Main entry points: [`ui/model.go`](https://github.com/elshadhu/systui/blob/main/ui/model.go) (Refresh and view model), [`ui/appsView.go`](https://github.com/elshadhu/systui/blob/main/ui/appsView.go) (Apps and Lifetime views), [`internal/apps/group.go`](https://github.com/elshadhu/systui/blob/main/internal/apps/group.go) (App grouping and sorting), [`ui/topbar.go`](https://github.com/elshadhu/systui/blob/main/ui/topbar.go) (Status and insight lines)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and UI"]
  node_entry["Program entry<br/>[main.go]"]
  node_model["Refresh and view model<br/>[model.go]"]
  node_theme["Color themes<br/>[theme.go]"]
end

subgraph group_processes["Process Monitoring"]
  node_process_sampler["Process sampler<br/>[sampler.go]"]
  node_process_details["Process details and usage"]
  node_app_groups["App grouping and sorting<br/>[group.go]"]
  node_app_roles["Helper process roles<br/>[role.go]"]
  node_app_history["App metric history<br/>[history.go]"]
end

subgraph group_system["System Metrics"]
  node_cpu_metrics["CPU metrics<br/>[cpu.go]"]
  node_memory_metrics["Memory and pressure<br/>[mem.go]"]
end

subgraph group_presentation["Views and Insights"]
  node_insight_logic["Insight ranking<br/>[insight.go]"]
  node_app_state["Expandable app list<br/>[state.go]"]
  node_apps_view["Apps and Lifetime views<br/>[appsView.go]"]
  node_overview_view["Overview panels<br/>[overview.go]"]
  node_status_view["Status and insight lines<br/>[topbar.go]"]
  node_column_layout["Responsive columns<br/>[columns.go]"]
  node_sparkline["Trend rendering<br/>[sparkline.go]"]
  node_draw_primitives["Terminal drawing"]
end

node_user(("Terminal user"))

node_user -->|"runs"| node_entry
node_entry -->|"starts UI"| node_model
node_entry -->|"selects theme"| node_theme
node_model -->|"samples processes"| node_process_sampler
node_app_groups -->|"groups process stats"| node_process_details
node_model -->|"builds groups"| node_app_groups
node_model -->|"reads CPU"| node_cpu_metrics
node_model -->|"reads memory pressure"| node_memory_metrics
node_model -->|"records samples"| node_app_history
node_model -->|"installs groups"| node_app_state
node_model -->|"ranks insights"| node_insight_logic
node_insight_logic -->|"checks app peaks"| node_app_groups
node_insight_logic -->|"checks system pressure"| node_memory_metrics
node_model -->|"renders app tabs"| node_apps_view
node_model -->|"renders overview"| node_overview_view
node_model -->|"renders status lines"| node_status_view
node_apps_view -->|"reads list state"| node_app_state
node_apps_view -->|"renders grouped data"| node_app_groups
node_apps_view -->|"uses layout"| node_column_layout
node_apps_view -->|"draws trends"| node_sparkline
node_overview_view -->|"uses drawing"| node_draw_primitives
node_status_view -->|"shows insights"| node_insight_logic
node_status_view -->|"shows pressure and swap"| node_memory_metrics
node_status_view -->|"fits status fields"| node_draw_primitives
node_sparkline -->|"draws metric history"| node_app_history
node_column_layout -->|"uses column widths"| node_draw_primitives
node_apps_view -->|"formats rows"| node_draw_primitives
node_model -->|"uses selected theme"| node_theme
node_app_groups -.->|"labels helper processes"| node_app_roles

click node_entry "https://github.com/elshadhu/systui/blob/main/main.go"
click node_model "https://github.com/elshadhu/systui/blob/main/ui/model.go"
click node_process_sampler "https://github.com/elshadhu/systui/blob/main/internal/proc/sampler.go"
click node_process_details "https://github.com/elshadhu/systui/tree/main/internal/proc"
click node_app_groups "https://github.com/elshadhu/systui/blob/main/internal/apps/group.go"
click node_app_roles "https://github.com/elshadhu/systui/blob/main/internal/apps/role.go"
click node_app_history "https://github.com/elshadhu/systui/blob/main/internal/apps/history.go"
click node_cpu_metrics "https://github.com/elshadhu/systui/blob/main/internal/metrics/cpu.go"
click node_memory_metrics "https://github.com/elshadhu/systui/blob/main/internal/metrics/mem.go"
click node_insight_logic "https://github.com/elshadhu/systui/blob/main/internal/insight/insight.go"
click node_app_state "https://github.com/elshadhu/systui/blob/main/ui/applist/state.go"
click node_apps_view "https://github.com/elshadhu/systui/blob/main/ui/appsView.go"
click node_overview_view "https://github.com/elshadhu/systui/blob/main/ui/overview.go"
click node_status_view "https://github.com/elshadhu/systui/blob/main/ui/topbar.go"
click node_column_layout "https://github.com/elshadhu/systui/blob/main/ui/columns.go"
click node_sparkline "https://github.com/elshadhu/systui/blob/main/ui/draw/sparkline.go"
click node_draw_primitives "https://github.com/elshadhu/systui/tree/main/ui/draw"
click node_theme "https://github.com/elshadhu/systui/blob/main/ui/theme/theme.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_entry,node_model,node_theme,node_user toneBlue
class node_process_sampler,node_process_details,node_app_groups,node_app_roles,node_app_history toneAmber
class node_cpu_metrics,node_memory_metrics toneMint
class node_insight_logic,node_app_state,node_apps_view,node_overview_view,node_status_view,node_column_layout,node_sparkline,node_draw_primitives toneRose
```

## Components

### Runtime and UI

- [Program entry](https://github.com/elshadhu/systui/blob/main/main.go): `main.go`
- [Refresh and view model](https://github.com/elshadhu/systui/blob/main/ui/model.go): `ui/model.go`
- [Color themes](https://github.com/elshadhu/systui/blob/main/ui/theme/theme.go): `ui/theme/theme.go`

### Process Monitoring

- [Process sampler](https://github.com/elshadhu/systui/blob/main/internal/proc/sampler.go): `internal/proc/sampler.go`
- [Process details and usage](https://github.com/elshadhu/systui/tree/main/internal/proc): `internal/proc`
- [App grouping and sorting](https://github.com/elshadhu/systui/blob/main/internal/apps/group.go): `internal/apps/group.go`
- [Helper process roles](https://github.com/elshadhu/systui/blob/main/internal/apps/role.go): `internal/apps/role.go`
- [App metric history](https://github.com/elshadhu/systui/blob/main/internal/apps/history.go): `internal/apps/history.go`

### System Metrics

- [CPU metrics](https://github.com/elshadhu/systui/blob/main/internal/metrics/cpu.go): `internal/metrics/cpu.go`
- [Memory and pressure](https://github.com/elshadhu/systui/blob/main/internal/metrics/mem.go): `internal/metrics/mem.go`

### Views and Insights

- [Insight ranking](https://github.com/elshadhu/systui/blob/main/internal/insight/insight.go): `internal/insight/insight.go`
- [Expandable app list](https://github.com/elshadhu/systui/blob/main/ui/applist/state.go): `ui/applist/state.go`
- [Apps and Lifetime views](https://github.com/elshadhu/systui/blob/main/ui/appsView.go): `ui/appsView.go`
- [Overview panels](https://github.com/elshadhu/systui/blob/main/ui/overview.go): `ui/overview.go`
- [Status and insight lines](https://github.com/elshadhu/systui/blob/main/ui/topbar.go): `ui/topbar.go`
- [Responsive columns](https://github.com/elshadhu/systui/blob/main/ui/columns.go): `ui/columns.go`
- [Trend rendering](https://github.com/elshadhu/systui/blob/main/ui/draw/sparkline.go): `ui/draw/sparkline.go`
- [Terminal drawing](https://github.com/elshadhu/systui/tree/main/ui/draw): `ui/draw`

### Other components

- **Terminal user**

## Connections

- Terminal user → Program entry: runs
- Program entry → Refresh and view model: starts UI (evidence: `main.go`)
- Program entry → Color themes: selects theme (evidence: `main.go`)
- Refresh and view model → Process sampler: samples processes (evidence: `ui/model.go`)
- App grouping and sorting → Process details and usage: groups process stats (evidence: `internal/apps/group.go`)
- Refresh and view model → App grouping and sorting: builds groups (evidence: `ui/model.go`)
- Refresh and view model → CPU metrics: reads CPU (evidence: `ui/model.go`)
- Refresh and view model → Memory and pressure: reads memory pressure (evidence: `ui/model.go`)
- Refresh and view model → App metric history: records samples (evidence: `ui/model.go`)
- Refresh and view model → Expandable app list: installs groups (evidence: `ui/model.go`)
- Refresh and view model → Insight ranking: ranks insights (evidence: `ui/model.go`)
- Insight ranking → App grouping and sorting: checks app peaks (evidence: `internal/insight/insight.go`)
- Insight ranking → Memory and pressure: checks system pressure (evidence: `internal/insight/insight.go`)
- Refresh and view model → Apps and Lifetime views: renders app tabs (evidence: `ui/model.go`)
- Refresh and view model → Overview panels: renders overview (evidence: `ui/model.go`)
- Refresh and view model → Status and insight lines: renders status lines (evidence: `ui/model.go`)
- Apps and Lifetime views → Expandable app list: reads list state (evidence: `ui/appsView.go`)
- Apps and Lifetime views → App grouping and sorting: renders grouped data (evidence: `ui/appsView.go`)
- Apps and Lifetime views → Responsive columns: uses layout (evidence: `ui/appsView.go`)
- Apps and Lifetime views → Trend rendering: draws trends (evidence: `ui/appsView.go`)
- Overview panels → Terminal drawing: uses drawing (evidence: `ui/overview.go`)
- Status and insight lines → Insight ranking: shows insights (evidence: `ui/topbar.go`)
- Status and insight lines → Memory and pressure: shows pressure and swap (evidence: `ui/topbar.go`)
- Status and insight lines → Terminal drawing: fits status fields (evidence: `ui/topbar.go`)
- Trend rendering → App metric history: draws metric history (evidence: `ui/draw/sparkline.go`)
- Responsive columns → Terminal drawing: uses column widths (evidence: `ui/columns.go`)
- Apps and Lifetime views → Terminal drawing: formats rows (evidence: `ui/appsView.go`)
- Refresh and view model → Color themes: uses selected theme (evidence: `ui/model.go`)
- App grouping and sorting → Helper process roles: labels helper processes
