# shelepuginivan/color architecture

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

- Interactive diagram: https://gitdiagram.com/shelepuginivan/color
- Repository: https://github.com/shelepuginivan/color

## Overview

##### Core Components Organization

a. Public API Layer (Top)
- Entry points: parse.go, must.go
- Utility functions: wheel.go, mix.go, shades.go, luminance.go

b. Internal Layer (Middle)
- Internal package components:
- degrees package for angle calculations
- percents package for percentage handling

- util.go for shared utilities

##### Component Relationships
- Dependencies on internal packages

- Rectangle: Public API components
- Circle: Internal utilities

##### Key Aspects to Highlight

- Conversion paths between spaces

b. Core Operations:
- Parse function entry point
- Shade/tone generation

c. Internal Utilities:

##### Implementation Details
- Green: Utility functions
- Orange: Core types
- Gray: Internal packages

##### Important Architectural Notes
- Chainable API design
- Validation and error handling flow through Must functions
- Test coverage relationship (each component has a corresponding _test.go file)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef core fill:#ff9933,stroke:#333,stroke-width:2px
    classDef api fill:#3498db,stroke:#333,stroke-width:2px
    classDef colorspace fill:#9b59b6,stroke:#333,stroke-width:2px
    classDef utility fill:#2ecc71,stroke:#333,stroke-width:2px
    classDef internal fill:#95a5a6,stroke:#333,stroke-width:2px
    classDef test fill:#e74c3c,stroke:#333,stroke-width:2px

    %% Core Layer
    subgraph CoreLayer["Core Color Type Layer"]
        Color["Color Type"]:::core
        Util["Utilities"]:::core
    end
    click Color "https://github.com/shelepuginivan/color/blob/main/color.go"
    click Util "https://github.com/shelepuginivan/color/blob/main/util.go"

    %% Internal Layer
    subgraph InternalLayer["Internal Layer"]
        Degrees["Angle Calculations"]:::internal
        Percents["Percentage Handling"]:::internal
    end
    click Degrees "https://github.com/shelepuginivan/color/blob/main/internal/degrees/degrees.go"
    click Percents "https://github.com/shelepuginivan/color/blob/main/internal/percents/percents.go"

    %% Public API Layer
    subgraph PublicAPI["Public API Layer"]
        Parse["Parser"]:::api
        Must["Must Functions"]:::api

        %% Color Spaces
        subgraph ColorSpaces["Color Space Implementations"]
            RGB["RGB"]:::colorspace
            CMYK["CMYK"]:::colorspace
            HSL["HSL"]:::colorspace
            HSV["HSV"]:::colorspace
            Lab["Lab"]:::colorspace
            LCH["LCH"]:::colorspace
            XYZ["XYZ"]:::colorspace
        end

        %% Utilities
        subgraph Utils["Utility Functions"]
            Wheel["Color Wheel"]:::utility
            Mix["Color Mixing"]:::utility
            Shades["Shade Generation"]:::utility
            Luminance["Luminance Calc"]:::utility
        end
    end

    %% Component Mappings
    click Parse "https://github.com/shelepuginivan/color/blob/main/parse.go"
    click Must "https://github.com/shelepuginivan/color/blob/main/must.go"
    click RGB "https://github.com/shelepuginivan/color/blob/main/rgb.go"
    click CMYK "https://github.com/shelepuginivan/color/blob/main/cmyk.go"
    click HSL "https://github.com/shelepuginivan/color/blob/main/hsl.go"
    click HSV "https://github.com/shelepuginivan/color/blob/main/hsv.go"
    click Lab "https://github.com/shelepuginivan/color/blob/main/lab.go"
    click LCH "https://github.com/shelepuginivan/color/blob/main/lch.go"
    click XYZ "https://github.com/shelepuginivan/color/blob/main/xyz.go"
    click Wheel "https://github.com/shelepuginivan/color/blob/main/wheel.go"
    click Mix "https://github.com/shelepuginivan/color/blob/main/mix.go"
    click Shades "https://github.com/shelepuginivan/color/blob/main/shades.go"
    click Luminance "https://github.com/shelepuginivan/color/blob/main/luminance.go"

    %% Relationships
    Color --> Parse
    Color --> Must
    Parse --> ColorSpaces
    Must --> ColorSpaces
    
    RGB <--> CMYK
    RGB <--> HSL
    RGB <--> HSV
    RGB <--> XYZ
    XYZ <--> Lab
    Lab <--> LCH
    
    ColorSpaces --> Utils
    HSL --> Degrees
    HSV --> Degrees
    ColorSpaces --> Percents
    
    %% Legend
    subgraph Legend["Legend"]
        CoreComp["Core Component"]:::core
        APIComp["API Component"]:::api
        ColorComp["Color Space"]:::colorspace
        UtilComp["Utility"]:::utility
        InternalComp["Internal"]:::internal
    end
```
