# kakilangit/matcha architecture

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

- Interactive diagram: https://gitdiagram.com/kakilangit/matcha
- Repository: https://github.com/kakilangit/matcha

## Overview

Matcha is a native regex workbench: users edit a pattern and sample text, choose flags and an engine, and inspect live matches and replacement previews. The main window coordinates those actions and also exposes pattern saving, Rust snippet generation, and pattern explanations. The graph separates the UI, regex processing, and supporting workbench features. Edges reflect the excerpts and SOURCE INDEX references; unsampled UI details are included only where the README documents the capability.

Main entry points: [`src/app.rs`](https://github.com/kakilangit/matcha/blob/main/src/app.rs) (Main window), [`src/main.rs`](https://github.com/kakilangit/matcha/blob/main/src/main.rs) (App startup), [`src/editor.rs`](https://github.com/kakilangit/matcha/blob/main/src/editor.rs) (Text editor), [`src/engine.rs`](https://github.com/kakilangit/matcha/blob/main/src/engine.rs) (Regex compile)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Workbench UI"]
  node_application["App startup<br/>[main.rs]"]
  node_window["Main window<br/>[app.rs]"]
  node_editor["Text editor<br/>[editor.rs]"]
end

subgraph group_regex["Regex Processing"]
  node_compile["Regex compile<br/>[engine.rs]"]
  node_matching["Match and replace<br/>[engine.rs]"]
end

subgraph group_features["Workbench Features"]
  node_library[("Pattern library<br/>[library.rs]")]
  node_codegen["Rust snippet<br/>[codegen.rs]"]
  node_explain["Pattern explanation<br/>[explain.rs]"]
end

subgraph group_presentation["Presentation"]
  node_theme["Theme<br/>[theme.rs]"]
end

node_user(("Workbench user"))

node_user -->|"launches"| node_application
node_application -->|"opens"| node_window
node_window -->|"uses"| node_editor
node_window -->|"configures"| node_compile
node_window -->|"recomputes"| node_matching
node_window -->|"manages"| node_library
node_window -->|"generates snippet"| node_codegen
node_window -->|"requests explanation"| node_explain
node_window -->|"uses"| node_theme
node_editor -->|"renders with"| node_theme
node_compile -->|"provides regex"| node_matching

click node_application "https://github.com/kakilangit/matcha/blob/main/src/main.rs"
click node_window "https://github.com/kakilangit/matcha/blob/main/src/app.rs"
click node_editor "https://github.com/kakilangit/matcha/blob/main/src/editor.rs"
click node_compile "https://github.com/kakilangit/matcha/blob/main/src/engine.rs"
click node_matching "https://github.com/kakilangit/matcha/blob/main/src/engine.rs"
click node_library "https://github.com/kakilangit/matcha/blob/main/src/library.rs"
click node_codegen "https://github.com/kakilangit/matcha/blob/main/src/codegen.rs"
click node_explain "https://github.com/kakilangit/matcha/blob/main/src/explain.rs"
click node_theme "https://github.com/kakilangit/matcha/blob/main/src/theme.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_application,node_window,node_editor,node_user toneBlue
class node_compile,node_matching toneAmber
class node_library,node_codegen,node_explain toneMint
class node_theme toneRose
```

## Components

### Workbench UI

- [App startup](https://github.com/kakilangit/matcha/blob/main/src/main.rs): `src/main.rs`
- [Main window](https://github.com/kakilangit/matcha/blob/main/src/app.rs): `src/app.rs`
- [Text editor](https://github.com/kakilangit/matcha/blob/main/src/editor.rs): `src/editor.rs`

### Regex Processing

- [Regex compile](https://github.com/kakilangit/matcha/blob/main/src/engine.rs): `src/engine.rs`
- [Match and replace](https://github.com/kakilangit/matcha/blob/main/src/engine.rs): `src/engine.rs`

### Workbench Features

- [Pattern library](https://github.com/kakilangit/matcha/blob/main/src/library.rs): `src/library.rs`
- [Rust snippet](https://github.com/kakilangit/matcha/blob/main/src/codegen.rs): `src/codegen.rs`
- [Pattern explanation](https://github.com/kakilangit/matcha/blob/main/src/explain.rs): `src/explain.rs`

### Presentation

- [Theme](https://github.com/kakilangit/matcha/blob/main/src/theme.rs): `src/theme.rs`

### Other components

- **Workbench user**

## Connections

- Workbench user → App startup: launches (evidence: `src/main.rs`)
- App startup → Main window: opens (evidence: `src/main.rs`)
- Main window → Text editor: uses (evidence: `src/app.rs`)
- Main window → Regex compile: configures (evidence: `src/app.rs`)
- Main window → Match and replace: recomputes (evidence: `src/app.rs`)
- Main window → Pattern library: manages (evidence: `src/app.rs`)
- Main window → Rust snippet: generates snippet (evidence: `src/app.rs`)
- Main window → Pattern explanation: requests explanation (evidence: `src/app.rs`)
- Main window → Theme: uses (evidence: `src/app.rs`)
- Text editor → Theme: renders with (evidence: `src/editor.rs`)
- Regex compile → Match and replace: provides regex (evidence: `src/engine.rs`)
