# toreau/url-normalize architecture

> Architecture diagram of the GitHub repository toreau/url-normalize, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/toreau/url-normalize
- Repository: https://github.com/toreau/url-normalize

## Overview

##### Main Components Structure
- Input/output interfaces for URL handling
- Different normalization processors as sub-components

##### Component Organization

a) Input Layer:
- URL Input Handler (accepts raw URLs)
- URI Parser (using URI module integration)

b) Core Processing Layer (URL::Normalize):
- Canonical Processor
- Directory Index Handler
- Query Parameter Processor
- Path Segment Handler
- Fragment Handler
- Slash Handler

c) Output Layer:
- Normalized URL Generator
- URI Object Provider

##### Flow Representation

- Input URL → URI Parser → Core Processing
- Processor → Output Layer

##### Detailed Component Breakdown

Query Parameter Processor should show sub-components:
- Sorter
- Duplicate Remover
- Empty Parameter Handler

Path Processing should include:
- Dot Segment Resolver
- Directory Index Resolver
- Slash Normalizer

##### Integration Points

External dependencies:
- URI module integration
- URI::URL module connection
- URI::QueryParam module interface

##### The error handling pathways

- Processing direction
- Optional vs. required steps
- Configuration points
- External dependencies

Remember to include notes about:
- The order of operations
- Optional processing paths
- Configuration injection points
- Error handling flows

This will create a comprehensive yet clear representation of the URL::Normalize module's architecture that accurately reflects its purpose as a URL normalization tool.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        URL[URL Input Handler]:::input
        URI[URI Parser]:::input
    end

    subgraph Core
        MAIN["URL::Normalize Core"]:::core
        click MAIN "https://github.com/toreau/URL-Normalize/blob/master/lib/URL/Normalize.pm"
    end

    subgraph Processors
        CAN[Canonical Processor]:::processor
        click CAN "https://github.com/toreau/URL-Normalize/blob/master/t/10-canonical.t"
        
        PSH[Path Segment Handler]:::processor
        click PSH "https://github.com/toreau/URL-Normalize/blob/master/t/15-remove-dot-segments.t"
        
        DIH[Directory Index Handler]:::processor
        click DIH "https://github.com/toreau/URL-Normalize/blob/master/t/20-remove-directory-index.t"
        
        FH[Fragment Handler]:::processor
        click FH "https://github.com/toreau/URL-Normalize/blob/master/t/35-remove-fragment.t"
        
        SH[Slash Handler]:::processor
        click SH "https://github.com/toreau/URL-Normalize/blob/master/t/40-remove-duplicate-slashes.t"

        subgraph "Query Parameter Processor"
            QPSort[Parameter Sorter]:::qp
            click QPSort "https://github.com/toreau/URL-Normalize/blob/master/t/25-sort-query-parameters.t"
            
            QPEmpty[Empty Parameter Handler]:::qp
            click QPEmpty "https://github.com/toreau/URL-Normalize/blob/master/t/30-remove-empty-query.t"
            
            QPDup[Duplicate Remover]:::qp
            click QPDup "https://github.com/toreau/URL-Normalize/blob/master/t/45-remove-duplicate-query-parameters.t"
        end
    end

    subgraph Configuration
        Config[Configuration Settings]:::config
        DIP[Directory Index Patterns]:::config
        REG[Custom RegEx Patterns]:::config
        FLAGS[Processing Flags]:::config
    end

    subgraph Output
        NormURL[Normalized URL Generator]:::output
        URIObj[URI Object Provider]:::output
    end

    subgraph "External Dependencies"
        URIMod[URI Module]:::external
        URIURLMod[URI::URL Module]:::external
        URIQueryMod[URI::QueryParam Module]:::external
    end

    URL --> URI
    URI --> MAIN
    MAIN --> CAN
    MAIN --> PSH
    MAIN --> DIH
    MAIN --> FH
    MAIN --> SH
    MAIN --> QPSort
    MAIN --> QPEmpty
    MAIN --> QPDup
    
    CAN --> NormURL
    PSH --> NormURL
    DIH --> NormURL
    FH --> NormURL
    SH --> NormURL
    QPSort --> NormURL
    QPEmpty --> NormURL
    QPDup --> NormURL
    
    Config --> MAIN
    DIP --> DIH
    REG --> MAIN
    FLAGS --> MAIN
    
    MAIN --- URIMod
    MAIN --- URIURLMod
    MAIN --- URIQueryMod
    
    NormURL --> URIObj

    classDef input fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#4169E1,stroke:#333,stroke-width:2px,color:white
    classDef processor fill:#FFD700,stroke:#333,stroke-width:2px
    classDef qp fill:#FFA500,stroke:#333,stroke-width:2px
    classDef config fill:#A9A9A9,stroke:#333,stroke-width:2px
    classDef output fill:#98FB98,stroke:#333,stroke-width:2px
    classDef external fill:#DEB887,stroke:#333,stroke-width:2px
```
