# flplima/tmuxy architecture

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

- Interactive diagram: https://gitdiagram.com/flplima/tmuxy
- Repository: https://github.com/flplima/tmuxy

## Overview

#### Purpose and Delivery Modes
tmuxy is a GUI layer over tmux: it observes and controls existing tmux sessions while adding browser-native UI features such as pane groups, floating panes, rich widgets, and image rendering. It ships as a web application backed by HTTP/SSE and as a Tauri desktop application using local IPC. Core workspace and package boundaries are defined by `Cargo.toml`, `packages/tmuxy-ui/`, and `packages/tmuxy-tauri-app/`.

#### Entry Points and Launch Topology
Rust binaries provide the backend, connector, desktop app, and tree utility: `packages/tmuxy-server/src/main.rs`, `packages/tmuxy-connect/src/main.rs`, `packages/tmuxy-tauri-app/src/main.rs`, and `packages/tmuxy-tree/src/main.rs`. The browser UI boots from `packages/tmuxy-ui/src/main.tsx`; shell entrypoints in `bin/dev`, `bin/prod`, and `bin/build-tauri` orchestrate development and packaging. A separate Next-based public demo lives in `packages/tmuxy-demo/app/page.tsx`.

#### tmux Core: Control Mode to Authoritative State
`packages/tmuxy-core/` is the central Rust domain layer. It connects to tmux control mode, parses its protocol and terminal-related extensions, aggregates state, and executes tmux commands. The critical pipeline is represented by `packages/tmuxy-core/src/control_mode/connection.rs`, `packages/tmuxy-core/src/control_mode/parser.rs`, and `packages/tmuxy-core/src/control_mode/state.rs`. Service/session coordination and command execution sit at `packages/tmuxy-core/src/tmux_service.rs`, `packages/tmuxy-core/src/session.rs`, and `packages/tmuxy-core/src/executor.rs`.

#### Network Server Boundary
The web backend exposes the core through HTTP commands and Server-Sent Events. `packages/tmuxy-server/src/server.rs` owns server setup, `packages/tmuxy-server/src/command.rs` maps client operations to core actions, and `packages/tmuxy-server/src/sse.rs` streams state/events to clients. `packages/tmuxy-server/src/auth.rs` is the security boundary for remote access. The web client should treat this API as asynchronous, streamed transport rather than direct tmux access.

#### Desktop IPC Boundary
The Tauri app reuses the Rust core but bypasses HTTP/SSE for local IPC. `packages/tmuxy-tauri-app/src/gui.rs` initializes desktop-facing application behavior, `packages/tmuxy-tauri-app/src/commands.rs` exposes invokeable commands, and `packages/tmuxy-tauri-app/src/monitor.rs` connects monitoring/state propagation. Capabilities are constrained through `packages/tmuxy-tauri-app/capabilities/default.json`.

#### UI State, Transport, and Rendering
The React/Vite frontend is structured around an application state machine and a tmux model/store. `packages/tmuxy-ui/src/machines/app/appMachine.ts` coordinates UI modes and user workflows; `packages/tmuxy-ui/src/machines/actors/tmuxActor.ts` binds transport updates into UI control flow; `packages/tmuxy-ui/src/tmux/store/TmuxStore.ts` owns client-side tmux state and operations. Transport adapters support web, desktop-compatible abstractions, demo, and local emulation: `packages/tmuxy-ui/src/tmux/HttpAdapter.ts`, `packages/tmuxy-ui/src/tmux/effect/EffectTmuxAdapter.ts`, and `packages/tmuxy-ui/src/tmux/v86/V86TmuxAdapter.ts`.

#### Interaction and Terminal Presentation
`packages/tmuxy-ui/src/App.tsx` composes the application shell. Layout and pane presentation are centered on `packages/tmuxy-ui/src/components/PaneLayout.tsx`, `packages/tmuxy-ui/src/components/TerminalPane.tsx`, and `packages/tmuxy-ui/src/components/ScrollbackTerminal.tsx`. Input flows from keyboard/mouse actors through tmux adapters, while streamed terminal deltas update the client store and trigger pane rendering. Rich non-terminal content is an explicit extension boundary via `packages/tmuxy-ui/src/components/WidgetPane.tsx` and `packages/tmuxy-ui/src/components/widgets/`.

#### Runtime and External Dependencies
Primary runtimes are Rust for tmux integration/server/desktop services and TypeScript/React in the frontend. tmux itself, specifically control mode, is the fundamental external system. Web mode requires an HTTP/SSE-capable browser and server; desktop mode requires Tauri. The optional browser-local v86 path supports tmux emulation/demo behavior. CI builds and deploys through `.github/workflows/build-app.yml` and `.github/workflows/deploy-demo.yml`.

Main entry points: [`packages/tmuxy-core/src/tmux_service.rs`](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/tmux_service.rs) (tmux service), [`packages/tmuxy-ui/src/machines/actors/tmuxActor.ts`](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/machines/actors/tmuxActor.ts) (tmux actor), [`packages/tmuxy-server/src/command.rs`](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-server/src/command.rs) (HTTP commands), [`packages/tmuxy-tauri-app/src/commands.rs`](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-tauri-app/src/commands.rs) (Tauri commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["tmux Core"]
  node_connection["Control connection<br/>Rust protocol<br/>[connection.rs]"]
  node_parser["Control parser<br/>Rust protocol<br/>[parser.rs]"]
  node_state[("Authoritative state<br/>Rust state<br/>[state.rs]")]
  node_tmux_service["tmux service<br/>Rust coordination<br/>[tmux_service.rs]"]
  node_executor["Command executor<br/>Rust commands<br/>[executor.rs]"]
end

subgraph group_web["Web Backend"]
  node_server["Server runtime<br/>Rust HTTP server<br/>[server.rs]"]
  node_auth["Remote auth<br/>security boundary<br/>[auth.rs]"]
  node_http_commands["HTTP commands<br/>API handler<br/>[command.rs]"]
  node_sse["SSE event stream<br/>streaming API<br/>[sse.rs]"]
end

subgraph group_desktop["Tauri Desktop"]
  node_tauri_gui["Tauri GUI runtime<br/>Rust desktop app<br/>[gui.rs]"]
  node_tauri_commands["Tauri commands<br/>local IPC<br/>[commands.rs]"]
  node_tauri_monitor["Desktop monitor<br/>state propagation<br/>[monitor.rs]"]
end

subgraph group_ui["React UI"]
  node_ui_boot["UI bootstrap<br/>React/Vite entry<br/>[main.tsx]"]
  node_app_shell["Application shell<br/>React composition<br/>[App.tsx]"]
  node_app_machine["App state machine<br/>XState workflow<br/>[appMachine.ts]"]
  node_tmux_actor["tmux actor<br/>UI transport actor<br/>[tmuxActor.ts]"]
  node_tmux_store[("Client tmux store<br/>TypeScript state<br/>[TmuxStore.ts]")]
  node_http_adapter["HTTP adapter<br/>web transport<br/>[HttpAdapter.ts]"]
  node_effect_adapter["Effect adapter<br/>desktop-compatible transport"]
  node_pane_layout["Pane layout<br/>React layout<br/>[PaneLayout.tsx]"]
  node_terminal_pane["Terminal presentation<br/>React terminal<br/>[TerminalPane.tsx]"]
end

node_tmux{{"tmux control mode<br/>external runtime"}}

node_tmux -->|"control protocol"| node_connection
node_connection -->|"raw messages"| node_parser
node_parser -->|"parsed events"| node_state
node_state -->|"state updates"| node_tmux_service
node_tmux_service -->|"operations"| node_executor
node_executor -->|"tmux commands"| node_tmux
node_server -->|"protects remote access"| node_auth
node_auth -->|"authorized requests"| node_http_commands
node_http_commands -->|"core actions"| node_tmux_service
node_tmux_service -->|"state and events"| node_sse
node_tauri_gui -->|"local invoke"| node_tauri_commands
node_tauri_commands -->|"core actions"| node_tmux_service
node_tmux_service -->|"state changes"| node_tauri_monitor
node_ui_boot -->|"mounts"| node_app_shell
node_app_shell -->|"UI workflows"| node_app_machine
node_app_machine -->|"control flow"| node_tmux_actor
node_tmux_actor -->|"streamed updates"| node_tmux_store
node_tmux_actor -->|"web mode"| node_http_adapter
node_http_adapter -->|"HTTP commands"| node_http_commands
node_sse -->|"SSE updates"| node_http_adapter
node_tmux_actor -->|"desktop mode"| node_effect_adapter
node_effect_adapter -->|"local IPC"| node_tauri_commands
node_tauri_monitor -->|"state updates"| node_effect_adapter
node_tmux_store -->|"pane state"| node_pane_layout
node_pane_layout -->|"pane rendering"| node_terminal_pane

click node_connection "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/control_mode/connection.rs"
click node_parser "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/control_mode/parser.rs"
click node_state "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/control_mode/state.rs"
click node_tmux_service "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/tmux_service.rs"
click node_executor "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/executor.rs"
click node_server "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-server/src/server.rs"
click node_auth "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-server/src/auth.rs"
click node_http_commands "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-server/src/command.rs"
click node_sse "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-server/src/sse.rs"
click node_tauri_gui "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-tauri-app/src/gui.rs"
click node_tauri_commands "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-tauri-app/src/commands.rs"
click node_tauri_monitor "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-tauri-app/src/monitor.rs"
click node_ui_boot "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/main.tsx"
click node_app_shell "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/App.tsx"
click node_app_machine "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/machines/app/appMachine.ts"
click node_tmux_actor "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/machines/actors/tmuxActor.ts"
click node_tmux_store "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/tmux/store/TmuxStore.ts"
click node_http_adapter "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/tmux/HttpAdapter.ts"
click node_effect_adapter "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/tmux/effect/EffectTmuxAdapter.ts"
click node_pane_layout "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/components/PaneLayout.tsx"
click node_terminal_pane "https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/components/TerminalPane.tsx"

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_connection,node_parser,node_state,node_tmux_service,node_executor toneBlue
class node_server,node_auth,node_http_commands,node_sse toneAmber
class node_tauri_gui,node_tauri_commands,node_tauri_monitor toneMint
class node_ui_boot,node_app_shell,node_app_machine,node_tmux_actor,node_tmux_store,node_http_adapter,node_effect_adapter,node_pane_layout,node_terminal_pane toneRose
class node_tmux toneNeutral
```

## Components

### tmux Core

Rust domain layer and authoritative tmux state.

- [Control connection](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/control_mode/connection.rs): Rust protocol · `packages/tmuxy-core/src/control_mode/connection.rs`
- [Control parser](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/control_mode/parser.rs): Rust protocol · `packages/tmuxy-core/src/control_mode/parser.rs`
- [Authoritative state](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/control_mode/state.rs): Rust state · `packages/tmuxy-core/src/control_mode/state.rs`
- [tmux service](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/tmux_service.rs): Rust coordination · Coordinates sessions and state. · `packages/tmuxy-core/src/tmux_service.rs`
- [Command executor](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-core/src/executor.rs): Rust commands · `packages/tmuxy-core/src/executor.rs`

### Web Backend

HTTP and SSE boundary for browser clients.

- [Server runtime](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-server/src/server.rs): Rust HTTP server · `packages/tmuxy-server/src/server.rs`
- [Remote auth](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-server/src/auth.rs): security boundary · `packages/tmuxy-server/src/auth.rs`
- [HTTP commands](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-server/src/command.rs): API handler · `packages/tmuxy-server/src/command.rs`
- [SSE event stream](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-server/src/sse.rs): streaming API · `packages/tmuxy-server/src/sse.rs`

### Tauri Desktop

Local IPC boundary for the desktop runtime.

- [Tauri GUI runtime](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-tauri-app/src/gui.rs): Rust desktop app · `packages/tmuxy-tauri-app/src/gui.rs`
- [Tauri commands](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-tauri-app/src/commands.rs): local IPC · Invokeable desktop commands. · `packages/tmuxy-tauri-app/src/commands.rs`
- [Desktop monitor](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-tauri-app/src/monitor.rs): state propagation · `packages/tmuxy-tauri-app/src/monitor.rs`

### React UI

Shared frontend state, transport, and rendering.

- [UI bootstrap](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/main.tsx): React/Vite entry · `packages/tmuxy-ui/src/main.tsx`
- [Application shell](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/App.tsx): React composition · `packages/tmuxy-ui/src/App.tsx`
- [App state machine](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/machines/app/appMachine.ts): XState workflow · Coordinates UI modes and workflows. · `packages/tmuxy-ui/src/machines/app/appMachine.ts`
- [tmux actor](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/machines/actors/tmuxActor.ts): UI transport actor · Binds transport updates into UI control flow. · `packages/tmuxy-ui/src/machines/actors/tmuxActor.ts`
- [Client tmux store](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/tmux/store/TmuxStore.ts): TypeScript state · Owns client-side tmux state and operations. · `packages/tmuxy-ui/src/tmux/store/TmuxStore.ts`
- [HTTP adapter](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/tmux/HttpAdapter.ts): web transport · `packages/tmuxy-ui/src/tmux/HttpAdapter.ts`
- [Effect adapter](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/tmux/effect/EffectTmuxAdapter.ts): desktop-compatible transport · `packages/tmuxy-ui/src/tmux/effect/EffectTmuxAdapter.ts`
- [Pane layout](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/components/PaneLayout.tsx): React layout · `packages/tmuxy-ui/src/components/PaneLayout.tsx`
- [Terminal presentation](https://github.com/flplima/tmuxy/blob/main/packages/tmuxy-ui/src/components/TerminalPane.tsx): React terminal · Renders panes and scrollback updates. · `packages/tmuxy-ui/src/components/TerminalPane.tsx`

### Other components

- **tmux control mode**: external runtime · Authoritative terminal multiplexer.

## Connections

- tmux control mode → Control connection: control protocol
- Control connection → Control parser: raw messages
- Control parser → Authoritative state: parsed events
- Authoritative state → tmux service: state updates
- tmux service → Command executor: operations
- Command executor → tmux control mode: tmux commands
- Server runtime → Remote auth: protects remote access
- Remote auth → HTTP commands: authorized requests
- HTTP commands → tmux service: core actions
- tmux service → SSE event stream: state and events
- Tauri GUI runtime → Tauri commands: local invoke
- Tauri commands → tmux service: core actions
- tmux service → Desktop monitor: state changes
- UI bootstrap → Application shell: mounts
- Application shell → App state machine: UI workflows
- App state machine → tmux actor: control flow
- tmux actor → Client tmux store: streamed updates
- tmux actor → HTTP adapter: web mode
- HTTP adapter → HTTP commands: HTTP commands
- SSE event stream → HTTP adapter: SSE updates
- tmux actor → Effect adapter: desktop mode
- Effect adapter → Tauri commands: local IPC
- Desktop monitor → Effect adapter: state updates
- Client tmux store → Pane layout: pane state
- Pane layout → Terminal presentation: pane rendering
