# aathish14/natsort-rs architecture

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

- Interactive diagram: https://gitdiagram.com/aathish14/natsort-rs
- Repository: https://github.com/aathish14/natsort-rs

## Overview

natsort-rs is a Rust natural-sorting library. Callers either sort collections directly or generate reusable sort keys; algorithm flags select numeric, path, case, and locale behavior. The core key pipeline separates input transforms, parsing, component conversion, and final key assembly, with Unicode numeric data and locale providers supporting those stages. The tree and README establish additional public APIs and optional backends, but excerpts do not expose all of their call wiring, so uncertain links are omitted.

Main entry points: [`src/parser/mod.rs`](https://github.com/aathish14/natsort-rs/blob/master/src/parser/mod.rs) (Parser Factories), [`src/parser/string.rs`](https://github.com/aathish14/natsort-rs/blob/master/src/parser/string.rs) (String Parser), [`src/locale/mod.rs`](https://github.com/aathish14/natsort-rs/blob/master/src/locale/mod.rs) (Locale Provider), [`src/key.rs`](https://github.com/aathish14/natsort-rs/blob/master/src/key.rs) (Key Generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Sorting API"]
  node_sorted["Sort Helpers<br/>[sorted.rs]"]
  node_key["Key Generation<br/>[key.rs]"]
  node_index["Index Ordering<br/>[index.rs]"]
  node_os_sort["OS Sort API<br/>[os_sort.rs]"]
  node_ns["Algorithm Flags<br/>[ns.rs]"]
end

subgraph group_pipeline["Key Pipeline"]
  node_input_transform["Input Transform<br/>[input.rs]"]
  node_component_transform["Component Transform<br/>[component.rs]"]
  node_final_transform["Final Key Transform<br/>[final_transform.rs]"]
  node_parser_factory["Parser Factories<br/>[mod.rs]"]
end

subgraph group_support["Parsing Support"]
  node_string_parser["String Parser<br/>[string.rs]"]
  node_number_parser["Number Parser<br/>[number.rs]"]
  node_path_parser["Path Parser<br/>[path.rs]"]
  node_bytes_parser["Bytes Parser<br/>[bytes.rs]"]
  node_regex["Numeric Regex<br/>[regex.rs]"]
  node_number_compat["Number Compatibility<br/>[mod.rs]"]
  node_unicode["Unicode Numerics<br/>[numbers.rs]"]
end

subgraph group_locale["Locale Backends"]
  node_locale_provider["Locale Provider<br/>[mod.rs]"]
  node_stdlib_locale["Stdlib Locale<br/>[stdlib.rs]"]
  node_icu_locale["ICU Locale<br/>[icu.rs]"]
  node_windows_locale["Windows Locale<br/>[windows.rs]"]
end

node_caller(("Library Caller"))
node_windows_service["Windows API"]

node_caller -->|"sorts with"| node_sorted
node_caller -->|"generates keys"| node_key
node_caller -->|"requests indices"| node_index
node_caller -->|"requests OS sort"| node_os_sort
node_index -->|"generates sort keys"| node_key
node_key -->|"configures parsers"| node_parser_factory
node_parser_factory -->|"creates"| node_string_parser
node_parser_factory -->|"creates"| node_number_parser
node_parser_factory -->|"creates"| node_path_parser
node_parser_factory -->|"creates"| node_bytes_parser
node_parser_factory -->|"selects regex"| node_regex
node_string_parser -->|"transforms input"| node_input_transform
node_string_parser -->|"transforms components"| node_component_transform
node_string_parser -->|"assembles key"| node_final_transform
node_number_parser -->|"parses numbers"| node_number_compat
node_number_compat -->|"checks numeric values"| node_unicode
node_input_transform -->|"reads separators"| node_locale_provider
node_string_parser -->|"uses collation"| node_locale_provider
node_locale_provider -->|"provides fallback"| node_stdlib_locale
node_locale_provider -.->|"optional backend"| node_icu_locale
node_locale_provider -.->|"optional backend"| node_windows_locale
node_os_sort -.->|"uses platform sort"| node_windows_service

click node_sorted "https://github.com/aathish14/natsort-rs/blob/master/src/sorted.rs"
click node_key "https://github.com/aathish14/natsort-rs/blob/master/src/key.rs"
click node_index "https://github.com/aathish14/natsort-rs/blob/master/src/index.rs"
click node_os_sort "https://github.com/aathish14/natsort-rs/blob/master/src/os_sort.rs"
click node_ns "https://github.com/aathish14/natsort-rs/blob/master/src/ns.rs"
click node_input_transform "https://github.com/aathish14/natsort-rs/blob/master/src/transform/input.rs"
click node_component_transform "https://github.com/aathish14/natsort-rs/blob/master/src/transform/component.rs"
click node_final_transform "https://github.com/aathish14/natsort-rs/blob/master/src/transform/final_transform.rs"
click node_parser_factory "https://github.com/aathish14/natsort-rs/blob/master/src/parser/mod.rs"
click node_string_parser "https://github.com/aathish14/natsort-rs/blob/master/src/parser/string.rs"
click node_number_parser "https://github.com/aathish14/natsort-rs/blob/master/src/parser/number.rs"
click node_path_parser "https://github.com/aathish14/natsort-rs/blob/master/src/parser/path.rs"
click node_bytes_parser "https://github.com/aathish14/natsort-rs/blob/master/src/parser/bytes.rs"
click node_regex "https://github.com/aathish14/natsort-rs/blob/master/src/regex.rs"
click node_number_compat "https://github.com/aathish14/natsort-rs/blob/master/src/compat/mod.rs"
click node_unicode "https://github.com/aathish14/natsort-rs/blob/master/src/unicode/numbers.rs"
click node_locale_provider "https://github.com/aathish14/natsort-rs/blob/master/src/locale/mod.rs"
click node_stdlib_locale "https://github.com/aathish14/natsort-rs/blob/master/src/locale/stdlib.rs"
click node_icu_locale "https://github.com/aathish14/natsort-rs/blob/master/src/locale/icu.rs"
click node_windows_locale "https://github.com/aathish14/natsort-rs/blob/master/src/locale/windows.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_sorted,node_key,node_index,node_os_sort,node_ns toneBlue
class node_input_transform,node_component_transform,node_final_transform,node_parser_factory toneAmber
class node_string_parser,node_number_parser,node_path_parser,node_bytes_parser,node_regex,node_number_compat,node_unicode,node_windows_service toneMint
class node_locale_provider,node_stdlib_locale,node_icu_locale,node_windows_locale toneRose
class node_caller toneIndigo
```

## Components

### Sorting API

- [Sort Helpers](https://github.com/aathish14/natsort-rs/blob/master/src/sorted.rs): `src/sorted.rs`
- [Key Generation](https://github.com/aathish14/natsort-rs/blob/master/src/key.rs): `src/key.rs`
- [Index Ordering](https://github.com/aathish14/natsort-rs/blob/master/src/index.rs): `src/index.rs`
- [OS Sort API](https://github.com/aathish14/natsort-rs/blob/master/src/os_sort.rs): `src/os_sort.rs`
- [Algorithm Flags](https://github.com/aathish14/natsort-rs/blob/master/src/ns.rs): `src/ns.rs`

### Key Pipeline

- [Input Transform](https://github.com/aathish14/natsort-rs/blob/master/src/transform/input.rs): `src/transform/input.rs`
- [Component Transform](https://github.com/aathish14/natsort-rs/blob/master/src/transform/component.rs): `src/transform/component.rs`
- [Final Key Transform](https://github.com/aathish14/natsort-rs/blob/master/src/transform/final_transform.rs): `src/transform/final_transform.rs`
- [Parser Factories](https://github.com/aathish14/natsort-rs/blob/master/src/parser/mod.rs): `src/parser/mod.rs`

### Parsing Support

- [String Parser](https://github.com/aathish14/natsort-rs/blob/master/src/parser/string.rs): `src/parser/string.rs`
- [Number Parser](https://github.com/aathish14/natsort-rs/blob/master/src/parser/number.rs): `src/parser/number.rs`
- [Path Parser](https://github.com/aathish14/natsort-rs/blob/master/src/parser/path.rs): `src/parser/path.rs`
- [Bytes Parser](https://github.com/aathish14/natsort-rs/blob/master/src/parser/bytes.rs): `src/parser/bytes.rs`
- [Numeric Regex](https://github.com/aathish14/natsort-rs/blob/master/src/regex.rs): `src/regex.rs`
- [Number Compatibility](https://github.com/aathish14/natsort-rs/blob/master/src/compat/mod.rs): `src/compat/mod.rs`
- [Unicode Numerics](https://github.com/aathish14/natsort-rs/blob/master/src/unicode/numbers.rs): `src/unicode/numbers.rs`

### Locale Backends

- [Locale Provider](https://github.com/aathish14/natsort-rs/blob/master/src/locale/mod.rs): `src/locale/mod.rs`
- [Stdlib Locale](https://github.com/aathish14/natsort-rs/blob/master/src/locale/stdlib.rs): `src/locale/stdlib.rs`
- [ICU Locale](https://github.com/aathish14/natsort-rs/blob/master/src/locale/icu.rs): `src/locale/icu.rs`
- [Windows Locale](https://github.com/aathish14/natsort-rs/blob/master/src/locale/windows.rs): `src/locale/windows.rs`

### Other components

- **Library Caller**
- **Windows API**

## Connections

- Library Caller → Sort Helpers: sorts with
- Library Caller → Key Generation: generates keys
- Library Caller → Index Ordering: requests indices
- Library Caller → OS Sort API: requests OS sort
- Index Ordering → Key Generation: generates sort keys
- Key Generation → Parser Factories: configures parsers
- Parser Factories → String Parser: creates
- Parser Factories → Number Parser: creates
- Parser Factories → Path Parser: creates
- Parser Factories → Bytes Parser: creates
- Parser Factories → Numeric Regex: selects regex
- String Parser → Input Transform: transforms input
- String Parser → Component Transform: transforms components
- String Parser → Final Key Transform: assembles key
- Number Parser → Number Compatibility: parses numbers
- Number Compatibility → Unicode Numerics: checks numeric values
- Input Transform → Locale Provider: reads separators
- String Parser → Locale Provider: uses collation
- Locale Provider → Stdlib Locale: provides fallback
- Locale Provider → ICU Locale: optional backend
- Locale Provider → Windows Locale: optional backend
- OS Sort API → Windows API: uses platform sort
