# allangalli/hotswappii architecture

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

- Interactive diagram: https://gitdiagram.com/allangalli/hotswappii
- Repository: https://github.com/allangalli/hotswappii

## Overview

##### Main Components
- Entry Point & UI: app.py and the ui/ directory contain the Streamlit interface panels (input, evaluation, benchmarks, etc.). They handle user interactions and display results.
- Core Logic: The core/ directory holds the detection, anonymization, and evaluation logic.
- Models: The models/ directory implements different NER engines and a model factory to switch between them.
- Configuration: The config/ directory contains configuration settings used across the application.
- Utilities: The utils/ directory provides supporting functions such as data processing, metrics calculations, and visualization.
- Data Storage: The data/ directory stores both sample text data and benchmark datasets/results.

##### Relationships & Data Flow
- The UI component (ui/) receives user input and settings, then passes them to the core detection logic (core/).
- The core module routes the input to the appropriate model (from models/) based on the configuration (config/).
- Results (detection and anonymization outcomes) are processed further for evaluation using utilities (utils/) and results stored in the data/ folder.
- Additional modules like synthetic data generation and evaluation functions integrate with external services (e.g., OpenAI, Microsoft Presidio).

##### Design Patterns & Technologies
- MVC/MVVM-like separation: The UI (view) is clearly separated from business logic (core) and data handling (models, utils).
- Modular design: Components are split into clear directories for configuration, processing, and presentation.
- Technologies: Streamlit drives the UI; SpaCy, transformers, and custom recognizers implement NER; and Python utilities manage data and metrics.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        A["Entry Point (app.py)"]:::ui
        B["UI Components (ui/)"]:::ui
    end

    subgraph "Business Logic"
        C["Core Logic (core/)"]:::core
    end

    subgraph "Models & Config"
        D["NER Models (models/)"]:::models
        E["Configuration (config/)"]:::config
    end

    subgraph "Supporting Modules"
        F["Utilities (utils/)"]:::utils
        G["Data Storage (data/)"]:::data
        H["External Services (OpenAI,Presidio)"]:::external
    end

    %% Data flow
    A -->|"provides_input"| C
    B -->|"provides_input"| C
    C -->|"selects_NER"| D
    C -->|"reads_config"| E
    C -->|"processes_data"| F
    F -->|"stores_accesses"| G
    F -->|"calls_API"| H
    C -->|"returns_results"| B
    C -->|"returns_results"| A

    %% Click Events
    click A "https://github.com/allangalli/hotswappii/blob/main/app.py"
    click B "https://github.com/allangalli/hotswappii/tree/main/ui/"
    click C "https://github.com/allangalli/hotswappii/tree/main/core/"
    click D "https://github.com/allangalli/hotswappii/tree/main/models/"
    click E "https://github.com/allangalli/hotswappii/tree/main/config/"
    click F "https://github.com/allangalli/hotswappii/tree/main/utils/"
    click G "https://github.com/allangalli/hotswappii/tree/main/data/"

    %% Styles
    classDef ui fill:#f9d5a7,stroke:#333,stroke-width:2px;
    classDef core fill:#a4c2f4,stroke:#333,stroke-width:2px;
    classDef models fill:#b6d7a8,stroke:#333,stroke-width:2px;
    classDef config fill:#c9daf8,stroke:#333,stroke-width:2px;
    classDef utils fill:#ead1dc,stroke:#333,stroke-width:2px;
    classDef data fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef external fill:#d9ead3,stroke:#333,stroke-width:2px;
```
