# htop-dev/htop architecture

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

- Interactive diagram: https://gitdiagram.com/htop-dev/htop
- Repository: https://github.com/htop-dev/htop

## Overview

htop is a cross-platform interactive process and system monitor. The main workflow samples platform data, presents processes and system meters in a terminal interface, and lets users inspect, configure, and act on processes. The graph combines documented capabilities with the supplied ScreenManager and platform excerpts; several subsystem links are based on the README and tree rather than sampled implementation. Platform-specific collection is represented by Linux files, with other platform implementations also present.

Main entry points: [`ScreenManager.c`](https://github.com/htop-dev/htop/blob/main/ScreenManager.c) (Screen manager), [`Machine.c`](https://github.com/htop-dev/htop/blob/main/Machine.c) (Machine model), [`pcp/Platform.c`](https://github.com/htop-dev/htop/blob/main/pcp/Platform.c) (PCP platform), [`ProcessTable.c`](https://github.com/htop-dev/htop/blob/main/ProcessTable.c) (Process table)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and UI"]
  node_entry["Application entry<br/>[htop.c]"]
  node_screen["Screen manager<br/>[ScreenManager.c]"]
  node_header["System header<br/>[Header.c]"]
  node_meters["System meters<br/>[Meter.c]"]
end

subgraph group_sampling["System sampling"]
  node_machine["Machine model<br/>[Machine.c]"]
  node_platform["Platform collectors<br/>[Platform.c]"]
end

subgraph group_processes["Process monitoring"]
  node_process_table[("Process table<br/>[ProcessTable.c]")]
  node_process["Process model<br/>[Process.c]"]
  node_main_panel["Process list<br/>[MainPanel.c]"]
  node_table["Table and sorting<br/>[Table.c]"]
end

subgraph group_interaction["User interaction"]
  node_actions["Process actions<br/>[Action.c]"]
  node_settings[("Settings<br/>[Settings.c]")]
  node_setup["Setup panels<br/>[MetersPanel.c]"]
  node_screens["Detail screens<br/>[InfoScreen.c]"]
end

subgraph group_extensions["Optional capabilities"]
  node_pcp_platform["PCP platform<br/>[Platform.c]"]
  node_dynamic["Dynamic PCP views<br/>[PCPDynamicScreen.c]"]
  node_backtrace["Backtrace screen<br/>[BacktraceScreen.c]"]
end

node_user(("Terminal user"))
node_os{{"Operating system"}}
node_pcp{{"PCP data source"}}

node_user -->|"starts"| node_entry
node_entry -->|"runs interface"| node_screen
node_screen -->|"updates host"| node_machine
node_machine -->|"collects through"| node_platform
node_platform -->|"reads system data"| node_os
node_machine -->|"updates processes"| node_process_table
node_process_table -->|"maintains records"| node_process
node_screen -->|"displays processes"| node_main_panel
node_main_panel -->|"uses table"| node_table
node_screen -->|"updates and draws"| node_header
node_header -->|"renders meters"| node_meters
node_user -->|"navigates and selects"| node_screen
node_screen -->|"dispatches commands"| node_actions
node_actions -->|"targets processes"| node_process_table
node_screen -->|"reads state"| node_settings
node_screen -->|"opens configuration"| node_setup
node_setup -->|"changes options"| node_settings
node_screen -->|"opens details"| node_screens
node_user -.->|"selects PCP mode"| node_pcp_platform
node_pcp_platform -.->|"fetches metrics"| node_pcp
node_pcp_platform -.->|"provides dynamic views"| node_dynamic
node_user -.->|"requests backtrace"| node_backtrace

click node_entry "https://github.com/htop-dev/htop/blob/main/htop.c"
click node_screen "https://github.com/htop-dev/htop/blob/main/ScreenManager.c"
click node_header "https://github.com/htop-dev/htop/blob/main/Header.c"
click node_meters "https://github.com/htop-dev/htop/blob/main/Meter.c"
click node_machine "https://github.com/htop-dev/htop/blob/main/Machine.c"
click node_platform "https://github.com/htop-dev/htop/blob/main/linux/Platform.c"
click node_process_table "https://github.com/htop-dev/htop/blob/main/ProcessTable.c"
click node_process "https://github.com/htop-dev/htop/blob/main/Process.c"
click node_main_panel "https://github.com/htop-dev/htop/blob/main/MainPanel.c"
click node_table "https://github.com/htop-dev/htop/blob/main/Table.c"
click node_actions "https://github.com/htop-dev/htop/blob/main/Action.c"
click node_settings "https://github.com/htop-dev/htop/blob/main/Settings.c"
click node_setup "https://github.com/htop-dev/htop/blob/main/MetersPanel.c"
click node_screens "https://github.com/htop-dev/htop/blob/main/InfoScreen.c"
click node_pcp_platform "https://github.com/htop-dev/htop/blob/main/pcp/Platform.c"
click node_dynamic "https://github.com/htop-dev/htop/blob/main/pcp/PCPDynamicScreen.c"
click node_backtrace "https://github.com/htop-dev/htop/blob/main/BacktraceScreen.c"

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_screen,node_header,node_meters,node_user toneBlue
class node_machine,node_platform toneAmber
class node_process_table,node_process,node_main_panel,node_table toneMint
class node_actions,node_settings,node_setup,node_screens toneRose
class node_pcp_platform,node_dynamic,node_backtrace,node_os,node_pcp toneIndigo
```

## Components

### Runtime and UI

- [Application entry](https://github.com/htop-dev/htop/blob/main/htop.c): `htop.c`
- [Screen manager](https://github.com/htop-dev/htop/blob/main/ScreenManager.c): `ScreenManager.c`
- [System header](https://github.com/htop-dev/htop/blob/main/Header.c): `Header.c`
- [System meters](https://github.com/htop-dev/htop/blob/main/Meter.c): `Meter.c`

### System sampling

- [Machine model](https://github.com/htop-dev/htop/blob/main/Machine.c): `Machine.c`
- [Platform collectors](https://github.com/htop-dev/htop/blob/main/linux/Platform.c): `linux/Platform.c`

### Process monitoring

- [Process table](https://github.com/htop-dev/htop/blob/main/ProcessTable.c): `ProcessTable.c`
- [Process model](https://github.com/htop-dev/htop/blob/main/Process.c): `Process.c`
- [Process list](https://github.com/htop-dev/htop/blob/main/MainPanel.c): `MainPanel.c`
- [Table and sorting](https://github.com/htop-dev/htop/blob/main/Table.c): `Table.c`

### User interaction

- [Process actions](https://github.com/htop-dev/htop/blob/main/Action.c): `Action.c`
- [Settings](https://github.com/htop-dev/htop/blob/main/Settings.c): `Settings.c`
- [Setup panels](https://github.com/htop-dev/htop/blob/main/MetersPanel.c): `MetersPanel.c`
- [Detail screens](https://github.com/htop-dev/htop/blob/main/InfoScreen.c): `InfoScreen.c`

### Optional capabilities

- [PCP platform](https://github.com/htop-dev/htop/blob/main/pcp/Platform.c): `pcp/Platform.c`
- [Dynamic PCP views](https://github.com/htop-dev/htop/blob/main/pcp/PCPDynamicScreen.c): `pcp/PCPDynamicScreen.c`
- [Backtrace screen](https://github.com/htop-dev/htop/blob/main/BacktraceScreen.c): `BacktraceScreen.c`

### Other components

- **Terminal user**
- **Operating system**
- **PCP data source**

## Connections

- Terminal user → Application entry: starts
- Application entry → Screen manager: runs interface
- Screen manager → Machine model: updates host
- Machine model → Platform collectors: collects through
- Platform collectors → Operating system: reads system data
- Machine model → Process table: updates processes
- Process table → Process model: maintains records
- Screen manager → Process list: displays processes
- Process list → Table and sorting: uses table
- Screen manager → System header: updates and draws
- System header → System meters: renders meters
- Terminal user → Screen manager: navigates and selects
- Screen manager → Process actions: dispatches commands
- Process actions → Process table: targets processes
- Screen manager → Settings: reads state
- Screen manager → Setup panels: opens configuration
- Setup panels → Settings: changes options
- Screen manager → Detail screens: opens details
- Terminal user → PCP platform: selects PCP mode
- PCP platform → PCP data source: fetches metrics
- PCP platform → Dynamic PCP views: provides dynamic views
- Terminal user → Backtrace screen: requests backtrace
