# aristocratos/btop architecture

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

## Overview

btop++ is an interactive terminal system-resource monitor. Its principal workflow is to start the monitor, collect platform-specific CPU, memory, disk, network, process and GPU statistics, and present them in configurable terminal panels; users interact through keyboard input and menus. The graph preserves the documented Linux GPU capability and platform-specific collectors. Several links are dashed because the sampled material identifies modules and capabilities but does not show the corresponding runtime calls.

Main entry points: [`src/btop.cpp`](https://github.com/aristocratos/btop/blob/main/src/btop.cpp) (Monitor runtime), [`src/osx/btop_collect.cpp`](https://github.com/aristocratos/btop/blob/main/src/osx/btop_collect.cpp) (macOS stats), [`src/main.cpp`](https://github.com/aristocratos/btop/blob/main/src/main.cpp) (Program entry), [`src/btop_menu.cpp`](https://github.com/aristocratos/btop/blob/main/src/btop_menu.cpp) (Menus)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Application runtime"]
  node_main["Program entry<br/>[main.cpp]"]
  node_app["Monitor runtime<br/>[btop.cpp]"]
  node_cli["CLI options<br/>[btop_cli.cpp]"]
  node_config["Configuration<br/>[btop_config.cpp]"]
end

subgraph group_ui["Terminal interface"]
  node_input["Input handling<br/>[btop_input.cpp]"]
  node_menu["Menus<br/>[btop_menu.cpp]"]
  node_draw["Panel rendering<br/>[btop_draw.cpp]"]
  node_theme["Themes<br/>[btop_theme.cpp]"]
end

subgraph group_platform["Platform monitoring"]
  node_collector_linux["Linux stats<br/>[btop_collect.cpp]"]
  node_collector_freebsd["FreeBSD stats<br/>[btop_collect.cpp]"]
  node_collector_netbsd["NetBSD stats<br/>[btop_collect.cpp]"]
  node_collector_openbsd["OpenBSD stats<br/>[btop_collect.cpp]"]
  node_collector_osx["macOS stats<br/>[btop_collect.cpp]"]
  node_gpu["Intel GPU support<br/>[intel_gpu_top.c]"]
  node_osx_sensors["macOS sensors<br/>[sensors.cpp]"]
  node_osx_smc["Apple SMC<br/>[smc.cpp]"]
  node_drm["DRM interfaces<br/>[drm.h]"]
end

subgraph group_support["Shared support"]
  node_shared["Shared state<br/>[btop_shared.cpp]"]
  node_tools["Terminal utilities<br/>[btop_tools.cpp]"]
  node_logger["Logging<br/>[btop_log.cpp]"]
  node_format["fmt formatting<br/>[format.h]"]
  node_widechar["Unicode widths<br/>[widechar_width.hpp]"]
end

node_user(("Monitor user"))

node_user -.->|"starts monitor"| node_main
node_main -.->|"enters runtime"| node_app
node_app -.->|"handles options"| node_cli
node_app -.->|"collects stats"| node_collector_linux
node_app -.->|"collects stats"| node_collector_freebsd
node_app -.->|"collects stats"| node_collector_netbsd
node_app -.->|"collects stats"| node_collector_openbsd
node_app -.->|"collects stats"| node_collector_osx
node_collector_linux -.->|"uses GPU support"| node_gpu
node_app -.->|"uses settings"| node_config
node_app -.->|"handles input"| node_input
node_app -.->|"renders panels"| node_draw
node_app -.->|"opens menus"| node_menu
node_menu -.->|"edits settings"| node_config
node_draw -.->|"uses theme"| node_theme
node_app -.->|"uses shared state"| node_shared
node_app -.->|"uses utilities"| node_tools
node_app -.->|"logs events"| node_logger
node_collector_osx -.->|"uses sensors"| node_osx_sensors
node_collector_osx -.->|"uses SMC"| node_osx_smc
node_tools -.->|"uses widths"| node_widechar
node_format --> node_drm

click node_main "https://github.com/aristocratos/btop/blob/main/src/main.cpp"
click node_app "https://github.com/aristocratos/btop/blob/main/src/btop.cpp"
click node_cli "https://github.com/aristocratos/btop/blob/main/src/btop_cli.cpp"
click node_collector_linux "https://github.com/aristocratos/btop/blob/main/src/linux/btop_collect.cpp"
click node_collector_freebsd "https://github.com/aristocratos/btop/blob/main/src/freebsd/btop_collect.cpp"
click node_collector_netbsd "https://github.com/aristocratos/btop/blob/main/src/netbsd/btop_collect.cpp"
click node_collector_openbsd "https://github.com/aristocratos/btop/blob/main/src/openbsd/btop_collect.cpp"
click node_collector_osx "https://github.com/aristocratos/btop/blob/main/src/osx/btop_collect.cpp"
click node_gpu "https://github.com/aristocratos/btop/blob/main/src/linux/intel_gpu_top/intel_gpu_top.c"
click node_config "https://github.com/aristocratos/btop/blob/main/src/btop_config.cpp"
click node_input "https://github.com/aristocratos/btop/blob/main/src/btop_input.cpp"
click node_menu "https://github.com/aristocratos/btop/blob/main/src/btop_menu.cpp"
click node_draw "https://github.com/aristocratos/btop/blob/main/src/btop_draw.cpp"
click node_theme "https://github.com/aristocratos/btop/blob/main/src/btop_theme.cpp"
click node_shared "https://github.com/aristocratos/btop/blob/main/src/btop_shared.cpp"
click node_tools "https://github.com/aristocratos/btop/blob/main/src/btop_tools.cpp"
click node_logger "https://github.com/aristocratos/btop/blob/main/src/btop_log.cpp"
click node_osx_sensors "https://github.com/aristocratos/btop/blob/main/src/osx/sensors.cpp"
click node_osx_smc "https://github.com/aristocratos/btop/blob/main/src/osx/smc.cpp"
click node_format "https://github.com/aristocratos/btop/blob/main/include/fmt/format.h"
click node_widechar "https://github.com/aristocratos/btop/blob/main/include/widechar_width.hpp"
click node_drm "https://github.com/aristocratos/btop/blob/main/src/linux/intel_gpu_top/drm.h"

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_main,node_app,node_cli,node_config,node_user toneBlue
class node_input,node_menu,node_draw,node_theme toneAmber
class node_collector_linux,node_collector_freebsd,node_collector_netbsd,node_collector_openbsd,node_collector_osx,node_gpu,node_osx_sensors,node_osx_smc,node_drm toneMint
class node_shared,node_tools,node_logger,node_format,node_widechar toneRose
```

## Components

### Application runtime

- [Program entry](https://github.com/aristocratos/btop/blob/main/src/main.cpp): `src/main.cpp`
- [Monitor runtime](https://github.com/aristocratos/btop/blob/main/src/btop.cpp): `src/btop.cpp`
- [CLI options](https://github.com/aristocratos/btop/blob/main/src/btop_cli.cpp): `src/btop_cli.cpp`
- [Configuration](https://github.com/aristocratos/btop/blob/main/src/btop_config.cpp): `src/btop_config.cpp`

### Terminal interface

- [Input handling](https://github.com/aristocratos/btop/blob/main/src/btop_input.cpp): `src/btop_input.cpp`
- [Menus](https://github.com/aristocratos/btop/blob/main/src/btop_menu.cpp): `src/btop_menu.cpp`
- [Panel rendering](https://github.com/aristocratos/btop/blob/main/src/btop_draw.cpp): `src/btop_draw.cpp`
- [Themes](https://github.com/aristocratos/btop/blob/main/src/btop_theme.cpp): `src/btop_theme.cpp`

### Platform monitoring

- [Linux stats](https://github.com/aristocratos/btop/blob/main/src/linux/btop_collect.cpp): `src/linux/btop_collect.cpp`
- [FreeBSD stats](https://github.com/aristocratos/btop/blob/main/src/freebsd/btop_collect.cpp): `src/freebsd/btop_collect.cpp`
- [NetBSD stats](https://github.com/aristocratos/btop/blob/main/src/netbsd/btop_collect.cpp): `src/netbsd/btop_collect.cpp`
- [OpenBSD stats](https://github.com/aristocratos/btop/blob/main/src/openbsd/btop_collect.cpp): `src/openbsd/btop_collect.cpp`
- [macOS stats](https://github.com/aristocratos/btop/blob/main/src/osx/btop_collect.cpp): `src/osx/btop_collect.cpp`
- [Intel GPU support](https://github.com/aristocratos/btop/blob/main/src/linux/intel_gpu_top/intel_gpu_top.c): `src/linux/intel_gpu_top/intel_gpu_top.c`
- [macOS sensors](https://github.com/aristocratos/btop/blob/main/src/osx/sensors.cpp): `src/osx/sensors.cpp`
- [Apple SMC](https://github.com/aristocratos/btop/blob/main/src/osx/smc.cpp): `src/osx/smc.cpp`
- [DRM interfaces](https://github.com/aristocratos/btop/blob/main/src/linux/intel_gpu_top/drm.h): `src/linux/intel_gpu_top/drm.h`

### Shared support

- [Shared state](https://github.com/aristocratos/btop/blob/main/src/btop_shared.cpp): `src/btop_shared.cpp`
- [Terminal utilities](https://github.com/aristocratos/btop/blob/main/src/btop_tools.cpp): `src/btop_tools.cpp`
- [Logging](https://github.com/aristocratos/btop/blob/main/src/btop_log.cpp): `src/btop_log.cpp`
- [fmt formatting](https://github.com/aristocratos/btop/blob/main/include/fmt/format.h): `include/fmt/format.h`
- [Unicode widths](https://github.com/aristocratos/btop/blob/main/include/widechar_width.hpp): `include/widechar_width.hpp`

### Other components

- **Monitor user**

## Connections

- Monitor user → Program entry: starts monitor (evidence: `README.md`)
- Program entry → Monitor runtime: enters runtime
- Monitor runtime → CLI options: handles options (evidence: `src/btop.cpp`)
- Monitor runtime → Linux stats: collects stats
- Monitor runtime → FreeBSD stats: collects stats
- Monitor runtime → NetBSD stats: collects stats
- Monitor runtime → OpenBSD stats: collects stats
- Monitor runtime → macOS stats: collects stats
- Linux stats → Intel GPU support: uses GPU support (evidence: `src/linux/btop_collect.cpp`)
- Monitor runtime → Configuration: uses settings (evidence: `src/btop.cpp`)
- Monitor runtime → Input handling: handles input (evidence: `src/btop.cpp`)
- Monitor runtime → Panel rendering: renders panels (evidence: `src/btop.cpp`)
- Monitor runtime → Menus: opens menus (evidence: `src/btop.cpp`)
- Menus → Configuration: edits settings (evidence: `src/btop_menu.cpp`)
- Panel rendering → Themes: uses theme (evidence: `src/btop_draw.cpp`)
- Monitor runtime → Shared state: uses shared state (evidence: `src/btop.cpp`)
- Monitor runtime → Terminal utilities: uses utilities (evidence: `src/btop.cpp`)
- Monitor runtime → Logging: logs events (evidence: `src/btop.cpp`)
- macOS stats → macOS sensors: uses sensors (evidence: `src/osx/btop_collect.cpp`)
- macOS stats → Apple SMC: uses SMC (evidence: `src/osx/btop_collect.cpp`)
- Terminal utilities → Unicode widths: uses widths (evidence: `src/btop_tools.cpp`)
- fmt formatting → DRM interfaces
