# leapbeyond/scrubadub architecture

> Architecture diagram of the GitHub repository leapbeyond/scrubadub, 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/leapbeyond/scrubadub
- Repository: https://github.com/leapbeyond/scrubadub

## Overview

scrubadub is a Python library for detecting and redacting personally identifiable information in free text. A caller supplies text to the public API or a Scrubber; the Scrubber selects detectors, represents matches as Filth, and applies configurable post-processors to produce cleaned text or expose detected matches. The README also documents localization, custom detectors and processors, and optional name/address detector integrations. Source excerpts establish the main entry points and component roles; some internal Scrubber dispatch details and optional integrations are documented or indexed but not fully sampled.

Main entry points: [`scrubadub/scrubbers.py`](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/scrubbers.py) (Scrubber), [`scrubadub/filth/base.py`](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/filth/base.py) (Filth Model), [`scrubadub/detectors/catalogue.py`](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/detectors/catalogue.py) (Detector Catalogue), [`scrubadub/detectors`](https://github.com/leapbeyond/scrubadub/tree/master/scrubadub/detectors) (PII Detectors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_public["Scrub API<br/>[__init__.py]"]
  node_scrubber["Scrubber<br/>[scrubbers.py]"]
  node_clean_text["Cleaned Text"]
  node_matches["Detected Matches"]
end

subgraph group_detection["Detection"]
  node_detector_catalogue["Detector Catalogue<br/>[catalogue.py]"]
  node_detector_base["Detector Base<br/>[base.py]"]
  node_pii_detectors["PII Detectors"]
  node_tagged_detection["Tagged &amp; Supplied<br/>[tagged.py]"]
  node_text_blob["TextBlob Names<br/>[text_blob.py]"]
  node_optional_detectors["Optional Detectors"]
end

subgraph group_domain["PII Representation"]
  node_filth_model["Filth Model<br/>[base.py]"]
  node_filth_types["PII Types"]
end

subgraph group_processing["Redaction"]
  node_processor_catalogue["Processor Catalogue<br/>[catalogue.py]"]
  node_processor_base["Processor Base<br/>[base.py]"]
  node_filth_replacer["Filth Replacer<br/>[filth_replacer.py]"]
  node_other_processors["Other Processors"]
end

node_caller(("Library Caller"))

node_caller -->|"calls"| node_public
node_public -->|"creates and delegates"| node_scrubber
node_scrubber -->|"resolves detectors"| node_detector_catalogue
node_scrubber -->|"runs detection"| node_pii_detectors
node_scrubber -->|"resolves processors"| node_processor_catalogue
node_scrubber -->|"applies processors"| node_other_processors
node_detector_catalogue -->|"registers"| node_pii_detectors
node_pii_detectors -->|"extends"| node_detector_base
node_tagged_detection -->|"creates matches"| node_filth_model
node_tagged_detection -->|"registers"| node_detector_catalogue
node_text_blob -->|"registers"| node_detector_catalogue
node_detector_base -->|"creates match objects"| node_filth_model
node_filth_model -->|"provides shared model"| node_filth_types
node_processor_catalogue -->|"registers"| node_other_processors
node_filth_replacer -->|"extends"| node_processor_base
node_filth_replacer -->|"sets replacement"| node_filth_model
node_scrubber -->|"collects matches"| node_filth_model
node_scrubber -->|"returns cleaned text"| node_clean_text
node_scrubber -->|"returns matches"| node_matches
node_optional_detectors -.->|"extends detection"| node_pii_detectors

click node_public "https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/__init__.py"
click node_scrubber "https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/scrubbers.py"
click node_detector_catalogue "https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/detectors/catalogue.py"
click node_detector_base "https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/detectors/base.py"
click node_pii_detectors "https://github.com/leapbeyond/scrubadub/tree/master/scrubadub/detectors"
click node_tagged_detection "https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/detectors/tagged.py"
click node_text_blob "https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/detectors/text_blob.py"
click node_filth_model "https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/filth/base.py"
click node_filth_types "https://github.com/leapbeyond/scrubadub/tree/master/scrubadub/filth"
click node_processor_catalogue "https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/post_processors/catalogue.py"
click node_processor_base "https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/post_processors/base.py"
click node_filth_replacer "https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/post_processors/filth_replacer.py"
click node_other_processors "https://github.com/leapbeyond/scrubadub/tree/master/scrubadub/post_processors"

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_public,node_scrubber,node_clean_text,node_matches toneBlue
class node_detector_catalogue,node_detector_base,node_pii_detectors,node_tagged_detection,node_text_blob,node_optional_detectors toneAmber
class node_filth_model,node_filth_types toneMint
class node_processor_catalogue,node_processor_base,node_filth_replacer,node_other_processors toneRose
class node_caller toneIndigo
```

## Components

### Public API

- [Scrub API](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/__init__.py): `scrubadub/__init__.py`
- [Scrubber](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/scrubbers.py): `scrubadub/scrubbers.py`
- **Cleaned Text**
- **Detected Matches**

### Detection

- [Detector Catalogue](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/detectors/catalogue.py): `scrubadub/detectors/catalogue.py`
- [Detector Base](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/detectors/base.py): `scrubadub/detectors/base.py`
- [PII Detectors](https://github.com/leapbeyond/scrubadub/tree/master/scrubadub/detectors): `scrubadub/detectors`
- [Tagged & Supplied](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/detectors/tagged.py): `scrubadub/detectors/tagged.py`
- [TextBlob Names](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/detectors/text_blob.py): `scrubadub/detectors/text_blob.py`
- **Optional Detectors**

### PII Representation

- [Filth Model](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/filth/base.py): `scrubadub/filth/base.py`
- [PII Types](https://github.com/leapbeyond/scrubadub/tree/master/scrubadub/filth): `scrubadub/filth`

### Redaction

- [Processor Catalogue](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/post_processors/catalogue.py): `scrubadub/post_processors/catalogue.py`
- [Processor Base](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/post_processors/base.py): `scrubadub/post_processors/base.py`
- [Filth Replacer](https://github.com/leapbeyond/scrubadub/blob/master/scrubadub/post_processors/filth_replacer.py): `scrubadub/post_processors/filth_replacer.py`
- [Other Processors](https://github.com/leapbeyond/scrubadub/tree/master/scrubadub/post_processors): `scrubadub/post_processors`

### Other components

- **Library Caller**

## Connections

- Library Caller → Scrub API: calls
- Scrub API → Scrubber: creates and delegates (evidence: `scrubadub/__init__.py`)
- Scrubber → Detector Catalogue: resolves detectors (evidence: `scrubadub/scrubbers.py`)
- Scrubber → PII Detectors: runs detection (evidence: `scrubadub/scrubbers.py`)
- Scrubber → Processor Catalogue: resolves processors (evidence: `scrubadub/scrubbers.py`)
- Scrubber → Other Processors: applies processors (evidence: `scrubadub/scrubbers.py`)
- Detector Catalogue → PII Detectors: registers (evidence: `scrubadub/detectors/catalogue.py`)
- PII Detectors → Detector Base: extends (evidence: `scrubadub/detectors/__init__.py`)
- Tagged & Supplied → Filth Model: creates matches (evidence: `scrubadub/detectors/tagged.py`)
- Tagged & Supplied → Detector Catalogue: registers (evidence: `scrubadub/detectors/tagged.py`)
- TextBlob Names → Detector Catalogue: registers (evidence: `scrubadub/detectors/text_blob.py`)
- Detector Base → Filth Model: creates match objects (evidence: `scrubadub/detectors/base.py`)
- Filth Model → PII Types: provides shared model (evidence: `scrubadub/filth/__init__.py`)
- Processor Catalogue → Other Processors: registers (evidence: `scrubadub/post_processors/catalogue.py`)
- Filth Replacer → Processor Base: extends (evidence: `scrubadub/post_processors/filth_replacer.py`)
- Filth Replacer → Filth Model: sets replacement (evidence: `scrubadub/post_processors/filth_replacer.py`)
- Scrubber → Filth Model: collects matches (evidence: `scrubadub/scrubbers.py`)
- Scrubber → Cleaned Text: returns cleaned text
- Scrubber → Detected Matches: returns matches
- Optional Detectors → PII Detectors: extends detection
