# ereinaimer/taurine architecture

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

- Interactive diagram: https://gitdiagram.com/ereinaimer/taurine
- Repository: https://github.com/ereinaimer/taurine

## Overview

#### Purpose and workspace
Taurine is a local-first, cross-platform desktop automation system: text expansion, hotkeys, scripts, dynamic values, inline math, and optional streamed AI inserted into the active application. The Rust workspace separates shared domain logic (`core`), a background input/injection daemon (`daemon`), CLI, terminal UI, and a small startup binary. Workspace definition: `Cargo.toml`.

#### User-facing entry points
- CLI binary parses management, service, AI, import/export, and automation commands: `cli/src/main.rs`, `cli/src/commands/mod.rs`.
- Interactive Ratatui terminal UI manages the library, settings, and daemon state: `tui/src/lib.rs`, `tui/src/app.rs`.
- Background daemon is the runtime required for global triggers and hotkeys: `daemon/src/lib.rs`, `daemon/src/server.rs`.
- Startup executable likely launches/coordinates application startup: `startup/src/main.rs`.

#### Core domain, persistence, and settings
`core` owns reusable models and business operations. Its database layer initializes/migrates/seeds a local database, then exposes CRUD for automations, settings, and usage statistics: `core/src/db/init/migrate.rs`, `core/src/db/crud/automations/mod.rs`, `core/src/db/crud/stats/recorder.rs`. Settings are managed and applied separately, forming the policy/configuration boundary used by CLI, TUI, and daemon: `core/src/settings/manager.rs`, `core/src/settings/apply.rs`. Automations and optionally settings/metrics cross the machine boundary via encrypted `.tau` import/export: `core/src/exchange/export.rs`, `core/src/exchange/import.rs`, `core/src/exchange/crypto.rs`.

#### Trigger-to-action pipeline
The daemon listens to global keyboard activity, supervises hooks, and dispatches recognized input sequences: `daemon/src/hook/listener.rs`, `daemon/src/hook/supervisor.rs`, `daemon/src/hook/dispatch.rs`. It evaluates hotkeys and text-trigger state, including inline specialized modes such as AI: `daemon/src/hotkey_evaluator.rs`, `daemon/src/engine/mod.rs`, `daemon/src/engine/ai/stream.rs`. This is the privileged OS-facing boundary: raw input is platform-specific, while matching/evaluation is centralized before execution.

#### Expansion and automation engine
The shared engine resolves an automation into output or actions. It maintains trigger/buffer/state, catalogs automations, evaluates content, and supports shell execution, math, emoji, conversions, and AI sessions: `core/src/engine/buffer.rs`, `core/src/engine/evaluator.rs`, `core/src/engine/shell/mod.rs`. Variable interpolation parses user placeholders, retrieves custom/system values, then applies chained transformers: `core/src/engine/variables/interpolate.rs`, `core/src/engine/variables/registry.rs`, `core/src/engine/variables/system/transformers/mod.rs`. System variables can access clipboard, files, environment, HTTP/network, commands, and image data; these are explicit external-effect boundaries: `core/src/engine/variables/system/http.rs`, `core/src/engine/variables/system/exec.rs`, `core/src/engine/variables/system/file.rs`.

#### Injection and platform adaptation
After evaluation, the daemon gates and injects text or simulated keyboard actions, with clipboard support and notifications/audio feedback: `daemon/src/injector/gate.rs`, `daemon/src/injector/inject.rs`, `daemon/src/injector/clipboard.rs`. OS adapters isolate Windows, macOS, and Linux implementation details; Linux additionally supports evdev/uinput and several active-window/toplevel mechanisms (AT-SPI DBus, KWin DBus, wlroots Wayland, X11): `daemon/src/platform/windows/mod.rs`, `daemon/src/platform/macos/mod.rs`, `daemon/src/platform/linux/mod.rs`.

#### Interprocess, services, and external dependencies
CLI/TUI communicate with daemon functionality through a protobuf-defined RPC boundary: `proto/daemon.proto`, `core/src/rpc.rs`, `daemon/src/server.rs`. Daemon lifecycle integrates with native Unix/Windows services: `core/src/service/unix.rs`, `core/src/service/windows.rs`. AI is optional and network-backed through configurable providers/models/API credentials; local automation otherwise remains offline: `core/src/ai/mod.rs`, `core/src/engine/ai_session.rs`, `daemon/src/engine/ai/stream.rs`.

Main entry points: [`core/src/engine/evaluator.rs`](https://github.com/ereinaimer/taurine/blob/main/core/src/engine/evaluator.rs) (Core domain), [`daemon/src/server.rs`](https://github.com/ereinaimer/taurine/blob/main/daemon/src/server.rs) (Daemon server), [`daemon/src/hook/listener.rs`](https://github.com/ereinaimer/taurine/blob/main/daemon/src/hook/listener.rs) (Global input hooks), [`daemon/src/engine/mod.rs`](https://github.com/ereinaimer/taurine/blob/main/daemon/src/engine/mod.rs) (Trigger evaluator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry points"]
  node_cli["CLI<br/>Rust binary<br/>[main.rs]"]
  node_tui["Terminal UI<br/>Ratatui app<br/>[app.rs]"]
  node_startup["Startup launcher<br/>Rust binary<br/>[main.rs]"]
end

subgraph group_core["Shared core"]
  node_domain["Core domain<br/>shared business logic<br/>[evaluator.rs]"]
  node_database[("Local database<br/>persistence layer<br/>[migrate.rs]")]
  node_automation_crud["Automation library<br/>CRUD repository<br/>[mod.rs]"]
  node_settings["Settings policy<br/>settings manager<br/>[manager.rs]"]
  node_exchange["Encrypted exchange<br/>import/export<br/>[export.rs]"]
  node_variables["Variable pipeline<br/>interpolation and transforms<br/>[interpolate.rs]"]
  node_ai_core["AI sessions<br/>optional AI integration<br/>[ai_session.rs]"]
  node_rpc_contract["Daemon RPC<br/>protobuf contract<br/>[daemon.proto]"]
end

subgraph group_daemon["Daemon runtime"]
  node_daemon_server["Daemon server<br/>RPC service<br/>[server.rs]"]
  node_input_hooks["Global input hooks<br/>hook subsystem<br/>[listener.rs]"]
  node_trigger_engine["Trigger evaluator<br/>daemon engine<br/>[mod.rs]"]
  node_injection["Injection gate<br/>privileged output<br/>[gate.rs]"]
  node_ai_stream["AI streaming<br/>daemon stream mode<br/>[stream.rs]"]
end

subgraph group_platform["OS and external boundaries"]
  node_effects{{"System effects<br/>external value access<br/>[http.rs]"}}
  node_os_adapters{{"OS adapters<br/>platform integration<br/>[mod.rs]"}}
  node_native_services["Native services<br/>lifecycle integration<br/>[unix.rs]"]
end

node_cli -->|"manages"| node_domain
node_tui -->|"manages"| node_domain
node_cli -->|"uses"| node_rpc_contract
node_tui -->|"uses"| node_rpc_contract
node_startup -->|"starts"| node_daemon_server
node_rpc_contract -->|"defines API"| node_daemon_server
node_domain -->|"loads automations"| node_automation_crud
node_automation_crud -->|"persists"| node_database
node_settings -->|"persists"| node_database
node_domain -->|"interpolates"| node_variables
node_variables -->|"accesses"| node_effects
node_domain -->|"runs sessions"| node_ai_core
node_exchange -->|"imports/exports"| node_database
node_daemon_server -->|"runs"| node_input_hooks
node_input_hooks -->|"dispatches input"| node_trigger_engine
node_trigger_engine -->|"evaluates automation"| node_domain
node_trigger_engine -->|"activates"| node_ai_stream
node_ai_stream -->|"uses"| node_ai_core
node_domain -->|"produces output"| node_injection
node_injection -->|"injects through"| node_os_adapters
node_input_hooks -->|"captures through"| node_os_adapters
node_daemon_server -->|"lifecycle"| node_native_services

click node_cli "https://github.com/ereinaimer/taurine/blob/main/cli/src/main.rs"
click node_tui "https://github.com/ereinaimer/taurine/blob/main/tui/src/app.rs"
click node_startup "https://github.com/ereinaimer/taurine/blob/main/startup/src/main.rs"
click node_domain "https://github.com/ereinaimer/taurine/blob/main/core/src/engine/evaluator.rs"
click node_database "https://github.com/ereinaimer/taurine/blob/main/core/src/db/init/migrate.rs"
click node_automation_crud "https://github.com/ereinaimer/taurine/blob/main/core/src/db/crud/automations/mod.rs"
click node_settings "https://github.com/ereinaimer/taurine/blob/main/core/src/settings/manager.rs"
click node_exchange "https://github.com/ereinaimer/taurine/blob/main/core/src/exchange/export.rs"
click node_variables "https://github.com/ereinaimer/taurine/blob/main/core/src/engine/variables/interpolate.rs"
click node_effects "https://github.com/ereinaimer/taurine/blob/main/core/src/engine/variables/system/http.rs"
click node_ai_core "https://github.com/ereinaimer/taurine/blob/main/core/src/engine/ai_session.rs"
click node_rpc_contract "https://github.com/ereinaimer/taurine/blob/main/proto/daemon.proto"
click node_daemon_server "https://github.com/ereinaimer/taurine/blob/main/daemon/src/server.rs"
click node_input_hooks "https://github.com/ereinaimer/taurine/blob/main/daemon/src/hook/listener.rs"
click node_trigger_engine "https://github.com/ereinaimer/taurine/blob/main/daemon/src/engine/mod.rs"
click node_injection "https://github.com/ereinaimer/taurine/blob/main/daemon/src/injector/gate.rs"
click node_os_adapters "https://github.com/ereinaimer/taurine/blob/main/daemon/src/platform/linux/mod.rs"
click node_native_services "https://github.com/ereinaimer/taurine/blob/main/core/src/service/unix.rs"
click node_ai_stream "https://github.com/ereinaimer/taurine/blob/main/daemon/src/engine/ai/stream.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_cli,node_tui,node_startup toneBlue
class node_domain,node_database,node_automation_crud,node_settings,node_exchange,node_variables,node_ai_core,node_rpc_contract toneAmber
class node_daemon_server,node_input_hooks,node_trigger_engine,node_injection,node_ai_stream toneMint
class node_effects,node_os_adapters,node_native_services toneRose
```

## Components

### User entry points

- [CLI](https://github.com/ereinaimer/taurine/blob/main/cli/src/main.rs): Rust binary · Management, service, AI, exchange, and automation commands. · `cli/src/main.rs`
- [Terminal UI](https://github.com/ereinaimer/taurine/blob/main/tui/src/app.rs): Ratatui app · Interactive library, settings, and daemon management. · `tui/src/app.rs`
- [Startup launcher](https://github.com/ereinaimer/taurine/blob/main/startup/src/main.rs): Rust binary · `startup/src/main.rs`

### Shared core

- [Core domain](https://github.com/ereinaimer/taurine/blob/main/core/src/engine/evaluator.rs): shared business logic · `core/src/engine/evaluator.rs`
- [Local database](https://github.com/ereinaimer/taurine/blob/main/core/src/db/init/migrate.rs): persistence layer · Migrates and stores automations, settings, and usage. · `core/src/db/init/migrate.rs`
- [Automation library](https://github.com/ereinaimer/taurine/blob/main/core/src/db/crud/automations/mod.rs): CRUD repository · `core/src/db/crud/automations/mod.rs`
- [Settings policy](https://github.com/ereinaimer/taurine/blob/main/core/src/settings/manager.rs): settings manager · `core/src/settings/manager.rs`
- [Encrypted exchange](https://github.com/ereinaimer/taurine/blob/main/core/src/exchange/export.rs): import/export · Transfers .tau automations and optional settings or metrics. · `core/src/exchange/export.rs`
- [Variable pipeline](https://github.com/ereinaimer/taurine/blob/main/core/src/engine/variables/interpolate.rs): interpolation and transforms · Resolves placeholders, custom/system values, and chained transformers. · `core/src/engine/variables/interpolate.rs`
- [AI sessions](https://github.com/ereinaimer/taurine/blob/main/core/src/engine/ai_session.rs): optional AI integration · Configurable providers, models, and credentials. · `core/src/engine/ai_session.rs`
- [Daemon RPC](https://github.com/ereinaimer/taurine/blob/main/proto/daemon.proto): protobuf contract · `proto/daemon.proto`

### Daemon runtime

- [Daemon server](https://github.com/ereinaimer/taurine/blob/main/daemon/src/server.rs): RPC service · Exposes background runtime functions to clients. · `daemon/src/server.rs`
- [Global input hooks](https://github.com/ereinaimer/taurine/blob/main/daemon/src/hook/listener.rs): hook subsystem · Listens to raw keyboard input and supervises platform hooks. · `daemon/src/hook/listener.rs`
- [Trigger evaluator](https://github.com/ereinaimer/taurine/blob/main/daemon/src/engine/mod.rs): daemon engine · Matches hotkeys and text-trigger state, including AI mode. · `daemon/src/engine/mod.rs`
- [Injection gate](https://github.com/ereinaimer/taurine/blob/main/daemon/src/injector/gate.rs): privileged output · Gates and injects text or simulated keys with clipboard support. · `daemon/src/injector/gate.rs`
- [AI streaming](https://github.com/ereinaimer/taurine/blob/main/daemon/src/engine/ai/stream.rs): daemon stream mode · Streams optional AI output during inline expansion. · `daemon/src/engine/ai/stream.rs`

### OS and external boundaries

- [System effects](https://github.com/ereinaimer/taurine/blob/main/core/src/engine/variables/system/http.rs): external value access · Clipboard, files, environment, HTTP, commands, and image data. · `core/src/engine/variables/system/http.rs`
- [OS adapters](https://github.com/ereinaimer/taurine/blob/main/daemon/src/platform/linux/mod.rs): platform integration · Windows, macOS, and Linux input, window, and injection implementations. · `daemon/src/platform/linux/mod.rs`
- [Native services](https://github.com/ereinaimer/taurine/blob/main/core/src/service/unix.rs): lifecycle integration · Unix and Windows daemon service support. · `core/src/service/unix.rs`

## Connections

- CLI → Core domain: manages
- Terminal UI → Core domain: manages
- CLI → Daemon RPC: uses
- Terminal UI → Daemon RPC: uses
- Startup launcher → Daemon server: starts
- Daemon RPC → Daemon server: defines API
- Core domain → Automation library: loads automations
- Automation library → Local database: persists
- Settings policy → Local database: persists
- Core domain → Variable pipeline: interpolates
- Variable pipeline → System effects: accesses
- Core domain → AI sessions: runs sessions
- Encrypted exchange → Local database: imports/exports
- Daemon server → Global input hooks: runs
- Global input hooks → Trigger evaluator: dispatches input
- Trigger evaluator → Core domain: evaluates automation
- Trigger evaluator → AI streaming: activates
- AI streaming → AI sessions: uses
- Core domain → Injection gate: produces output
- Injection gate → OS adapters: injects through
- Global input hooks → OS adapters: captures through
- Daemon server → Native services: lifecycle
