# menshikovs/termr architecture

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

## Overview

termr is an R framework for building reactive terminal applications, especially data tools and dashboards. Users compose widgets and layouts, attach event handlers and commands, then run an app; the framework renders its screen to a terminal and updates it as input and state change. Data workflows include in-memory and lazy tables, SQL editing, and database exploration. The README also documents workers and static exports. Relationships below follow documented capabilities; source excerpts mainly cover test tooling, so implementation-level links are limited.

Main entry points: [`R/app.R`](https://github.com/menshikovs/termr/blob/main/R/app.R) (App Construction), [`R/datatable-source.R`](https://github.com/menshikovs/termr/blob/main/R/datatable-source.R) (Table Sources), [`R/renderer.R`](https://github.com/menshikovs/termr/blob/main/R/renderer.R) (Screen Renderer), [`R/layout.R`](https://github.com/menshikovs/termr/blob/main/R/layout.R) (Layouts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App Runtime"]
  node_app_api["App Construction<br/>[app.R]"]
  node_events["Events and Commands<br/>[events.R]"]
  node_reactivity["Reactive State<br/>[reactive.R]"]
end

subgraph group_ui["UI Composition"]
  node_layout["Layouts<br/>[layout.R]"]
  node_widgets["Widgets<br/>[widget.R]"]
  node_controls["Controls<br/>[widget-controls.R]"]
end

subgraph group_data["Data Workflows"]
  node_datatable["Data Table<br/>[widget-datatable.R]"]
  node_table_sources["Table Sources<br/>[datatable-source.R]"]
  node_source_query["Query Sources"]
  node_source_sqlite["SQLite Sources"]
  node_sql_editor["SQL Editor<br/>[sql.R]"]
  node_db_explorer["Database Explorer"]
end

subgraph group_render["Rendering and I/O"]
  node_renderer["Screen Renderer<br/>[renderer.R]"]
  node_screen_buffer["Virtual Screen<br/>[screen-buffer.R]"]
  node_terminal["Terminal Drivers<br/>[terminal.R]"]
end

subgraph group_extended["Extended Capabilities"]
  node_workers["Background Workers<br/>[workers.R]"]
  node_export["Static Export<br/>[export.R]"]
end

node_developer(("Application Developer"))
node_dbi["DBI Drivers"]
node_terminal_user(("Terminal User"))

node_developer -->|"composes app"| node_app_api
node_app_api -->|"accepts layout"| node_layout
node_app_api -->|"registers handlers"| node_events
node_app_api -->|"binds state"| node_reactivity
node_layout -->|"arranges widgets"| node_widgets
node_controls -->|"provides controls"| node_widgets
node_app_api -->|"runs app"| node_renderer
node_renderer -->|"updates cells"| node_screen_buffer
node_renderer -->|"writes changes"| node_terminal
node_terminal_user -->|"sends input"| node_terminal
node_datatable -->|"uses sources"| node_table_sources
node_table_sources -->|"supports lazy queries"| node_source_query
node_table_sources -->|"includes SQLite"| node_source_sqlite
node_sql_editor -->|"composes data tools"| node_db_explorer
node_db_explorer -.->|"uses optional drivers"| node_dbi
node_workers -->|"streams progress"| node_terminal_user
node_export -->|"exports snapshots"| node_screen_buffer

click node_app_api "https://github.com/menshikovs/termr/blob/main/R/app.R"
click node_events "https://github.com/menshikovs/termr/blob/main/R/events.R"
click node_reactivity "https://github.com/menshikovs/termr/blob/main/R/reactive.R"
click node_layout "https://github.com/menshikovs/termr/blob/main/R/layout.R"
click node_widgets "https://github.com/menshikovs/termr/blob/main/R/widget.R"
click node_controls "https://github.com/menshikovs/termr/blob/main/R/widget-controls.R"
click node_datatable "https://github.com/menshikovs/termr/blob/main/R/widget-datatable.R"
click node_table_sources "https://github.com/menshikovs/termr/blob/main/R/datatable-source.R"
click node_source_query "https://github.com/menshikovs/termr/blob/main/R/datatable-source-query.R"
click node_source_sqlite "https://github.com/menshikovs/termr/blob/main/R/datatable-source-sqlite.R"
click node_sql_editor "https://github.com/menshikovs/termr/blob/main/R/sql.R"
click node_db_explorer "https://github.com/menshikovs/termr/blob/main/R/database-explorer.R"
click node_renderer "https://github.com/menshikovs/termr/blob/main/R/renderer.R"
click node_screen_buffer "https://github.com/menshikovs/termr/blob/main/R/screen-buffer.R"
click node_terminal "https://github.com/menshikovs/termr/blob/main/R/terminal.R"
click node_workers "https://github.com/menshikovs/termr/blob/main/R/workers.R"
click node_export "https://github.com/menshikovs/termr/blob/main/R/export.R"

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_api,node_events,node_reactivity,node_terminal_user toneBlue
class node_layout,node_widgets,node_controls toneAmber
class node_datatable,node_table_sources,node_source_query,node_source_sqlite,node_sql_editor,node_db_explorer toneMint
class node_renderer,node_screen_buffer,node_terminal toneRose
class node_workers,node_export,node_developer,node_dbi toneIndigo
```

## Components

### App Runtime

- [App Construction](https://github.com/menshikovs/termr/blob/main/R/app.R): `R/app.R`
- [Events and Commands](https://github.com/menshikovs/termr/blob/main/R/events.R): `R/events.R`
- [Reactive State](https://github.com/menshikovs/termr/blob/main/R/reactive.R): `R/reactive.R`

### UI Composition

- [Layouts](https://github.com/menshikovs/termr/blob/main/R/layout.R): `R/layout.R`
- [Widgets](https://github.com/menshikovs/termr/blob/main/R/widget.R): `R/widget.R`
- [Controls](https://github.com/menshikovs/termr/blob/main/R/widget-controls.R): `R/widget-controls.R`

### Data Workflows

- [Data Table](https://github.com/menshikovs/termr/blob/main/R/widget-datatable.R): `R/widget-datatable.R`
- [Table Sources](https://github.com/menshikovs/termr/blob/main/R/datatable-source.R): `R/datatable-source.R`
- [Query Sources](https://github.com/menshikovs/termr/blob/main/R/datatable-source-query.R): `R/datatable-source-query.R`
- [SQLite Sources](https://github.com/menshikovs/termr/blob/main/R/datatable-source-sqlite.R): `R/datatable-source-sqlite.R`
- [SQL Editor](https://github.com/menshikovs/termr/blob/main/R/sql.R): `R/sql.R`
- [Database Explorer](https://github.com/menshikovs/termr/blob/main/R/database-explorer.R): `R/database-explorer.R`

### Rendering and I/O

- [Screen Renderer](https://github.com/menshikovs/termr/blob/main/R/renderer.R): `R/renderer.R`
- [Virtual Screen](https://github.com/menshikovs/termr/blob/main/R/screen-buffer.R): `R/screen-buffer.R`
- [Terminal Drivers](https://github.com/menshikovs/termr/blob/main/R/terminal.R): `R/terminal.R`

### Extended Capabilities

- [Background Workers](https://github.com/menshikovs/termr/blob/main/R/workers.R): `R/workers.R`
- [Static Export](https://github.com/menshikovs/termr/blob/main/R/export.R): `R/export.R`

### Other components

- **Application Developer**
- **DBI Drivers**
- **Terminal User**

## Connections

- Application Developer → App Construction: composes app (evidence: `README.md`)
- App Construction → Layouts: accepts layout (evidence: `README.md`)
- App Construction → Events and Commands: registers handlers (evidence: `README.md`)
- App Construction → Reactive State: binds state (evidence: `README.md`)
- Layouts → Widgets: arranges widgets (evidence: `README.md`)
- Controls → Widgets: provides controls (evidence: `README.md`)
- App Construction → Screen Renderer: runs app (evidence: `README.md`)
- Screen Renderer → Virtual Screen: updates cells (evidence: `README.md`)
- Screen Renderer → Terminal Drivers: writes changes (evidence: `README.md`)
- Terminal User → Terminal Drivers: sends input (evidence: `README.md`)
- Data Table → Table Sources: uses sources (evidence: `README.md`)
- Table Sources → Query Sources: supports lazy queries (evidence: `README.md`)
- Table Sources → SQLite Sources: includes SQLite (evidence: `README.md`)
- SQL Editor → Database Explorer: composes data tools (evidence: `README.md`)
- Database Explorer → DBI Drivers: uses optional drivers (evidence: `README.md`)
- Background Workers → Terminal User: streams progress (evidence: `README.md`)
- Static Export → Virtual Screen: exports snapshots (evidence: `README.md`)
