# ethangreen-dev/lovely-injector architecture

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

- Interactive diagram: https://gitdiagram.com/ethangreen-dev/lovely-injector
- Repository: https://github.com/ethangreen-dev/lovely-injector

## Overview

Lovely injects into a running LÖVE game, intercepts Lua buffer loading, loads a mod’s patch definitions and assets, and applies the matching injections before Lua executes the buffer. The patch system supports module, copy, pattern, regex, and variable-substitution patches; the README also documents priority ordering and reloadable mods. Platform entry points and core patching are excerpted, but several implementation details and native bindings are not, so uncertain connections are omitted.

Main entry points: [`crates/lovely-core/src/patch/table.rs`](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/table.rs) (Patch table), [`crates/lovely-core/src/lib.rs`](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/lib.rs) (Lovely runtime), [`crates/lovely-unix/src/lib.rs`](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-unix/src/lib.rs) (Unix injector), [`crates/lovely-core/src/dump.rs`](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/dump.rs) (Patch dumps)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform injectors"]
  node_unix["Unix injector<br/>[lib.rs]"]
  node_unixlua["Unix Lua loader<br/>[lualib.rs]"]
  node_windows["Windows injector<br/>[lib.rs]"]
  node_winlua["Windows Lua loader<br/>[lualib.rs]"]
  node_dobby["Dobby FFI<br/>[ffi.rs]"]
  node_cbridge["C interface<br/>[lib.rs]"]
end

subgraph group_runtime["Runtime core"]
  node_lovely["Lovely runtime<br/>[lib.rs]"]
end

subgraph group_patching["Patch system"]
  node_table["Patch table<br/>[table.rs]"]
  node_loader["Mod patch loader<br/>[loader.rs]"]
  node_module["Module patches<br/>[module.rs]"]
  node_copy["Copy patches<br/>[copy.rs]"]
  node_pattern["Pattern patches<br/>[pattern.rs]"]
  node_regex["Regex patches<br/>[regex.rs]"]
  node_vars["Variable substitution<br/>[vars.rs]"]
end

subgraph group_support["Lua and diagnostics"]
  node_luaapi["Lua API access<br/>[sys.rs]"]
  node_cursor["Rope regex cursor"]
  node_dump["Patch dumps<br/>[dump.rs]"]
  node_logging["Logging<br/>[log.rs]"]
end

node_game(("LÖVE game"))

node_game -->|"loads injector"| node_unix
node_game -->|"loads injector"| node_windows
node_unix -->|"initializes runtime"| node_lovely
node_windows -->|"initializes runtime"| node_lovely
node_unix -->|"detours Lua loads"| node_lovely
node_windows -->|"detours Lua loads"| node_lovely
node_unix -->|"loads Lua library"| node_unixlua
node_unixlua -->|"provides Lua bindings"| node_luaapi
node_lovely -->|"loads and applies"| node_table
node_lovely -->|"writes source dumps"| node_dump
node_lovely -->|"uses Lua state"| node_luaapi
node_table -->|"loads patch definitions"| node_loader
node_table -->|"applies module patches"| node_module
node_table -->|"applies copy patches"| node_copy
node_table -->|"applies pattern patches"| node_pattern
node_table -->|"applies regex patches"| node_regex
node_table -->|"interpolates variables"| node_vars
node_table -->|"preloads modules"| node_luaapi
node_regex -->|"scans rope chunks"| node_cursor
node_pattern -->|"records patch regions"| node_dump
node_regex -->|"records patch regions"| node_dump
node_copy -->|"records patch details"| node_dump
node_lovely -->|"returns patched buffer"| node_game

click node_unix "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-unix/src/lib.rs"
click node_unixlua "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-unix/src/lualib.rs"
click node_windows "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-win/src/lib.rs"
click node_winlua "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-win/src/lualib.rs"
click node_lovely "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/lib.rs"
click node_table "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/table.rs"
click node_loader "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/loader.rs"
click node_module "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/module.rs"
click node_copy "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/copy.rs"
click node_pattern "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/pattern.rs"
click node_regex "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/regex.rs"
click node_vars "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/vars.rs"
click node_luaapi "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/sys.rs"
click node_cursor "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/chunk_vec_cursor.rs"
click node_dump "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/dump.rs"
click node_logging "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/log.rs"
click node_dobby "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/dobby-sys/src/ffi.rs"
click node_cbridge "https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/liblovely/src/lib.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_unix,node_unixlua,node_windows,node_winlua,node_dobby,node_cbridge toneBlue
class node_lovely toneAmber
class node_table,node_loader,node_module,node_copy,node_pattern,node_regex,node_vars toneMint
class node_luaapi,node_cursor,node_dump,node_logging toneRose
class node_game toneIndigo
```

## Components

### Platform injectors

- [Unix injector](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-unix/src/lib.rs): `crates/lovely-unix/src/lib.rs`
- [Unix Lua loader](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-unix/src/lualib.rs): `crates/lovely-unix/src/lualib.rs`
- [Windows injector](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-win/src/lib.rs): `crates/lovely-win/src/lib.rs`
- [Windows Lua loader](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-win/src/lualib.rs): `crates/lovely-win/src/lualib.rs`
- [Dobby FFI](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/dobby-sys/src/ffi.rs): `crates/dobby-sys/src/ffi.rs`
- [C interface](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/liblovely/src/lib.rs): `crates/liblovely/src/lib.rs`

### Runtime core

- [Lovely runtime](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/lib.rs): `crates/lovely-core/src/lib.rs`

### Patch system

- [Patch table](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/table.rs): `crates/lovely-core/src/patch/table.rs`
- [Mod patch loader](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/loader.rs): `crates/lovely-core/src/patch/loader.rs`
- [Module patches](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/module.rs): `crates/lovely-core/src/patch/module.rs`
- [Copy patches](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/copy.rs): `crates/lovely-core/src/patch/copy.rs`
- [Pattern patches](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/pattern.rs): `crates/lovely-core/src/patch/pattern.rs`
- [Regex patches](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/regex.rs): `crates/lovely-core/src/patch/regex.rs`
- [Variable substitution](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/patch/vars.rs): `crates/lovely-core/src/patch/vars.rs`

### Lua and diagnostics

- [Lua API access](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/sys.rs): `crates/lovely-core/src/sys.rs`
- [Rope regex cursor](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/chunk_vec_cursor.rs): `crates/lovely-core/src/chunk_vec_cursor.rs`
- [Patch dumps](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/dump.rs): `crates/lovely-core/src/dump.rs`
- [Logging](https://github.com/ethangreen-dev/lovely-injector/blob/master/crates/lovely-core/src/log.rs): `crates/lovely-core/src/log.rs`

### Other components

- **LÖVE game**

## Connections

- LÖVE game → Unix injector: loads injector (evidence: `crates/lovely-unix/src/lib.rs`)
- LÖVE game → Windows injector: loads injector (evidence: `crates/lovely-win/src/lib.rs`)
- Unix injector → Lovely runtime: initializes runtime (evidence: `crates/lovely-unix/src/lib.rs`)
- Windows injector → Lovely runtime: initializes runtime (evidence: `crates/lovely-win/src/lib.rs`)
- Unix injector → Lovely runtime: detours Lua loads (evidence: `crates/lovely-unix/src/lib.rs`)
- Windows injector → Lovely runtime: detours Lua loads (evidence: `crates/lovely-win/src/lib.rs`)
- Unix injector → Unix Lua loader: loads Lua library (evidence: `crates/lovely-unix/src/lib.rs`)
- Unix Lua loader → Lua API access: provides Lua bindings (evidence: `crates/lovely-unix/src/lualib.rs`)
- Lovely runtime → Patch table: loads and applies (evidence: `crates/lovely-core/src/lib.rs`)
- Lovely runtime → Patch dumps: writes source dumps (evidence: `crates/lovely-core/src/lib.rs`)
- Lovely runtime → Lua API access: uses Lua state (evidence: `crates/lovely-core/src/lib.rs`)
- Patch table → Mod patch loader: loads patch definitions (evidence: `crates/lovely-core/src/patch/table.rs`)
- Patch table → Module patches: applies module patches (evidence: `crates/lovely-core/src/patch/table.rs`)
- Patch table → Copy patches: applies copy patches (evidence: `crates/lovely-core/src/patch/table.rs`)
- Patch table → Pattern patches: applies pattern patches (evidence: `crates/lovely-core/src/patch/table.rs`)
- Patch table → Regex patches: applies regex patches (evidence: `crates/lovely-core/src/patch/table.rs`)
- Patch table → Variable substitution: interpolates variables (evidence: `crates/lovely-core/src/patch/table.rs`)
- Patch table → Lua API access: preloads modules (evidence: `crates/lovely-core/src/patch/table.rs`)
- Regex patches → Rope regex cursor: scans rope chunks (evidence: `crates/lovely-core/src/patch/regex.rs`)
- Pattern patches → Patch dumps: records patch regions (evidence: `crates/lovely-core/src/patch/pattern.rs`)
- Regex patches → Patch dumps: records patch regions (evidence: `crates/lovely-core/src/patch/regex.rs`)
- Copy patches → Patch dumps: records patch details (evidence: `crates/lovely-core/src/patch/copy.rs`)
- Lovely runtime → LÖVE game: returns patched buffer (evidence: `crates/lovely-core/src/lib.rs`)
