# njskalski/bernardo architecture

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

- Interactive diagram: https://gitdiagram.com/njskalski/bernardo
- Repository: https://github.com/njskalski/bernardo

## Overview

Bernardo/Gladius contains two products: Bernardo is a terminal UI widget library, while Gladius is a code editor. The map emphasizes Gladius’s user-facing editing and language-service capabilities, with Bernardo’s terminal I/O and widget framework as its internal presentation layer. The README documents editor configuration and LSP-based completion; the source index supports several internal module relationships. Many central UI and startup files were not sampled, so their runtime wiring is not asserted.

Main entry points: [`src/w7e/handler_factory.rs`](https://github.com/njskalski/bernardo/blob/master/src/w7e/handler_factory.rs) (Workspace handlers), [`src/gladius`](https://github.com/njskalski/bernardo/tree/master/src/gladius) (Editor runtime), [`src/text/buffer_state.rs`](https://github.com/njskalski/bernardo/blob/master/src/text/buffer_state.rs) (Buffer state), [`src/w7e/navcomp_provider_lsp.rs`](https://github.com/njskalski/bernardo/blob/master/src/w7e/navcomp_provider_lsp.rs) (Navigation provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Applications"]
  node_gladius["Gladius startup<br/>[main.rs]"]
  node_runtime["Editor runtime"]
  node_configuration["Editor configuration<br/>[config.rs]"]
  node_bernardo_reader["Bernardo reader<br/>[main.rs]"]
end

subgraph group_editing["Editing Core"]
  node_editor_view["Main editor view<br/>[main_view.rs]"]
  node_editor_widget["Editor widget<br/>[editor_widget.rs]"]
  node_text_state["Buffer state<br/>[buffer_state.rs]"]
  node_text_buffer["Text buffer<br/>[text_buffer.rs]"]
  node_cursor["Cursor model<br/>[cursor.rs]"]
  node_filesystem[("Filesystem paths<br/>[path.rs]")]
end

subgraph group_language["Language Services"]
  node_workspace["Workspace handlers<br/>[handler_factory.rs]"]
  node_rust_handler["Rust handler<br/>[handler_rust.rs]"]
  node_cpp_handler["C++ handler<br/>[handler_cpp.rs]"]
  node_lang_ids["Language IDs<br/>[lang_id.rs]"]
  node_navcomp["Navigation provider"]
  node_lsp["LSP client<br/>[lsp_client.rs]"]
end

subgraph group_presentation["Terminal UI"]
  node_terminal_app["Terminal app wrapper<br/>[app.rs]"]
  node_terminal_io["Terminal I/O"]
  node_widget_framework["Widget framework"]
end

node_user(("Editor user"))

node_user -.->|"starts editor"| node_gladius
node_gladius -.->|"starts runtime"| node_runtime
node_runtime -.->|"loads settings"| node_configuration
node_runtime -.->|"shows editor"| node_editor_view
node_runtime -.->|"configures handlers"| node_workspace
node_workspace -->|"loads Rust"| node_rust_handler
node_workspace -->|"loads C++"| node_cpp_handler
node_workspace -->|"constructs provider"| node_navcomp
node_rust_handler -->|"stores provider"| node_navcomp
node_cpp_handler -.->|"stores provider"| node_navcomp
node_workspace -->|"selects language"| node_lang_ids
node_navcomp -.->|"uses LSP client"| node_lsp
node_editor_view -.->|"hosts editor"| node_editor_widget
node_editor_widget -.->|"edits buffer"| node_text_state
node_text_state -->|"uses text model"| node_text_buffer
node_text_state -->|"uses cursors"| node_cursor
node_text_state -->|"accesses files"| node_filesystem
node_user -.->|"runs terminal UI"| node_terminal_app
node_terminal_app -->|"creates input output"| node_terminal_io
node_bernardo_reader -->|"uses widgets"| node_widget_framework

click node_gladius "https://github.com/njskalski/bernardo/blob/master/src/bin/gladius/main.rs"
click node_runtime "https://github.com/njskalski/bernardo/tree/master/src/gladius"
click node_configuration "https://github.com/njskalski/bernardo/blob/master/src/config/config.rs"
click node_workspace "https://github.com/njskalski/bernardo/blob/master/src/w7e/handler_factory.rs"
click node_rust_handler "https://github.com/njskalski/bernardo/blob/master/src/w7e/rust/handler_rust.rs"
click node_cpp_handler "https://github.com/njskalski/bernardo/blob/master/src/w7e/cpp/handler_cpp.rs"
click node_lang_ids "https://github.com/njskalski/bernardo/blob/master/src/tsw/lang_id.rs"
click node_navcomp "https://github.com/njskalski/bernardo/blob/master/src/w7e/navcomp_provider_lsp.rs"
click node_lsp "https://github.com/njskalski/bernardo/blob/master/src/lsp_client/lsp_client.rs"
click node_editor_view "https://github.com/njskalski/bernardo/blob/master/src/widgets/main_view/main_view.rs"
click node_editor_widget "https://github.com/njskalski/bernardo/blob/master/src/widgets/editor_widget/editor_widget.rs"
click node_text_state "https://github.com/njskalski/bernardo/blob/master/src/text/buffer_state.rs"
click node_text_buffer "https://github.com/njskalski/bernardo/blob/master/src/text/text_buffer.rs"
click node_cursor "https://github.com/njskalski/bernardo/blob/master/src/cursor/cursor.rs"
click node_filesystem "https://github.com/njskalski/bernardo/blob/master/src/fs/path.rs"
click node_terminal_app "https://github.com/njskalski/bernardo/blob/master/src/app.rs"
click node_terminal_io "https://github.com/njskalski/bernardo/tree/master/src/io"
click node_widget_framework "https://github.com/njskalski/bernardo/tree/master/src/widget"
click node_bernardo_reader "https://github.com/njskalski/bernardo/blob/master/src/bin/reader/main.rs"

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_gladius,node_runtime,node_configuration,node_bernardo_reader,node_user toneBlue
class node_editor_view,node_editor_widget,node_text_state,node_text_buffer,node_cursor,node_filesystem toneAmber
class node_workspace,node_rust_handler,node_cpp_handler,node_lang_ids,node_navcomp,node_lsp toneMint
class node_terminal_app,node_terminal_io,node_widget_framework toneRose
```

## Components

### Applications

- [Gladius startup](https://github.com/njskalski/bernardo/blob/master/src/bin/gladius/main.rs): `src/bin/gladius/main.rs`
- [Editor runtime](https://github.com/njskalski/bernardo/tree/master/src/gladius): `src/gladius`
- [Editor configuration](https://github.com/njskalski/bernardo/blob/master/src/config/config.rs): `src/config/config.rs`
- [Bernardo reader](https://github.com/njskalski/bernardo/blob/master/src/bin/reader/main.rs): `src/bin/reader/main.rs`

### Editing Core

- [Main editor view](https://github.com/njskalski/bernardo/blob/master/src/widgets/main_view/main_view.rs): `src/widgets/main_view/main_view.rs`
- [Editor widget](https://github.com/njskalski/bernardo/blob/master/src/widgets/editor_widget/editor_widget.rs): `src/widgets/editor_widget/editor_widget.rs`
- [Buffer state](https://github.com/njskalski/bernardo/blob/master/src/text/buffer_state.rs): `src/text/buffer_state.rs`
- [Text buffer](https://github.com/njskalski/bernardo/blob/master/src/text/text_buffer.rs): `src/text/text_buffer.rs`
- [Cursor model](https://github.com/njskalski/bernardo/blob/master/src/cursor/cursor.rs): `src/cursor/cursor.rs`
- [Filesystem paths](https://github.com/njskalski/bernardo/blob/master/src/fs/path.rs): `src/fs/path.rs`

### Language Services

- [Workspace handlers](https://github.com/njskalski/bernardo/blob/master/src/w7e/handler_factory.rs): `src/w7e/handler_factory.rs`
- [Rust handler](https://github.com/njskalski/bernardo/blob/master/src/w7e/rust/handler_rust.rs): `src/w7e/rust/handler_rust.rs`
- [C++ handler](https://github.com/njskalski/bernardo/blob/master/src/w7e/cpp/handler_cpp.rs): `src/w7e/cpp/handler_cpp.rs`
- [Language IDs](https://github.com/njskalski/bernardo/blob/master/src/tsw/lang_id.rs): `src/tsw/lang_id.rs`
- [Navigation provider](https://github.com/njskalski/bernardo/blob/master/src/w7e/navcomp_provider_lsp.rs): `src/w7e/navcomp_provider_lsp.rs`
- [LSP client](https://github.com/njskalski/bernardo/blob/master/src/lsp_client/lsp_client.rs): `src/lsp_client/lsp_client.rs`

### Terminal UI

- [Terminal app wrapper](https://github.com/njskalski/bernardo/blob/master/src/app.rs): `src/app.rs`
- [Terminal I/O](https://github.com/njskalski/bernardo/tree/master/src/io): `src/io`
- [Widget framework](https://github.com/njskalski/bernardo/tree/master/src/widget): `src/widget`

### Other components

- **Editor user**

## Connections

- Editor user → Gladius startup: starts editor (evidence: `README.md`)
- Gladius startup → Editor runtime: starts runtime
- Editor runtime → Editor configuration: loads settings
- Editor runtime → Main editor view: shows editor
- Editor runtime → Workspace handlers: configures handlers
- Workspace handlers → Rust handler: loads Rust (evidence: `src/w7e/handler_factory.rs`)
- Workspace handlers → C++ handler: loads C++ (evidence: `src/w7e/handler_factory.rs`)
- Workspace handlers → Navigation provider: constructs provider (evidence: `src/w7e/handler_factory.rs`)
- Rust handler → Navigation provider: stores provider (evidence: `src/w7e/rust/handler_rust.rs`)
- C++ handler → Navigation provider: stores provider
- Workspace handlers → Language IDs: selects language (evidence: `src/w7e/handler_factory.rs`)
- Navigation provider → LSP client: uses LSP client
- Main editor view → Editor widget: hosts editor
- Editor widget → Buffer state: edits buffer
- Buffer state → Text buffer: uses text model (evidence: `src/text/buffer_state.rs`)
- Buffer state → Cursor model: uses cursors (evidence: `src/text/buffer_state.rs`)
- Buffer state → Filesystem paths: accesses files (evidence: `src/text/buffer_state.rs`)
- Editor user → Terminal app wrapper: runs terminal UI (evidence: `README.md`)
- Terminal app wrapper → Terminal I/O: creates input output (evidence: `src/app.rs`)
- Bernardo reader → Widget framework: uses widgets (evidence: `src/bin/reader/main.rs`)
