# shark-empire/mitos-terminal architecture

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

- Interactive diagram: https://gitdiagram.com/shark-empire/mitos-terminal
- Repository: https://github.com/shark-empire/mitos-terminal

## Overview

MITOS Terminal is a native terminal emulator: user input and PTY output meet in a per-pane session, VT output updates a screen model, and the app renders it in a tabbed/split GUI. Major documented capabilities include search and selection, themes and effects, configuration hot reload, accessibility, shell hooks, and MITOS integrations. Sampled source confirms session/parser/render ownership and app-to-session actions; README describes other subsystems whose detailed wiring was not sampled, so uncertain links are omitted.

Main entry points: [`src/app.rs`](https://github.com/shark-empire/mitos-terminal/blob/main/src/app.rs) (Application controller), [`src/session.rs`](https://github.com/shark-empire/mitos-terminal/blob/main/src/session.rs) (PTY session), [`src/term/mod.rs`](https://github.com/shark-empire/mitos-terminal/blob/main/src/term/mod.rs) (VT screen model), [`src/render.rs`](https://github.com/shark-empire/mitos-terminal/blob/main/src/render.rs) (Grid painter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Terminal runtime"]
  node_session["PTY session<br/>[session.rs]"]
  node_pty["PTY and shell<br/>[pty.rs]"]
  node_term["VT screen model<br/>[mod.rs]"]
  node_parser["Escape interpreter<br/>[perform.rs]"]
  node_screenops["Screen operations<br/>[ops.rs]"]
  node_search["Scrollback search<br/>[search.rs]"]
  node_input["Input encoding<br/>[input.rs]"]
  node_security["Terminal policy<br/>[security.rs]"]
end

subgraph group_interface["Window interface"]
  node_app["Application controller<br/>[app.rs]"]
  node_layout["Tabs and splits<br/>[layout.rs]"]
  node_config["Settings and profiles<br/>[config.rs]"]
  node_platform["Desktop services<br/>[platform.rs]"]
end

subgraph group_presentation["Appearance and access"]
  node_render["Grid painter<br/>[render.rs]"]
  node_theme["Theme engine<br/>[theme.rs]"]
  node_effects["Visual effects<br/>[fx.rs]"]
  node_a11y["Accessibility<br/>[a11y.rs]"]
end

subgraph group_ecosystem["MITOS integration"]
  node_ipc["Ecosystem IPC<br/>[ipc.rs]"]
  node_pkg["Package bridge<br/>[pkg_bridge.rs]"]
  node_hooks["Shell integration hooks"]
end

node_user(("Terminal user"))
node_shell(("Child shell"))
node_mitos(("MITOS services"))

node_user -->|"operates"| node_app
node_app -->|"manages panes"| node_layout
node_app -->|"spawns and resizes"| node_session
node_app -->|"encodes input"| node_input
node_app -->|"reads screen"| node_term
node_app -->|"paints panes"| node_render
node_app -->|"loads settings"| node_config
node_session -->|"spawns child"| node_pty
node_pty -->|"runs"| node_shell
node_session -->|"feeds PTY bytes"| node_term
node_term -->|"interprets sequences"| node_parser
node_parser -->|"updates screen"| node_screenops
node_input -->|"writes child bytes"| node_session
node_session -->|"transfers input and output"| node_shell
node_app -->|"queries scrollback"| node_search
node_app -->|"applies policy"| node_security
node_term -->|"emits policy events"| node_security
node_render -->|"reads screen state"| node_term
node_render -->|"resolves colors"| node_theme
node_app -->|"paints effects"| node_effects
node_app -->|"provides accessibility"| node_a11y
node_app -->|"uses desktop services"| node_platform
node_app -.->|"serves ecosystem requests"| node_ipc
node_ipc -.->|"communicates"| node_mitos
node_app -.->|"handles missing commands"| node_pkg
node_pkg -.->|"requests installs"| node_mitos
node_app -.->|"installs shell hooks"| node_hooks

click node_app "https://github.com/shark-empire/mitos-terminal/blob/main/src/app.rs"
click node_layout "https://github.com/shark-empire/mitos-terminal/blob/main/src/layout.rs"
click node_session "https://github.com/shark-empire/mitos-terminal/blob/main/src/session.rs"
click node_pty "https://github.com/shark-empire/mitos-terminal/blob/main/src/pty.rs"
click node_term "https://github.com/shark-empire/mitos-terminal/blob/main/src/term/mod.rs"
click node_parser "https://github.com/shark-empire/mitos-terminal/blob/main/src/term/perform.rs"
click node_screenops "https://github.com/shark-empire/mitos-terminal/blob/main/src/term/ops.rs"
click node_search "https://github.com/shark-empire/mitos-terminal/blob/main/src/term/search.rs"
click node_input "https://github.com/shark-empire/mitos-terminal/blob/main/src/input.rs"
click node_security "https://github.com/shark-empire/mitos-terminal/blob/main/src/security.rs"
click node_config "https://github.com/shark-empire/mitos-terminal/blob/main/src/config.rs"
click node_render "https://github.com/shark-empire/mitos-terminal/blob/main/src/render.rs"
click node_theme "https://github.com/shark-empire/mitos-terminal/blob/main/src/theme.rs"
click node_effects "https://github.com/shark-empire/mitos-terminal/blob/main/src/fx.rs"
click node_a11y "https://github.com/shark-empire/mitos-terminal/blob/main/src/a11y.rs"
click node_platform "https://github.com/shark-empire/mitos-terminal/blob/main/src/platform.rs"
click node_ipc "https://github.com/shark-empire/mitos-terminal/blob/main/src/ipc.rs"
click node_pkg "https://github.com/shark-empire/mitos-terminal/blob/main/src/pkg_bridge.rs"
click node_hooks "https://github.com/shark-empire/mitos-terminal/tree/main/shell-integration"

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_session,node_pty,node_term,node_parser,node_screenops,node_search,node_input,node_security,node_user toneBlue
class node_app,node_layout,node_config,node_platform toneAmber
class node_render,node_theme,node_effects,node_a11y toneMint
class node_ipc,node_pkg,node_hooks toneRose
class node_shell,node_mitos toneIndigo
```

## Components

### Terminal runtime

- [PTY session](https://github.com/shark-empire/mitos-terminal/blob/main/src/session.rs): `src/session.rs`
- [PTY and shell](https://github.com/shark-empire/mitos-terminal/blob/main/src/pty.rs): `src/pty.rs`
- [VT screen model](https://github.com/shark-empire/mitos-terminal/blob/main/src/term/mod.rs): `src/term/mod.rs`
- [Escape interpreter](https://github.com/shark-empire/mitos-terminal/blob/main/src/term/perform.rs): `src/term/perform.rs`
- [Screen operations](https://github.com/shark-empire/mitos-terminal/blob/main/src/term/ops.rs): `src/term/ops.rs`
- [Scrollback search](https://github.com/shark-empire/mitos-terminal/blob/main/src/term/search.rs): `src/term/search.rs`
- [Input encoding](https://github.com/shark-empire/mitos-terminal/blob/main/src/input.rs): `src/input.rs`
- [Terminal policy](https://github.com/shark-empire/mitos-terminal/blob/main/src/security.rs): `src/security.rs`

### Window interface

- [Application controller](https://github.com/shark-empire/mitos-terminal/blob/main/src/app.rs): `src/app.rs`
- [Tabs and splits](https://github.com/shark-empire/mitos-terminal/blob/main/src/layout.rs): `src/layout.rs`
- [Settings and profiles](https://github.com/shark-empire/mitos-terminal/blob/main/src/config.rs): `src/config.rs`
- [Desktop services](https://github.com/shark-empire/mitos-terminal/blob/main/src/platform.rs): `src/platform.rs`

### Appearance and access

- [Grid painter](https://github.com/shark-empire/mitos-terminal/blob/main/src/render.rs): `src/render.rs`
- [Theme engine](https://github.com/shark-empire/mitos-terminal/blob/main/src/theme.rs): `src/theme.rs`
- [Visual effects](https://github.com/shark-empire/mitos-terminal/blob/main/src/fx.rs): `src/fx.rs`
- [Accessibility](https://github.com/shark-empire/mitos-terminal/blob/main/src/a11y.rs): `src/a11y.rs`

### MITOS integration

- [Ecosystem IPC](https://github.com/shark-empire/mitos-terminal/blob/main/src/ipc.rs): `src/ipc.rs`
- [Package bridge](https://github.com/shark-empire/mitos-terminal/blob/main/src/pkg_bridge.rs): `src/pkg_bridge.rs`
- [Shell integration hooks](https://github.com/shark-empire/mitos-terminal/tree/main/shell-integration): `shell-integration`

### Other components

- **Terminal user**
- **Child shell**
- **MITOS services**

## Connections

- Terminal user → Application controller: operates
- Application controller → Tabs and splits: manages panes
- Application controller → PTY session: spawns and resizes
- Application controller → Input encoding: encodes input
- Application controller → VT screen model: reads screen
- Application controller → Grid painter: paints panes
- Application controller → Settings and profiles: loads settings
- PTY session → PTY and shell: spawns child
- PTY and shell → Child shell: runs
- PTY session → VT screen model: feeds PTY bytes
- VT screen model → Escape interpreter: interprets sequences
- Escape interpreter → Screen operations: updates screen
- Input encoding → PTY session: writes child bytes
- PTY session → Child shell: transfers input and output
- Application controller → Scrollback search: queries scrollback
- Application controller → Terminal policy: applies policy
- VT screen model → Terminal policy: emits policy events
- Grid painter → VT screen model: reads screen state
- Grid painter → Theme engine: resolves colors
- Application controller → Visual effects: paints effects
- Application controller → Accessibility: provides accessibility
- Application controller → Desktop services: uses desktop services
- Application controller → Ecosystem IPC: serves ecosystem requests
- Ecosystem IPC → MITOS services: communicates
- Application controller → Package bridge: handles missing commands
- Package bridge → MITOS services: requests installs
- Application controller → Shell integration hooks: installs shell hooks
