Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Vix Architecture Overview

Vix is a keyboard-friendly terminal IDE built with a clean, modular architecture. This document provides a high-level overview of Vix’s architecture to help new contributors understand how the pieces fit together.

Philosophy

Vix follows several key architectural principles:

  1. Crate-per-feature: Each major feature lives in its own Rust crate
  2. Spec-driven: Every crate has a specification that is the source of truth
  3. Zero unsafe: The entire codebase contains no unsafe Rust code
  4. Terminal-first: Designed to work perfectly in terminals, over SSH, in tmux
  5. Progressive enhancement: Core editing works without LSP, Git, or other features

High-Level Architecture

At run time a key press travels from the terminal (through crossterm) into the App shell, vix-tui, which owns the event loop, the App state and all rendering (ratatui), and calls into the feature crates. The desktop GUIs in gui/ wrap the same App shell instead of a terminal.

Crate layers (checked against cargo metadata)

The build-time picture is a layered dependency graph. A crate’s layer is the longest chain of workspace dependencies below it: layer 0 crates depend on no other workspace crate, and each layer depends only on layers below it. The App shell vix-tui is the single crate at the top: it depends directly on 143 of the 148 member crates under crates/ (the other five, such as vix-civil-date and vix-jupyter-core, it reaches through other crates). The diagram shows the layers with a few well-known crates in each; every arrow is a real direct dependency (“depends on”), not every dependency is drawn.

flowchart TD
    gui["Desktop GUIs in gui/ (a separate workspace)"]
    subgraph L5["Layer 5: App shell (1 crate)"]
        tui["vix-tui"]
    end
    subgraph L4["Layer 4 (2 crates)"]
        script["vix-script"]
        fhir["vix-fhir"]
    end
    subgraph L3["Layer 3: feature hosts (19 crates)"]
        editor["vix-editor"]
        lsp["vix-lsp"]
        dap["vix-dap"]
        git["vix-git"]
        db["vix-db"]
        undo["vix-undo-store"]
        http["vix-http-client"]
    end
    subgraph L2["Layer 2 (9 crates)"]
        settings["vix-settings"]
        authority["vix-authority"]
        session["vix-session"]
        macros["vix-macros"]
    end
    subgraph L1["Layer 1 (54 crates)"]
        core["vix-editor-core"]
        fileops["vix-fileops"]
        theme["vix-theme"]
        menu["vix-menu"]
        palette["vix-palette"]
    end
    subgraph L0["Layer 0: no workspace dependencies (64 crates)"]
        input["vix-input"]
        i18n["vix-i18n"]
        list_state["vix-list-state"]
        encoding["vix-encoding"]
        lsp_core["vix-lsp-core"]
        textops["vix-textops"]
        theme_model["vix-theme-model"]
        keymap_model["vix-keymap-model"]
    end
    gui --> tui
    tui --> script
    tui --> fhir
    tui --> editor
    tui --> lsp
    tui --> dap
    tui --> db
    tui --> i18n
    script --> git
    script --> macros
    fhir --> http
    fhir --> list_state
    editor --> core
    editor --> authority
    editor --> theme
    editor --> textops
    undo --> core
    undo --> settings
    lsp --> settings
    lsp --> authority
    lsp --> lsp_core
    dap --> lsp_core
    git --> authority
    git --> list_state
    db --> settings
    db --> i18n
    settings --> fileops
    authority --> fileops
    session --> fileops
    core --> input
    fileops --> encoding
    theme --> theme_model
    menu --> keymap_model
    menu --> i18n
    palette --> i18n

tui/tests/docs_crate_graph.rs keeps this diagram honest: it runs cargo metadata, fails if an arrow between two crates is not a direct dependency, if a crate is drawn in the wrong layer, or if a layer’s crate count or the “143 of the 148” sentence above no longer matches, and checks that every crate this page or the crate map names really exists. To list the layers yourself:

cargo metadata --no-deps --format-version 1 --offline

and follow each package’s dependencies whose kind is not "dev". For which crate owns what, read the crate map; it is the maintained crate-by-crate reference, and this page only sketches the shape.

Layering rules

Beyond “each layer depends only on layers below it” (which the definition of a layer guarantees), the graph keeps five rules. tui/tests/crate_layering.rs enforces them, reading cargo metadata and the gui/*/Cargo.toml manifests, and its failure message names each offending edge (from -> to):

  1. Nothing depends on the App shell. No workspace member depends on vix-tui, as a normal, build or dev-dependency; the desktop GUIs in gui/ are the only crates above it.
  2. Only vix-input and vix-tui use crossterm. Terminal I/O stays in the App shell and key-event conversion, so every other crate works under a desktop GUI with no terminal.
  3. Model and core crates know no UI surface. A crate named *-core or *-model reaches no crate named *-panel, *-picker, *-preview or *-view, directly or through other crates.
  4. The GUIs never depend on each other. No gui/vix-*/Cargo.toml names another GUI crate; what two GUIs share lives in vix-tui or under crates/.
  5. The headless MCP server knows no UI surface. vix-mcp-server (behind vix --mcp) reaches no *-panel, *-picker, *-preview or *-view crate, directly or through other crates (T860: it parses Markdown headings itself instead of borrowing vix-markdown-preview’s table of contents), nor vix-palette (T861: its symbol scan lives in vix-textops).

A rule is added here only when the current graph already keeps it. The full graph, every crate with its layer, direct workspace dependencies and number of dependents, is the generated Crate Layers reference (cargo run --example list_commands -- --write; scripts/check fails when it is stale).

Workspace Structure

vix/
├── Cargo.toml                    # Root workspace manifest
├── AGENTS.md                     # Contribution guidelines
├── plan.md                       # Improvement roadmap
├── tasks.md                      # Detailed task checklist
├── spec/                         # Cross-cutting specifications
│   ├── ci/                       # CI/CD specs
│   ├── packaging/                # Packaging specs
│   └── ...
├── tui/                          # Main app shell (vix-tui package)
│   ├── Cargo.toml
│   ├── src/
│   │   ├── main.rs               # Binary: allocator + calls entry::run
│   │   ├── entry.rs              # The vix command: terminal setup, event loop
│   │   ├── app.rs                # App state and logic
│   │   ├── app/*.rs              # Feature modules (git, lsp, org, etc.)
│   │   ├── ui.rs                 # UI rendering
│   │   └── ui/*.rs               # UI components
│   ├── examples/                 # Cargo examples
│   ├── benches/                  # Benchmarks
│   └── tests/                    # Integration tests
├── crates/                       # 148 feature crates (vix-*)
│   ├── vix-editor/               # Editor host
│   │   ├── Cargo.toml
│   │   ├── src/
│   │   └── spec/
│   ├── vix-editor-core/          # Core editor widget
│   ├── vix-lsp/                   # LSP client
│   ├── vix-lsp-core/             # LSP protocol types
│   ├── vix-dap/                   # DAP debugger
│   ├── vix-git/                   # Git integration
│   ├── vix-db/                    # Database workbench
│   ├── vix-org/                   # Org mode
│   ├── vix-terminal/              # Integrated terminal
│   ├── vix-http-client/           # REST client
│   ├── vix-file-browser-panel/   # File explorer
│   └── ... (130+ more)
├── gui/                          # Desktop GUI front ends
│   ├── Cargo.toml
│   ├── vix-gpui/
│   ├── vix-egui/
│   ├── vix-iced/
│   ├── vix-slint/
│   ├── vix-gtk4/
│   ├── vix-bui/
│   └── vix-zgui/
├── fuzz/                         # Fuzz targets
├── scripts/                      # Build and check scripts
└── docs/                         # User documentation

App Shell Architecture

The App shell (tui/) is the central coordinator that ties everything together:

classDiagram
    class App {
        -root: PathBuf
        -editor: Editor
        -settings: Settings
        -focus: Focus
        -flags: Flags
        +on_key()
        +on_mouse()
        +run_action()
        +tick()
        +draw()
    }
    
    class Editor {
        -buffer: Buffer
        -cursors: MultiCursor
        -history: History
        -syntax: Syntax
        +open()
        +close()
        +input()
        +render()
    }
    
    class Lsp {
        -clients: HashMap~LanguageServer~
        +start_server()
        +send_request()
        +handle_response()
    }
    
    class Git {
        -repo: Repository
        +refresh()
        +stage_hunk()
        +commit()
    }
    
    App --> Editor : owns
    App --> Lsp : owns
    App --> Git : owns
    App --> Settings : owns
    App --> Terminal : owns
    App --> Db : owns
    App --> Im : owns

Key App Components

FilePurpose
tui/src/main.rsThe binary: the MUSL allocator and a main calling vix::entry::run
tui/src/entry.rsThe vix command (entry::run): terminal setup, event loop; also called by the crates.io umbrella crate vix
tui/src/app.rsMain App struct, key/mouse handling, action dispatch
tui/src/app/git.rsGit integration logic
tui/src/app/lsp_dap.rsLSP and DAP coordination
tui/src/app/cowork.rsReal-time collaboration
tui/src/app/remote_session.rsRemote editing over SSH
tui/src/ui.rsMain UI rendering
tui/src/ui/*.rsUI components (panels, overlays, etc.)

Editor Architecture

The editor is split across multiple crates:

flowchart TD
    editor["vix-editor: editor host"] --> core["vix-editor-core: editor widget, rope buffer, Tree-sitter"]
    editor --> fileops["vix-fileops: file operations"]
    editor --> encoding["vix-encoding: character encodings"]
    undo["vix-undo-store: persistent undo"] --> core
    editorconfig["vix-editorconfig"] --> authority["vix-authority"]

Editor Core Components

CratePurpose
vix-editorEditor host, tab management, split panes
vix-editor-coreCore editor widget: rope buffer, cursors, Tree-sitter parsing and highlighting, rendering
vix-editorconfigEditorConfig file support
vix-undo-storePersistent undo tree with branching
vix-fileopsFile operations (read, write, watch)
vix-encodingCharacter encoding handling

Feature Crate Categories

Code Intelligence

flowchart TD
    lsp["vix-lsp: LSP client"] --> lsp_core["vix-lsp-core: protocol framing and types"]
    dap["vix-dap: DAP client"] --> lsp_core
    lsp --> project_env["vix-project-env: project environment"]
    lsp --> settings["vix-settings"]
    dap --> settings
CrateDescription
vix-lspLSP client implementation
vix-lsp-coreLSP protocol types and message parsing
vix-dapDebug Adapter Protocol client

Version Control

CrateDescription
vix-gitGit integration (status, diff, stage, commit)
vix-git-graphInteractive commit graph visualization
vix-reviewCode review with side-by-side diff
vix-conflict-toolMerge conflict resolution

Data & Documents

CrateDescription
vix-dbDatabase workbench (SQLite, PostgreSQL, MySQL)
vix-edit-tableCSV/TSV table editing
vix-edit-sqlSQL file editing with syntax awareness
vix-edit-valueJSON/YAML/TOML editing
vix-edit-outlineOutline/structural editing
vix-edit-bytesHex dump editing
vix-large-fileLarge file viewer (multi-GB files)
vix-markdown-previewMarkdown preview rendering

Org Mode

CrateDescription
vix-orgCore Org mode parsing and editing
vix-org-tableOrg table editing with formulas
vix-org-captureOrg capture templates
vix-org-contactsOrg contacts management
vix-roamOrg-roam with backlinks
vix-column-viewColumn View for Org and file browser

Projects & Tools

CrateDescription
vix-project-envProject environment detection (direnv, mise, venv)
vix-tasksTask runner (npm, make, etc.)
vix-terminalIntegrated terminal emulator
vix-http-clientREST client for .http files
vix-ociOpen Container Initiative support
vix-oci-panelContainer management UI

Collaboration

CrateDescription
vix-coworkReal-time collaborative editing
vix-cowork-netCowork network protocol
vix-imInstant messaging (IRC, Matrix)
vix-im-panelIM UI panel
vix-matrix-protocolMatrix protocol support
vix-im-ircIRC client implementation

AI & Assistants

CrateDescription
vix-ai-coreAI provider abstraction
vix-ai-panelAI chat panel UI
vix-ai-diffAI-assisted diff review
vix-acpAgent Client Protocol client
vix-mcp-serverModel Context Protocol server

UI & Rendering

CrateDescription
vix-menuMenu bar and context menus
vix-paletteCommand palette
vix-status-bar-panelStatus bar
vix-bottom-dockBottom dock area
vix-left-dockLeft dock (file browser)
vix-right-dockRight dock area
vix-welcome-panelWelcome screen
vix-themeTheme loading and management
vix-theme-modelTheme data model
vix-theme-editor-panelTheme editor UI

Settings & State

CrateDescription
vix-settingsConfiguration management
vix-settings-bundleBundled settings presets
vix-sessionSession state management
vix-workspaceWorkspace state management
vix-keymap-modelKeymap definitions
vix-keybindingsKeybinding registry
vix-snippetsSnippet management
vix-scriptRhai scripting
vix-macrosKeyboard macro recording

File Browser & Navigation

CrateDescription
vix-file-browser-panelFile explorer UI
vix-file-information-panelFile info display
vix-workspace-dashboard-panelWorkspace dashboard
vix-text-information-panelText info display
vix-tagsTag management
vix-todo-treeTODO tree
vix-workspace-searchWorkspace search
vix-find-panelFind/replace UI

Utilities

CrateDescription
vix-i18nInternationalization
vix-locale-modelLocale management
vix-clipboardClipboard access
vix-authorityAuthority abstraction (local, SSH, containers)
vix-byte-sizeByte size formatting
vix-civil-dateCivil date handling
vix-time-zone-modelTime zone management
vix-uuid-toolUUID generation
vix-base64-toolBase64 encoding/decoding
vix-jwt-toolJWT encoding/decoding
vix-qr-toolQR code generation
vix-calendar-panelCalendar panel
vix-clock-panelClock panel
vix-system-information-panelSystem info display
vix-vcard-panelvCard display
vix-vcard-parservCard parsing
vix-fhirFHIR support
vix-hl7HL7 v2 support

Desktop GUI Architecture

Vix supports 7 desktop GUI front ends, each wrapping the same App shell:

graph TD
    A[App Shell] --> B[vix-gpui]
    A --> C[vix-egui]
    A --> D[vix-iced]
    A --> E[vix-slint]
    A --> F[vix-gtk4]
    A --> G[vix-bui]
    A --> H[vix-zgui]
    
    B --> I[GPUI Framework]
    C --> J[egui Framework]
    D --> K[iced Framework]
    E --> L[Slint Framework]
    F --> M[GTK4 Framework]
    G --> N[BUI Framework]
    H --> O[zgui Framework]
    
    I --> P[Skia Renderer]
    J --> Q[Softbuffer Renderer]
    K --> R[wgpu Renderer]
    L --> S[OpenGL Renderer]
    M --> T[GTK Renderer]
    N --> U[BUI Renderer]
    O --> V[wgpu Renderer]
FrontendFrameworkLicenseNotes
vix-gpuiGPUIMIT/Apache-2.0GPU-accelerated, native menu bar
vix-eguieguiMIT/Apache-2.0Immediate mode, simple
vix-icedicedMIT/Apache-2.0Elm-style, CSS styling
vix-slintSlintGPL-3.0-onlyDeclarative, OpenGL
vix-gtk4GTK4LGPLNative GTK integration
vix-buiBUIGPL-3.0-onlyBlender’s UI toolkit
vix-zguizguiApache-2.0Reactive, CSS, wgpu

All front ends:

  • Share the same App shell from tui/
  • Use the same key handling, action dispatch, and state management
  • Render using the framework’s capabilities
  • Support the same features as the TUI version

Data Flow

Key Press Flow

flowchart TD
    A[User Presses Key] --> B[Terminal]
    B --> C[App::on_key]
    C --> D{Keymap Active?}
    D -->|Yes| E[Keymap Dispatch]
    D -->|No| F[Global Key Handling]
    E --> G[Match Key in Keymap]
    G --> H[Find Action ID]
    H --> I[App::run_action]
    I --> J[Action Dispatch]
    J --> K[Update State]
    J --> L[Queue Render]
    L --> M[App::draw]
    M --> N[ratatui::Terminal::draw]

LSP Request Flow

flowchart TD
    A[User Types] --> B[Editor::input]
    B --> C[Trigger LSP Request]
    C --> D[vix-lsp::request]
    D --> E[Send to Language Server]
    E --> F[Receive Response]
    F --> G[vix-lsp::handle_response]
    G --> H[Update Editor State]
    H --> I[Queue Render]

Git Operation Flow

flowchart TD
    A[User Triggers Git Action] --> B[App::run_action]
    B --> C[git.* action]
    C --> D[vix-git::handle]
    D --> E[Spawn git Command]
    E --> F[Parse Output]
    F --> G[Update Git State]
    G --> H[Refresh UI]

Internationalization (i18n)

Vix uses a robust i18n system:

flowchart TD
    A[User Text] -->|t! macro| B[Lookup in Catalog]
    B --> C[crates/vix-i18n]
    C --> D[Load Locale File]
    D --> E[Return Translated String]
    E --> F[Display to User]
    
    C --> G[locales/action.yml]
    C --> H[locales/menu.yml]
    C --> I[locales/ui.yml]
    C --> J[... one file per key namespace, each key holding all 15 languages]

Supported Languages:

  • English (en)
  • Spanish (es)
  • French (fr)
  • German (de)
  • Welsh (cy)
  • Irish (ga)
  • Scottish Gaelic (gd)
  • Polish (pl)
  • Portuguese (pt)
  • Russian (ru)
  • Arabic (ar)
  • Hindi (hi)
  • Bengali (bn)
  • Chinese (zh)
  • Japanese (ja)

Settings System

Vix uses a hierarchical settings system:

flowchart LR
    builtin["Built-in defaults"] --> user["User: config.toml in the confy config folder (~/.config/vix/ on Linux)"]
    user --> project["Project: .vix/settings.toml in the workspace root"]
    project --> language["Language: a languages table per language id, per buffer"]

vix-settings loads four layers, each overriding the one before it (crates/vix-settings/src/layers.rs; see its spec for the details):

  1. Built-in defaults
  2. User settings (config.toml, located by confy)
  3. Project settings (<root>/.vix/settings.toml)
  4. Per-language overrides ([languages.<id>]), resolved per buffer

Theme System

flowchart TD
    A[Theme Selection] --> B[Load Theme]
    B --> C[Built-in Themes]
    B --> D[Custom Themes]
    C --> E[21 Bundled Themes]
    D --> F[~/.config/vix/themes/*.json]
    E --> G[Theme Model]
    F --> G
    G --> H[Apply Colors]
    H --> I[Render UI]

Bundled Themes:

  • Default (light/dark variants)
  • High contrast themes
  • Popular color schemes (Catppuccin, etc.)

Keymap System

Vix supports 14 keymaps:

flowchart TD
    A[Keymap Selection] --> B[Load Keymap]
    B --> C[vix-keymap-model]
    C --> D[Apple]
    C --> E[VSCode macOS]
    C --> F[VSCode Windows]
    C --> G[Emacs]
    C --> H[Vi]
    C --> I[Spacemacs]
    C --> J[Helix]
    C --> K[IntelliJ macOS]
    C --> L[IntelliJ Windows]
    C --> M[Eclipse]
    C --> N[Sublime]
    C --> O[Zed]
    C --> P[Fresh]
    C --> Q[ttt]

Performance Architecture

Vix is designed for performance:

Background Processing

flowchart TD
    A[Editor::input] --> B[Queue Background Task]
    B --> C[Background Thread Pool]
    C --> D[Process Task]
    D --> E[Send Result]
    E --> F[Apply to Editor]
    
    C --> G[Tree-sitter Parsing]
    C --> H[LSP Requests]
    C --> I[Git Operations]
    C --> J[Workspace Search]

Lazy Loading

flowchart TD
    A[App Startup] --> B[Load Essential Components]
    B --> C[Defer Optional Features]
    C --> D[Load on First Use]
    
    D --> E[LSP Servers]
    D --> F[Git Integration]
    D --> G[Database Workbench]
    D --> H[Terminal]
    D --> I[AI Panel]

Caching

flowchart TD
    A[First Request] --> B[Check Cache]
    B -->|Miss| C[Process Request]
    C --> D[Store in Cache]
    D --> E[Return Result]
    B -->|Hit| E
    
    A --> F[Subsequent Request]
    F --> B

Security Architecture

Vix takes security seriously:

flowchart TD
    A[User Input] --> B[Validation]
    B --> C[Sanitization]
    C --> D[Sandboxing]
    D --> E[Execution]
    
    A --> F[File Path]
    F --> G[Check for Traversal]
    G --> H[Check for Special Files]
    H --> I[Safe Open]
    
    A --> J[Shell Command]
    J --> K[Check for Dangerous Patterns]
    K --> L[Execute with Restrictions]
    
    A --> M[Rhai Script]
    M --> N[Disable File/Network/Process Access]
    N --> O[Execute in Sandbox]

Security Features

  • Zero unsafe Rust: No unsafe code anywhere in the codebase
  • Sandboxed scripts: Rhai scripts have no file/network/process access
  • Workspace trust: Project scripts run only after explicit trust
  • Keyring integration: Secrets stored in native credential stores
  • Input validation: All external inputs are validated
  • Path sanitization: Prevents directory traversal attacks
  • Command sanitization: Prevents shell injection attacks

Testing Architecture

Vix has comprehensive testing:

flowchart TD
    A[Development] --> B[Unit Tests]
    A --> C[Integration Tests]
    A --> D[Snapshot Tests]
    A --> E[Fuzz Tests]
    A --> F[Benchmarks]
    
    B --> G[cargo test --workspace]
    C --> G
    D --> H[TestBackend]
    E --> I[cargo +nightly fuzz]
    F --> J[cargo bench]
    
    G --> K[CI: GitHub/GitLab/Codeberg]
    H --> K
    I --> K
    J --> K

Test Layers

LayerFrameworkPurpose
Unit TestsRust #[test]Test individual functions
Integration Testsratatui TestBackendTest component interactions
Snapshot TestsinstaTest UI rendering
Fuzz Testscargo-fuzzTest parser edge cases
BenchmarksCriterionTest performance

CI/CD Architecture

flowchart TD
    A[Push to main] --> B[GitHub Actions]
    A --> C[GitLab CI]
    A --> D[Codeberg CI]
    
    B --> E[Run scripts/check]
    C --> E
    D --> E
    
    E --> F[cargo fmt --check]
    E --> G[cargo build]
    E --> H[cargo clippy]
    E --> I[cargo test]
    E --> J[cargo doc]
    E --> K[scripts/check-docs]
    E --> L[lychee link check]
    
    E --> M[Generate Gate Attestation]
    M --> N[refs/notes/vix-gate]
    
    N --> O[pre-push Hook]
    O --> P[Verify Attestation]

Summary

Vix’s architecture is designed for:

  1. Modularity: Each feature is isolated in its own crate
  2. Maintainability: Clear boundaries and specifications
  3. Extensibility: Easy to add new features
  4. Performance: Background processing, lazy loading, caching
  5. Security: Sandboxing, validation, zero unsafe
  6. Internationalization: Full support for 15 languages
  7. Accessibility: High contrast, keyboard-only, screen reader friendly

The architecture enables Vix to be:

  • Fast: Native binary, optimized rendering
  • Reliable: Comprehensive testing, zero unsafe
  • Flexible: Multiple keymaps, themes, configurations
  • Extensible: Scripting, plugins (future), customization
  • Portable: Works anywhere Rust runs

Next Steps

If you’re new to Vix’s codebase, here are some good next steps:

  1. Read AGENTS.md - Detailed conventions and workflow
  2. Read agents/workflow.md - Spec-driven development guide
  3. Explore the crates - Each crate has its own spec/index.md
  4. Run the examples - cargo run --example list_commands
  5. Check the docs - docs/ has user-facing documentation
  6. Join the community - Ask questions in GitHub Discussions

Resources