# glincker/glin-profanity architecture

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

- Interactive diagram: https://gitdiagram.com/glincker/glin-profanity
- Repository: https://github.com/glincker/glin-profanity

## Overview

Glin Profanity is an offline-capable content-safety library offered in JavaScript/TypeScript and Python, with MCP and OpenClaw integrations. The main workflow accepts text, normalizes and matches it against multilingual profanity dictionaries, then returns a decision and can redact matches; optional ML, contextual analysis, and specialized scanners broaden coverage to toxicity, PII, secrets, and prompt injection. The graph combines sampled imports and calls with README-documented capabilities; unsampled integration internals are shown only where documented.

Main entry points: [`packages/js/src/filters/Filter.ts`](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/filters/Filter.ts) (Profanity Filter), [`packages/js/src/scanners/pii.ts`](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/pii.ts) (PII Scanner), [`packages/py/glin_profanity/filters/filter.py`](https://github.com/glincker/glin-profanity/blob/release/packages/py/glin_profanity/filters/filter.py) (Python Filter), [`packages/mcp/src/server.ts`](https://github.com/glincker/glin-profanity/blob/release/packages/mcp/src/server.ts) (MCP Tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_js["JavaScript Core"]
  node_jsapi["Public API<br/>[index.ts]"]
  node_jscore["Check API"]
  node_jsfilter["Profanity Filter<br/>[Filter.ts]"]
  node_jsnormalize["Text Normalization<br/>[normalizeText.ts]"]
  node_jsunicode["Unicode Folding<br/>[unicode.ts]"]
  node_jsmatcher["Word Matcher<br/>[wordMatcher.ts]"]
  node_jsdict[("Language Dictionary<br/>[dictionary.ts]")]
  node_context["Context Analysis<br/>[contextAnalyzer.ts]"]
end

subgraph group_py["Python Core"]
  node_pyapi["Python API<br/>[__init__.py]"]
  node_pyfilter["Python Filter<br/>[filter.py]"]
  node_pydict[("Language Dictionary<br/>[dictionary.py]")]
  node_hybrid["Hybrid ML Filter<br/>[hybrid.py]"]
end

subgraph group_guard["Safety Scanners"]
  node_scanners["Scanner Framework<br/>[base.ts]"]
  node_pii["PII Scanner<br/>[pii.ts]"]
  node_piipatterns["PII Patterns<br/>[pii-patterns.ts]"]
  node_vault[("Redaction Vault<br/>[vault.ts]")]
  node_injection["Injection Scanner"]
end

subgraph group_integrations["App Integrations"]
  node_mcp["MCP Tools<br/>[server.ts]"]
  node_mcphttp["MCP HTTP<br/>[http.ts]"]
  node_openclaw["OpenClaw Plugin<br/>[index.ts]"]
  node_vscode["VS Code Extension<br/>[extension.ts]"]
end

node_consumer(("Application"))

node_consumer -->|"uses API"| node_jsapi
node_consumer -->|"uses API"| node_pyapi
node_jsapi -->|"exports"| node_jscore
node_jscore -->|"pools filter"| node_jsfilter
node_jsfilter -->|"normalizes text"| node_jsnormalize
node_jsfilter -->|"folds Unicode"| node_jsunicode
node_jsfilter -->|"matches words"| node_jsmatcher
node_jsfilter -->|"loads words"| node_jsdict
node_jsfilter -->|"checks context"| node_context
node_pyapi -->|"exports filter"| node_pyfilter
node_pyfilter -->|"loads words"| node_pydict
node_hybrid -->|"combines rules"| node_pyfilter
node_pii -->|"implements scanner"| node_scanners
node_pii -->|"uses patterns"| node_piipatterns
node_pii -->|"redacts via"| node_vault
node_injection -.->|"implements scanner"| node_scanners
node_mcp -->|"checks text"| node_jsfilter
node_mcphttp -->|"serves transport"| node_mcp
node_consumer -->|"uses tools"| node_mcp
node_consumer -->|"installs plugin"| node_openclaw
node_consumer -.->|"uses extension"| node_vscode

click node_jsapi "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/index.ts"
click node_jscore "https://github.com/glincker/glin-profanity/tree/release/packages/js/src/core"
click node_jsfilter "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/filters/Filter.ts"
click node_jsnormalize "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/filters/normalizeText.ts"
click node_jsunicode "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/utils/unicode.ts"
click node_jsmatcher "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/filters/wordMatcher.ts"
click node_jsdict "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/data/dictionary.ts"
click node_context "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/nlp/contextAnalyzer.ts"
click node_pyapi "https://github.com/glincker/glin-profanity/blob/release/packages/py/glin_profanity/__init__.py"
click node_pyfilter "https://github.com/glincker/glin-profanity/blob/release/packages/py/glin_profanity/filters/filter.py"
click node_pydict "https://github.com/glincker/glin-profanity/blob/release/packages/py/glin_profanity/data/dictionary.py"
click node_hybrid "https://github.com/glincker/glin-profanity/blob/release/packages/py/glin_profanity/ml/hybrid.py"
click node_scanners "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/base.ts"
click node_pii "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/pii.ts"
click node_piipatterns "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/patterns/pii-patterns.ts"
click node_vault "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/vault.ts"
click node_injection "https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/prompt-injection.ts"
click node_mcp "https://github.com/glincker/glin-profanity/blob/release/packages/mcp/src/server.ts"
click node_mcphttp "https://github.com/glincker/glin-profanity/blob/release/packages/mcp/src/http.ts"
click node_openclaw "https://github.com/glincker/glin-profanity/blob/release/packages/openclaw/src/index.ts"
click node_vscode "https://github.com/glincker/glin-profanity/blob/release/packages/vscode-extension/src/extension.ts"

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_jsapi,node_jscore,node_jsfilter,node_jsnormalize,node_jsunicode,node_jsmatcher,node_jsdict,node_context toneBlue
class node_pyapi,node_pyfilter,node_pydict,node_hybrid toneAmber
class node_scanners,node_pii,node_piipatterns,node_vault,node_injection toneMint
class node_mcp,node_mcphttp,node_openclaw,node_vscode toneRose
class node_consumer toneIndigo
```

## Components

### JavaScript Core

- [Public API](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/index.ts): `packages/js/src/index.ts`
- [Check API](https://github.com/glincker/glin-profanity/tree/release/packages/js/src/core): `packages/js/src/core`
- [Profanity Filter](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/filters/Filter.ts): `packages/js/src/filters/Filter.ts`
- [Text Normalization](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/filters/normalizeText.ts): `packages/js/src/filters/normalizeText.ts`
- [Unicode Folding](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/utils/unicode.ts): `packages/js/src/utils/unicode.ts`
- [Word Matcher](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/filters/wordMatcher.ts): `packages/js/src/filters/wordMatcher.ts`
- [Language Dictionary](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/data/dictionary.ts): `packages/js/src/data/dictionary.ts`
- [Context Analysis](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/nlp/contextAnalyzer.ts): `packages/js/src/nlp/contextAnalyzer.ts`

### Python Core

- [Python API](https://github.com/glincker/glin-profanity/blob/release/packages/py/glin_profanity/__init__.py): `packages/py/glin_profanity/__init__.py`
- [Python Filter](https://github.com/glincker/glin-profanity/blob/release/packages/py/glin_profanity/filters/filter.py): `packages/py/glin_profanity/filters/filter.py`
- [Language Dictionary](https://github.com/glincker/glin-profanity/blob/release/packages/py/glin_profanity/data/dictionary.py): `packages/py/glin_profanity/data/dictionary.py`
- [Hybrid ML Filter](https://github.com/glincker/glin-profanity/blob/release/packages/py/glin_profanity/ml/hybrid.py): `packages/py/glin_profanity/ml/hybrid.py`

### Safety Scanners

- [Scanner Framework](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/base.ts): `packages/js/src/scanners/base.ts`
- [PII Scanner](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/pii.ts): `packages/js/src/scanners/pii.ts`
- [PII Patterns](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/patterns/pii-patterns.ts): `packages/js/src/scanners/patterns/pii-patterns.ts`
- [Redaction Vault](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/vault.ts): `packages/js/src/scanners/vault.ts`
- [Injection Scanner](https://github.com/glincker/glin-profanity/blob/release/packages/js/src/scanners/prompt-injection.ts): `packages/js/src/scanners/prompt-injection.ts`

### App Integrations

- [MCP Tools](https://github.com/glincker/glin-profanity/blob/release/packages/mcp/src/server.ts): `packages/mcp/src/server.ts`
- [MCP HTTP](https://github.com/glincker/glin-profanity/blob/release/packages/mcp/src/http.ts): `packages/mcp/src/http.ts`
- [OpenClaw Plugin](https://github.com/glincker/glin-profanity/blob/release/packages/openclaw/src/index.ts): `packages/openclaw/src/index.ts`
- [VS Code Extension](https://github.com/glincker/glin-profanity/blob/release/packages/vscode-extension/src/extension.ts): `packages/vscode-extension/src/extension.ts`

### Other components

- **Application**

## Connections

- Application → Public API: uses API (evidence: `packages/js/src/index.ts`)
- Application → Python API: uses API (evidence: `packages/py/glin_profanity/__init__.py`)
- Public API → Check API: exports (evidence: `packages/js/src/index.ts`)
- Check API → Profanity Filter: pools filter (evidence: `packages/js/src/core/filterPool.ts`)
- Profanity Filter → Text Normalization: normalizes text (evidence: `packages/js/src/filters/Filter.ts`)
- Profanity Filter → Unicode Folding: folds Unicode (evidence: `packages/js/src/filters/Filter.ts`)
- Profanity Filter → Word Matcher: matches words (evidence: `packages/js/src/filters/Filter.ts`)
- Profanity Filter → Language Dictionary: loads words (evidence: `packages/js/src/filters/Filter.ts`)
- Profanity Filter → Context Analysis: checks context (evidence: `packages/js/src/filters/Filter.ts`)
- Python API → Python Filter: exports filter (evidence: `packages/py/glin_profanity/__init__.py`)
- Python Filter → Language Dictionary: loads words (evidence: `packages/py/glin_profanity/filters/filter.py`)
- Hybrid ML Filter → Python Filter: combines rules (evidence: `packages/py/glin_profanity/ml/hybrid.py`)
- PII Scanner → Scanner Framework: implements scanner (evidence: `packages/js/src/scanners/pii.ts`)
- PII Scanner → PII Patterns: uses patterns (evidence: `packages/js/src/scanners/pii.ts`)
- PII Scanner → Redaction Vault: redacts via (evidence: `packages/js/src/scanners/pii.ts`)
- Injection Scanner → Scanner Framework: implements scanner
- MCP Tools → Profanity Filter: checks text (evidence: `packages/mcp/src/server.ts`)
- MCP HTTP → MCP Tools: serves transport (evidence: `packages/mcp/src/http.ts`)
- Application → MCP Tools: uses tools (evidence: `README.md`)
- Application → OpenClaw Plugin: installs plugin (evidence: `README.md`)
- Application → VS Code Extension: uses extension
