# mr-context/ruji architecture

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

- Interactive diagram: https://gitdiagram.com/mr-context/ruji
- Repository: https://github.com/mr-context/ruji

## Overview

Ruji is a local semantic emoji and Nerd Font icon picker. The main flow is a global shortcut opening a cursor-positioned capsule, semantic search, selection, then clipboard and keyboard paste into the previously active app. The graph covers the UI, model/index, platform integrations, and documented GNOME cursor service. Source excerpts show the main calls; the extension-to-Linux D-Bus relationship is documented in the extension but Linux setup of that extension is not shown.

Main entry points: [`src/app.rs`](https://github.com/mr-context/ruji/blob/master/src/app.rs) (Search capsule), [`src/main.rs`](https://github.com/mr-context/ruji/blob/master/src/main.rs) (App startup), [`src/linux.rs`](https://github.com/mr-context/ruji/blob/master/src/linux.rs) (Global shortcut), [`src/win.rs`](https://github.com/mr-context/ruji/blob/master/src/win.rs) (Windows desktop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Picker app"]
  node_runtime["App startup<br/>[main.rs]"]
  node_picker["Search capsule<br/>[app.rs]"]
end

subgraph group_search["Semantic search"]
  node_modelassets["Embedded model files"]
  node_modelsetup["Model setup<br/>[main.rs]"]
  node_semantic["Semantic index<br/>[modele.rs]"]
end

subgraph group_platform["Platform integration"]
  node_shortcut["Global shortcut<br/>[linux.rs]"]
  node_linux["Linux desktop<br/>[linux.rs]"]
  node_windows["Windows desktop<br/>[win.rs]"]
  node_clipboard["Clipboard and paste<br/>[linux.rs]"]
end

subgraph group_pointer["Cursor service"]
  node_gnome["GNOME pointer extension<br/>[extension.js]"]
end

node_user(("Desktop user"))
node_target["Active application"]

node_user -->|"invokes"| node_shortcut
node_shortcut -->|"requests toggle"| node_picker
node_runtime -->|"registers"| node_shortcut
node_runtime -->|"starts loader"| node_modelsetup
node_modelassets -->|"provides files"| node_modelsetup
node_modelsetup -->|"loads index"| node_semantic
node_runtime -->|"creates UI"| node_picker
node_picker -->|"searches query"| node_semantic
node_picker -->|"reads cursor and focus"| node_linux
node_picker -->|"reads cursor and focus"| node_windows
node_picker -->|"pastes selection"| node_clipboard
node_clipboard -->|"writes pasted symbol"| node_target
node_linux -->|"queries position"| node_gnome
node_gnome -->|"returns coordinates"| node_linux
node_user -->|"types and selects"| node_picker
node_windows -->|"sends paste"| node_target

click node_runtime "https://github.com/mr-context/ruji/blob/master/src/main.rs"
click node_picker "https://github.com/mr-context/ruji/blob/master/src/app.rs"
click node_shortcut "https://github.com/mr-context/ruji/blob/master/src/linux.rs"
click node_linux "https://github.com/mr-context/ruji/blob/master/src/linux.rs"
click node_windows "https://github.com/mr-context/ruji/blob/master/src/win.rs"
click node_modelassets "https://github.com/mr-context/ruji/tree/master/models"
click node_modelsetup "https://github.com/mr-context/ruji/blob/master/src/main.rs"
click node_semantic "https://github.com/mr-context/ruji/blob/master/src/modele.rs"
click node_clipboard "https://github.com/mr-context/ruji/blob/master/src/linux.rs"
click node_gnome "https://github.com/mr-context/ruji/blob/master/gnome-extension/ruji-pointer%40ruji.local/extension.js"

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_runtime,node_picker,node_user toneBlue
class node_modelassets,node_modelsetup,node_semantic toneAmber
class node_shortcut,node_linux,node_windows,node_clipboard toneMint
class node_gnome toneRose
class node_target toneIndigo
```

## Components

### Picker app

- [App startup](https://github.com/mr-context/ruji/blob/master/src/main.rs): `src/main.rs`
- [Search capsule](https://github.com/mr-context/ruji/blob/master/src/app.rs): `src/app.rs`

### Semantic search

- [Embedded model files](https://github.com/mr-context/ruji/tree/master/models): `models`
- [Model setup](https://github.com/mr-context/ruji/blob/master/src/main.rs): `src/main.rs`
- [Semantic index](https://github.com/mr-context/ruji/blob/master/src/modele.rs): `src/modele.rs`

### Platform integration

- [Global shortcut](https://github.com/mr-context/ruji/blob/master/src/linux.rs): `src/linux.rs`
- [Linux desktop](https://github.com/mr-context/ruji/blob/master/src/linux.rs): `src/linux.rs`
- [Windows desktop](https://github.com/mr-context/ruji/blob/master/src/win.rs): `src/win.rs`
- [Clipboard and paste](https://github.com/mr-context/ruji/blob/master/src/linux.rs): `src/linux.rs`

### Cursor service

- [GNOME pointer extension](https://github.com/mr-context/ruji/blob/master/gnome-extension/ruji-pointer%40ruji.local/extension.js): `gnome-extension/ruji-pointer@ruji.local/extension.js`

### Other components

- **Desktop user**
- **Active application**

## Connections

- Desktop user → Global shortcut: invokes (evidence: `README.md`)
- Global shortcut → Search capsule: requests toggle (evidence: `src/linux.rs`)
- App startup → Global shortcut: registers (evidence: `src/main.rs`)
- App startup → Model setup: starts loader (evidence: `src/main.rs`)
- Embedded model files → Model setup: provides files (evidence: `src/main.rs`)
- Model setup → Semantic index: loads index (evidence: `src/main.rs`)
- App startup → Search capsule: creates UI (evidence: `src/main.rs`)
- Search capsule → Semantic index: searches query (evidence: `src/app.rs`)
- Search capsule → Linux desktop: reads cursor and focus (evidence: `src/app.rs`)
- Search capsule → Windows desktop: reads cursor and focus (evidence: `src/app.rs`)
- Search capsule → Clipboard and paste: pastes selection (evidence: `src/app.rs`)
- Clipboard and paste → Active application: writes pasted symbol (evidence: `README.md`)
- Linux desktop → GNOME pointer extension: queries position (evidence: `src/linux.rs`)
- GNOME pointer extension → Linux desktop: returns coordinates (evidence: `gnome-extension/ruji-pointer@ruji.local/extension.js`)
- Desktop user → Search capsule: types and selects (evidence: `README.md`)
- Windows desktop → Active application: sends paste (evidence: `src/win.rs`)
