# ohadmata/shmessy architecture

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

- Interactive diagram: https://gitdiagram.com/ohadmata/shmessy
- Repository: https://github.com/ohadmata/shmessy

## Overview

##### Main Components

a) Core Components:
- Schema Inference Engine
- Type Validation System
- DataFrame Transformer
- File Readers (CSV/Excel)

b) Type System:
- Base Type Handler
- Specialized Type Validators (Boolean, Date, DateTime, Email, Float, Integer, IPv4, String, UnixTimestamp)

**┌─────────────────────────────────────────────────────────┐**
- Client Interface                       │
- (read_csv, infer_schema, fix_schema, get_inferred_schema) │
- ┤
- Core Processing                        │
- ┌─────────────┐    ┌──────────────┐   ┌─────────┐   │
- Schema    │    │    Type      │   │DataFrame │   │
- Inference  │◄──►│  Validation  │◄─►│Transform │   │
- Engine    │    │    System    │   │ Engine   │   │
- ┘    └──────────────┘   └─────────┘   │
- ┤
- Type System                         │
- ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────┐  │
- Boolean │ │  Date   │ │ Email   │ │    IPv4     │  │
- ┘ └─────────┘ └─────────┘ └─────────────┘  │
- ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────┐  │
- Integer │ │  Float  │ │ String  │ │UnixTimestamp│  │
- ┘ └─────────┘ └─────────┘ └─────────────┘  │
- ┘

##### Important Elements to Highlight

a) Data Flow:
- Input: Raw DataFrame/CSV/Excel files
- Processing: Type inference and validation
- Output: Cleaned DataFrame with correct types

b) Key Processes:
- Schema inference
- Type validation
- DataFrame transformation
- File reading and parsing

##### Implementation Details

How the components interact:
- Schema Inference Engine samples data and coordinates with Type Validation System
- Type System provides specialized validators for each data type
- DataFrame Transformer applies the inferred schema to clean the data

##### Configuration Elements

Configuration parameters:
- Sample size
- Encoding options
- Locale settings
- Type inference settings

This design reflects the project's focus on data type inference and transformation, with a clear separation between the type system, core processing, and client interface layers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef interface fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef type fill:#e67e22,stroke:#d35400,color:white
    classDef file fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef utils fill:#9b59b6,stroke:#8e44ad,color:white

    %% Client Interface Layer
    subgraph Interface
        CI[Client Interface]
        FR[File Readers]
    end

    %% Core Processing Layer
    subgraph Core
        SIE[Schema Inference Engine]
        TVS[Type Validation System]
        DTE[DataFrame Transformer]
    end

    %% Type System Layer
    subgraph TypeSystem
        BTH[Base Type Handler]
        subgraph Validators
            BV[Boolean Validator]
            DV[Date Validator]
            DTV[DateTime Validator]
            EV[Email Validator]
            FV[Float Validator]
            IV[Integer Validator]
            IPV[IPv4 Validator]
            SV[String Validator]
            UTV[UnixTimestamp Validator]
        end
    end

    %% Utilities Layer
    subgraph Utils
        DU[Date Utils]
        GU[General Utils]
        EH[Exception Handler]
    end

    %% Relationships
    CI --> FR
    CI --> SIE
    FR --> SIE
    SIE <--> TVS
    TVS <--> DTE
    TVS --> BTH
    BTH --> Validators
    DTE --> CI
    TVS --> Utils

    %% Click Events
    click SIE "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/schema.py"
    click TVS "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types_handler.py"
    click BTH "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types/base.py"
    click BV "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types/boolean.py"
    click DV "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types/date.py"
    click DTV "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types/datetime_.py"
    click EV "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types/email.py"
    click FV "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types/float.py"
    click IV "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types/integer.py"
    click IPV "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types/ipv4_address.py"
    click SV "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types/string.py"
    click UTV "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/types/unix_timestamp.py"
    click DU "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/date_utils.py"
    click GU "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/utils.py"
    click EH "https://github.com/ohadmata/shmessy/blob/main/src/shmessy/exceptions.py"

    %% Style Applications
    class CI,FR interface
    class SIE,TVS,DTE core
    class BTH,BV,DV,DTV,EV,FV,IV,IPV,SV,UTV type
    class DU,GU,EH utils
```
