# arthursonzogni/ftxui architecture

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

- Interactive diagram: https://gitdiagram.com/arthursonzogni/ftxui
- Repository: https://github.com/arthursonzogni/ftxui

## Overview

FTXUI is a cross-platform C++ terminal UI library. An application builds interactive components, runs them through an event/task loop, composes their output as DOM elements, and renders cells to the terminal. The README documents layout, styling, drawing, keyboard/mouse interaction, UTF-8, and animation; unsampled implementation details are represented only where the tree or excerpts support them.

Main entry points: [`src/ftxui/component/app.cpp`](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/component/app.cpp) (App Loop), [`include/ftxui/dom/elements.hpp`](https://github.com/arthursonzogni/ftxui/blob/main/include/ftxui/dom/elements.hpp) (DOM Elements), [`src/ftxui/screen/screen.cpp`](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/screen/screen.cpp) (Screen Surface), [`src/ftxui/component`](https://github.com/arthursonzogni/ftxui/tree/main/src/ftxui/component) (Interactive Widgets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_component["Interaction"]
  node_app["App Loop<br/>[app.cpp]"]
  node_widgets["Interactive Widgets"]
  node_events["Events and Input"]
  node_animation["Animation<br/>[animation.cpp]"]
end

subgraph group_dom["UI Composition"]
  node_dom["DOM Elements<br/>[elements.hpp]"]
  node_layout["Layout and Text<br/>[paragraph.cpp]"]
  node_style["Style and Color<br/>[color.cpp]"]
  node_drawing["Canvas Drawing<br/>[canvas.cpp]"]
end

subgraph group_screen["Terminal Rendering"]
  node_screen["Screen Surface<br/>[screen.cpp]"]
  node_cells["Cells and Colors<br/>[cell.hpp]"]
  node_strings["UTF-8 Strings<br/>[string.cpp]"]
end

subgraph group_runtime["Runtime Support"]
  node_tasks["Task Runner<br/>[task_runner.cpp]"]
end

node_developer(("Application Developer"))
node_terminal(("Terminal"))

node_developer -->|"defines UI"| node_widgets
node_developer -->|"starts loop"| node_app
node_app -->|"dispatches events"| node_widgets
node_app -->|"parses input"| node_events
node_app -->|"runs tasks"| node_tasks
node_app -->|"renders elements"| node_dom
node_widgets -->|"produces elements"| node_dom
node_animation -->|"requests frames"| node_app
node_dom -->|"lays out content"| node_layout
node_dom -->|"decorates elements"| node_style
node_dom -->|"draws canvas"| node_drawing
node_app -->|"renders screen"| node_screen
node_screen -->|"uses cells"| node_cells
node_screen -->|"measures strings"| node_strings
node_screen -->|"prints output"| node_terminal
node_terminal -->|"provides input"| node_app

click node_app "https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/component/app.cpp"
click node_widgets "https://github.com/arthursonzogni/ftxui/tree/main/src/ftxui/component"
click node_events "https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/component/terminal_input_parser.cpp"
click node_animation "https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/component/animation.cpp"
click node_tasks "https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/component/task_runner.cpp"
click node_dom "https://github.com/arthursonzogni/ftxui/blob/main/include/ftxui/dom/elements.hpp"
click node_layout "https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/dom/paragraph.cpp"
click node_style "https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/dom/color.cpp"
click node_drawing "https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/dom/canvas.cpp"
click node_screen "https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/screen/screen.cpp"
click node_cells "https://github.com/arthursonzogni/ftxui/blob/main/include/ftxui/screen/cell.hpp"
click node_strings "https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/screen/string.cpp"

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_app,node_widgets,node_events,node_animation toneBlue
class node_dom,node_layout,node_style,node_drawing toneAmber
class node_screen,node_cells,node_strings toneMint
class node_tasks toneRose
class node_developer,node_terminal toneIndigo
```

## Components

### Interaction

- [App Loop](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/component/app.cpp): `src/ftxui/component/app.cpp`
- [Interactive Widgets](https://github.com/arthursonzogni/ftxui/tree/main/src/ftxui/component): `src/ftxui/component`
- [Events and Input](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/component/terminal_input_parser.cpp): `src/ftxui/component/terminal_input_parser.cpp`
- [Animation](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/component/animation.cpp): `src/ftxui/component/animation.cpp`

### UI Composition

- [DOM Elements](https://github.com/arthursonzogni/ftxui/blob/main/include/ftxui/dom/elements.hpp): `include/ftxui/dom/elements.hpp`
- [Layout and Text](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/dom/paragraph.cpp): `src/ftxui/dom/paragraph.cpp`
- [Style and Color](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/dom/color.cpp): `src/ftxui/dom/color.cpp`
- [Canvas Drawing](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/dom/canvas.cpp): `src/ftxui/dom/canvas.cpp`

### Terminal Rendering

- [Screen Surface](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/screen/screen.cpp): `src/ftxui/screen/screen.cpp`
- [Cells and Colors](https://github.com/arthursonzogni/ftxui/blob/main/include/ftxui/screen/cell.hpp): `include/ftxui/screen/cell.hpp`
- [UTF-8 Strings](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/screen/string.cpp): `src/ftxui/screen/string.cpp`

### Runtime Support

- [Task Runner](https://github.com/arthursonzogni/ftxui/blob/main/src/ftxui/component/task_runner.cpp): `src/ftxui/component/task_runner.cpp`

### Other components

- **Application Developer**
- **Terminal**

## Connections

- Application Developer → Interactive Widgets: defines UI
- Application Developer → App Loop: starts loop
- App Loop → Interactive Widgets: dispatches events
- App Loop → Events and Input: parses input
- App Loop → Task Runner: runs tasks
- App Loop → DOM Elements: renders elements
- Interactive Widgets → DOM Elements: produces elements
- Animation → App Loop: requests frames
- DOM Elements → Layout and Text: lays out content
- DOM Elements → Style and Color: decorates elements
- DOM Elements → Canvas Drawing: draws canvas
- App Loop → Screen Surface: renders screen
- Screen Surface → Cells and Colors: uses cells
- Screen Surface → UTF-8 Strings: measures strings
- Screen Surface → Terminal: prints output
- Terminal → App Loop: provides input
