Skip to main content

Monolex Architecture

Monolex is a next-generation AI-native terminal built on Tauri 2.0 with a unique hybrid architecture combining the best of Rust and TypeScript.

High-Level Architecture

┌─────────────────────────────────────────────────────────────────┐
│  MONOLEX TAURI ARCHITECTURE                                     │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  pty-daemon-rust (Sidecar Binary)                               │
│       ↓ Unix Socket per session                                 │
│  Tauri Rust Backend (lib.rs ~5,700 lines)                       │
│       ├── SessionActor (owns all state, NO LOCKS)               │
│       ├── GridWorker (MPSC channel, ordered processing)         │
│       ├── Terminal Parser (native VTE)                          │
│       └── Cell Converter (native → xterm format)                │
│       ↓ Tauri emit() / invoke()                                 │
│  TypeScript Frontend                                            │
│       ├── grid-buffer-injector.ts (Direct Buffer Injection)     │
│       └── ACK Handshake (flow control)                          │
│       ↓                                                         │
│  xterm.js WebGL Renderer                                        │
│                                                                 │
└─────────────────────────────────────────────────────────────────┘

Key Components

Why This Architecture?

The Problem with Traditional Terminals

Standard xterm.js architecture:
PTY → JS VTE Parser (slow) → DOM Manipulation → WebGL
Result: High CPU, potential for jitter during bulk output

Monolex’s Solution

Grid Mode v2 architecture:
PTY → Native VTE (fast) → Cell Conversion → Buffer Injection → WebGL
Result: Lower CPU, stable rendering due to native parsing + ACK flow control
Result: Significant CPU reduction compared to standard xterm.js.

Core Principles

SMPC (Simplicity is Managed Part Chaos)

  • Simple solutions over complex ones
  • Each component has a single responsibility
  • Let simplicity guide architecture

OFAC (Order is a Feature of Accepted Chaos)

  • Accept complexity where it naturally emerges
  • Let order emerge from well-designed constraints
  • Don’t force patterns that don’t fit

Technology Stack

LayerTechnologyPurpose
App FrameworkTauri 2.0Native app with web frontend
BackendRustPerformance-critical operations
FrontendTypeScriptUI and user interaction
PTY Managementpty-daemon-rustSession lifecycle, Unix sockets
VTE ParsingNative RustANSI sequence processing
Renderingxterm.js WebGLGPU-accelerated display
IPCTauri EventsAsync communication

Next Steps