# ibpme/fuzzy-df architecture

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

- Interactive diagram: https://gitdiagram.com/ibpme/fuzzy-df
- Repository: https://github.com/ibpme/fuzzy-df

## Overview

##### Project Type & Purpose
- fuzzy-df is a Python package designed to offer utilities for fuzzy matching and merging operations on pandas DataFrames and Series. It leverages the rapidfuzz library for similarity scoring and integrates into pandas workflows.

##### File Structure
- The top-level directories provide important context:
- The “src” directory contains the package code. Within it, the fuzzy_df directory holds the primary modules: match.py and merge.py.
- The “tests” directory includes our test cases for these modules.
- The “.github/workflows” directory shows that CI/CD workflows are configured (ci.yml, release.yml, staging.yaml), which means automated tests, builds, and deployments are part of the design.
- Files like pyproject.toml, uv.lock, LICENSE, and .python-version indicate a managed build/dependency system and standard packaging practices.

##### Components
a. Core Library:
- Fuzzy Matching Component (from src/fuzzy_df/match.py): Represents the fuzzy matching functions that compare pandas Series with a score computed via rapidfuzz.
- Fuzzy Merging Component (from src/fuzzy_df/merge.py): Represents logic to merge two pandas DataFrames or Series using fuzzy matching.
b. Dependencies:
- pandas: Essential for handling DataFrame/Series operations.
- rapidfuzz: Used for similarity computations.
- uv: The build tool showcased in the README which is used for packaging and testing.
c. Testing & CI/CD Pipeline:
- Unit Testing (tests directory): Demonstrates that the fuzzy matching and merging functionalities are verified via pytest.
- CI/CD Workflows: The .github/workflows configuration files (ci.yml, release.yml, staging.yaml) indicate automation for continuous integration, building, and release management.
d. Build & Distribution:
- Build Process: Illustrate the use of uv build command that compiles and packages the project along with the creation of distribution artifacts under the dist/ directory.
- Local install and testing commands, such as uv pip install -e ., should be noted.

##### Relationships and Interactions
- The building and testing pipelines should be connected, showcasing that after code is modified in the src directory, tests (in tests/) are executed automatically via the CI workflows.

##### Architectural Patterns & Design Principles
- Modular Design: The clear separation of matching vs. merging code ensures maintainability.
- Pipeline Integration: The integration of CI/CD (via GitHub workflows) with build/test automation emphasizes a continuous delivery model.
- Extensibility: The code supports configuration (score_cutoff, custom column names), meaning the design is flexible and can be extended.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["User Input (pandas DataFrame/Series)"]:::input

    subgraph "Core Library"
        B["Fuzzy Matching Module"]:::module
        C["Fuzzy Merging Module"]:::module
    end

    I["Processed Output (Results with Scores)"]:::output

    D["pandas Integration"]:::dependency
    E["rapidfuzz Dependency"]:::dependency

    G["Unit Testing (pytest)"]:::test
    H["CI/CD Pipelines"]:::cicd
    F["Build & Packaging (uv)"]:::build

    %% Data flow from user input to core processing modules
    A -->|"provides"| B
    A -->|"provides"| C

    %% Core processing produces output
    B -->|"processes"| I
    C -->|"processes"| I

    %% Core modules use external dependencies
    B -->|"uses"| D
    C -->|"uses"| D
    B -->|"calls"| E
    C -->|"calls"| E

    %% Code commits from core modules trigger CI/CD
    B -->|"commit"| H
    C -->|"commit"| H

    %% CI/CD pipelines execute unit testing and build/packaging
    H -->|"runs"| G
    H -->|"runs"| F

    %% Build & Packaging prepares the library for installation
    F -->|"install"| A

    classDef input fill:#fce94f,stroke:#eab700,stroke-width:2px;
    classDef module fill:#8ae234,stroke:#4e9a06,stroke-width:2px;
    classDef dependency fill:#729fcf,stroke:#204a87,stroke-width:2px;
    classDef build fill:#fcaf3e,stroke:#e95420,stroke-width:2px;
    classDef test fill:#e9b96e,stroke:#c17d11,stroke-width:2px;
    classDef cicd fill:#ef2929,stroke:#cc0000,stroke-width:2px;
    classDef output fill:#8cc4ff,stroke:#2a65a0,stroke-width:2px;

    click B "https://github.com/ibpme/fuzzy-df/blob/main/src/fuzzy_df/match.py"
    click C "https://github.com/ibpme/fuzzy-df/blob/main/src/fuzzy_df/merge.py"
    click D "https://github.com/ibpme/fuzzy-df/tree/main/src/fuzzy_df"
    click G "https://github.com/ibpme/fuzzy-df/tree/main/tests"
    click H "https://github.com/ibpme/fuzzy-df/tree/main/.github/workflows"
    click F "https://github.com/ibpme/fuzzy-df/blob/main/pyproject.toml"
```
