# rodolfoviolac/blur-sensitive-data architecture

> Architecture diagram of the GitHub repository rodolfoviolac/blur-sensitive-data, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rodolfoviolac/blur-sensitive-data
- Repository: https://github.com/rodolfoviolac/blur-sensitive-data

## Overview

##### Main Components
- Client/API Layer – Although this is a library and not a full-stack application, the entry point is its API. The core class (named “Obfuscator”) is exposed (via index.js/ts) that developers instantiate and pass either object or string data.
- Object Obfuscation Module – This component handles the deep traversal of objects, keyword matching (based on default and additional sensitivity keys), circular dependency handling, and delegation to relevant utility functions.
- String Obfuscation Module – This component uses regular expression matching based on default patterns (e.g., credit card, CPF, etc.) and additional custom patterns to obfuscate sensitive information contained in text.
- Configurations/Typings – The “src/typings” directory includes enums and interface definitions that strongly type and define the behavior for both modules.
- Utility Functions – The “src/utils” directory contains helper modules (objectHandler, sensitiveFields, stringHandler, stringsPatterns) that perform the concrete data transformations.
- Testing & Examples – Though not part of the runtime architecture, the “test” directory ensures each module functions as expected and “examples” show how to integrate and use the library.

##### Depicting Relationships & Interactions
- From the “Obfuscator API”, branch out into two separate pathways:
- One pathway goes to the “Object Obfuscation Module” for object-based inputs.
- The other pathway routes to the “String Obfuscation Module” for string inputs.
- Both modules use common “Utility Functions” for handling tasks such as pattern matching or deep object traversal.
- Configurations (such as replacerText, additionalObjectKeys, etc.) and “Typings” feed into both modules to customize their behavior.
- Optionally, include a “Test Suite” alongside these modules to indicate testing/validation of each component and configuration.

##### Architectural Patterns & Design Principles
- Modularity: The design clearly separates concerns by having distinct modules for object and string processing.
- Configurability: The use of configuration objects and custom parameters (as seen in the README examples) allows flexible integration.
- Reusability: Utility functions and shared type definitions are reused across the string and object modules, promoting DRY (Don’t Repeat Yourself) principles.
- Extensibility: The design supports adding more sensitive patterns or keys (both in objects and strings) without major refactoring.

## Diagram (Mermaid)

```mermaid
flowchart TD
    ClientCode("Client Code"):::external
    ObfuscatorAPI("Obfuscator API"):::api
    ObjectModule("Object Obfuscation Module"):::module
    StringModule("String Obfuscation Module"):::module
    UtilityFuncs("Utility Functions"):::utility
    Configurations("Configurations & Typings"):::config
    TestingExamples("Test Suite & Examples"):::test

    ClientCode -->|"data_input"| ObfuscatorAPI
    ObfuscatorAPI -->|"object_input"| ObjectModule
    ObfuscatorAPI -->|"string_input"| StringModule
    ObjectModule -->|"uses_utility"| UtilityFuncs
    ObjectModule -->|"config_applied"| Configurations
    StringModule -->|"uses_utility"| UtilityFuncs
    StringModule -->|"config_applied"| Configurations
    ObfuscatorAPI -->|"verified_by"| TestingExamples

    click ObfuscatorAPI "https://github.com/rodolfoviolac/blur-sensitive-data/blob/main/src/index.js"
    click ObfuscatorAPI "https://github.com/rodolfoviolac/blur-sensitive-data/blob/main/src/index.ts"
    click ObjectModule "https://github.com/rodolfoviolac/blur-sensitive-data/blob/main/src/utils/objectHandler.ts"
    click ObjectModule "https://github.com/rodolfoviolac/blur-sensitive-data/blob/main/src/utils/sensitiveFields.ts"
    click StringModule "https://github.com/rodolfoviolac/blur-sensitive-data/blob/main/src/utils/stringHandler.ts"
    click StringModule "https://github.com/rodolfoviolac/blur-sensitive-data/blob/main/src/utils/stringsPatterns.ts"
    click Configurations "https://github.com/rodolfoviolac/blur-sensitive-data/tree/main/src/typings"
    click Configurations "https://github.com/rodolfoviolac/blur-sensitive-data/blob/main/src/typings/enums.ts"
    click Configurations "https://github.com/rodolfoviolac/blur-sensitive-data/blob/main/src/typings/interfaces.ts"
    click UtilityFuncs "https://github.com/rodolfoviolac/blur-sensitive-data/tree/main/src/utils"
    click TestingExamples "https://github.com/rodolfoviolac/blur-sensitive-data/tree/main/test"
    click TestingExamples "https://github.com/rodolfoviolac/blur-sensitive-data/tree/main/examples"

    classDef external fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef api fill:#a2d2ff,stroke:#333,stroke-width:2px;
    classDef module fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef utility fill:#ffeeba,stroke:#333,stroke-width:2px;
    classDef config fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef test fill:#f8d7da,stroke:#333,stroke-width:2px;
```
