# shner-elmo/flashtext2-rs architecture

> Architecture diagram of the GitHub repository shner-elmo/flashtext2-rs, 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/shner-elmo/flashtext2-rs
- Repository: https://github.com/shner-elmo/flashtext2-rs

## Overview

Flashtext2 is a Rust library for registering keywords, extracting matches (optionally with spans), and replacing matched text. The user selects a case-sensitive or case-insensitive KeywordProcessor; both expose the shared trie-based implementation, which tokenizes text on Unicode word boundaries. The README also documents bulk registration and case-insensitive matching. The sampled implementation shows extraction and replacement methods, though its replacement code appends the matched keyword rather than its configured clean word. The graph reflects visible calls and documented capabilities; it does not infer unsampled behavior.

Main entry points: [`src/shared.rs`](https://github.com/shner-elmo/flashtext2-rs/blob/master/src/shared.rs) (Keyword processor), [`src/lib.rs`](https://github.com/shner-elmo/flashtext2-rs/blob/master/src/lib.rs) (Case-sensitive API)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("Library user"))
node_sensitive["Case-sensitive API<br/>[lib.rs]"]
node_insensitive["Case-insensitive API<br/>[lib.rs]"]
node_processor["Keyword processor<br/>[shared.rs]"]
node_trie["Keyword trie<br/>[shared.rs]"]
node_tokenizer["Unicode tokenization<br/>[shared.rs]"]
node_unicode["Unicode segmentation"]

node_user -->|"uses"| node_sensitive
node_user -->|"uses"| node_insensitive
node_sensitive -->|"exports"| node_processor
node_insensitive -->|"exports"| node_processor
node_processor -->|"updates"| node_trie
node_processor -->|"tokenizes with"| node_tokenizer
node_tokenizer -->|"uses"| node_unicode
node_processor -->|"searches"| node_trie

click node_sensitive "https://github.com/shner-elmo/flashtext2-rs/blob/master/src/lib.rs"
click node_insensitive "https://github.com/shner-elmo/flashtext2-rs/blob/master/src/lib.rs"
click node_processor "https://github.com/shner-elmo/flashtext2-rs/blob/master/src/shared.rs"
click node_trie "https://github.com/shner-elmo/flashtext2-rs/blob/master/src/shared.rs"
click node_tokenizer "https://github.com/shner-elmo/flashtext2-rs/blob/master/src/shared.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_user toneBlue
class node_sensitive,node_insensitive toneMint
class node_processor,node_trie,node_tokenizer toneTeal
class node_unicode toneIndigo
```

## Components

### Other components

- **Library user**
- [Case-sensitive API](https://github.com/shner-elmo/flashtext2-rs/blob/master/src/lib.rs): `src/lib.rs`
- [Case-insensitive API](https://github.com/shner-elmo/flashtext2-rs/blob/master/src/lib.rs): `src/lib.rs`
- [Keyword processor](https://github.com/shner-elmo/flashtext2-rs/blob/master/src/shared.rs): `src/shared.rs`
- [Keyword trie](https://github.com/shner-elmo/flashtext2-rs/blob/master/src/shared.rs): `src/shared.rs`
- [Unicode tokenization](https://github.com/shner-elmo/flashtext2-rs/blob/master/src/shared.rs): `src/shared.rs`
- **Unicode segmentation**

## Connections

- Library user → Case-sensitive API: uses (evidence: `README.md`)
- Library user → Case-insensitive API: uses (evidence: `README.md`)
- Case-sensitive API → Keyword processor: exports (evidence: `src/lib.rs`)
- Case-insensitive API → Keyword processor: exports (evidence: `src/lib.rs`)
- Keyword processor → Keyword trie: updates (evidence: `src/shared.rs`)
- Keyword processor → Unicode tokenization: tokenizes with (evidence: `src/shared.rs`)
- Unicode tokenization → Unicode segmentation: uses (evidence: `src/shared.rs`)
- Keyword processor → Keyword trie: searches (evidence: `src/shared.rs`)
