# orlandorode97/gofilter architecture

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

- Interactive diagram: https://gitdiagram.com/orlandorode97/gofilter
- Repository: https://github.com/orlandorode97/gofilter

## Overview

##### Project type and purpose
- This is a standalone Go-based CLI application (“go-filter”) whose primary job is to load an image file, apply one of several built-in filter effects (grayscale, sepia, mirror, etc.), and write out the transformed image.

##### File structure
- Top-level:
- go.mod / go.sum – Go module definitions
- Makefile / .gitignore – build and VCS ignores
- cmd/go-filter/ – the only “service”/binary in the repo
- Under cmd/go-filter/:
- main.go – application entry point, sets up the root CLI command
- filter.go + filter_os.go – command registration, shared flags (e.g. --output)
- helper.go – I/O and common helper functions (readImage, writeImage, error handling)
- .go – subcommand to list available filters
- [grey_tone.go, negative_tone.go, red.go, blue.go, green.go, sepia_tone.go, mirror.go, sketch.go, shaperning.go, blur.go] – one filter implementation per file, each applying its own algorithm.

##### README for additional insights
- The README describes the CLI hierarchy:
- root command: go-filter
- subcommand: filter
– flags: --output
– subcommands: list, gray, negative, red, blue, …
- Usage examples and a TODO section hint at a future refactoring towards interfaces (Strategy/Command patterns) and concurrency for filter performance.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "CLI Layer"
        direction TB
        User["Terminal / Shell"]:::user
        Main["go-filter (main.go)"]:::cli
    end

    subgraph "Parser Layer"
        direction TB
        FilterCmd["Command Parser / Dispatcher (filter.go, filter_os.go)"]:::parser
        ListCmd["List Command Parser (list.go)"]:::parser
    end

    subgraph "Handler Layer"
        direction TB
        FilterHandler["FilterCommand Handler"]:::handler
        ListHandler["ListCommand Handler"]:::handler
    end

    subgraph "Domain Layer"
        direction TB
        Helper["Helper Utilities (helper.go)"]:::domain
        subgraph "Filter Strategy Modules"
            direction TB
            Gray["GrayFilter (grey_tone.go)"]:::filter
            Negative["NegativeFilter (negative_tone.go)"]:::filter
            Red["RedFilter (red.go)"]:::filter
            Blue["BlueFilter (blue.go)"]:::filter
            Green["GreenFilter (green.go)"]:::filter
            Sepia["SepiaFilter (sepia_tone.go)"]:::filter
            Mirror["MirrorFilter (mirror.go)"]:::filter
            Sketch["SketchFilter (sketch.go)"]:::filter
            Sharpen["SharpeningFilter (shaperning.go)"]:::filter
            Blur["BlurFilter (blur.go)"]:::filter
        end
    end

    subgraph "Infrastructure Layer"
        direction TB
        FS["File System"]:::infra
        StdLib["Go Std Libraries"]:::infra
        GoMod["go.mod"]:::config
        GoSum["go.sum"]:::config
        Makefile["Makefile"]:::config
        Gitignore[".gitignore"]:::config
    end

    %% Connections
    User -->|"execute go-filter"| Main
    Main -->|"invoke parser"| FilterCmd
    Main -->|"invoke parser"| ListCmd

    FilterCmd -->|"handles filter command"| FilterHandler
    ListCmd -->|"handles list command"| ListHandler

    FilterHandler -->|"ReadImage()"| Helper
    FilterHandler -->|"selects strategy"| Gray
    FilterHandler -->|"selects strategy"| Negative
    FilterHandler -->|"selects strategy"| Red
    FilterHandler -->|"selects strategy"| Blue
    FilterHandler -->|"selects strategy"| Green
    FilterHandler -->|"selects strategy"| Sepia
    FilterHandler -->|"selects strategy"| Mirror
    FilterHandler -->|"selects strategy"| Sketch
    FilterHandler -->|"selects strategy"| Sharpen
    FilterHandler -->|"selects strategy"| Blur

    Gray -->|"Apply() returns Image"| FilterHandler
    Negative -->|"Apply() returns Image"| FilterHandler
    Red -->|"Apply() returns Image"| FilterHandler
    Blue -->|"Apply() returns Image"| FilterHandler
    Green -->|"Apply() returns Image"| FilterHandler
    Sepia -->|"Apply() returns Image"| FilterHandler
    Mirror -->|"Apply() returns Image"| FilterHandler
    Sketch -->|"Apply() returns Image"| FilterHandler
    Sharpen -->|"Apply() returns Image"| FilterHandler
    Blur -->|"Apply() returns Image"| FilterHandler

    FilterHandler -->|"WriteImage()"| Helper
    Helper -->|"writes file"| FS

    FilterHandler -->|"uses"| StdLib

    Main -->|"module definitions"| GoMod
    Main -->|"module definitions"| GoSum
    Main -->|"build tasks"| Makefile
    Main -->|"ignore rules"| Gitignore

    %% Click Events
    click Main "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/main.go"
    click FilterCmd "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/filter.go"
    click ListCmd "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/list.go"
    click Helper "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/helper.go"
    click Gray "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/grey_tone.go"
    click Negative "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/negative_tone.go"
    click Red "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/red.go"
    click Blue "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/blue.go"
    click Green "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/green.go"
    click Sepia "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/sepia_tone.go"
    click Mirror "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/mirror.go"
    click Sketch "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/sketch.go"
    click Sharpen "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/shaperning.go"
    click Blur "https://github.com/orlandorode97/gofilter/blob/main/cmd/go-filter/blur.go"
    click GoMod "https://github.com/orlandorode97/gofilter/blob/main/go.mod"
    click GoSum "https://github.com/orlandorode97/gofilter/blob/main/go.sum"
    click Makefile "https://github.com/orlandorode97/gofilter/tree/main/Makefile"
    click Gitignore "https://github.com/orlandorode97/gofilter/blob/main/.gitignore"

    %% Styles
    classDef user fill:#D6EAF8,stroke:#2980B9,color:#154360,stroke-width:2px
    classDef cli fill:#E8F8F5,stroke:#1ABC9C,color:#117A65,stroke-width:2px
    classDef parser fill:#FDEDEC,stroke:#E74C3C,color:#78281F,stroke-width:2px
    classDef handler fill:#FEF9E7,stroke:#F1C40F,color:#7D6608,stroke-width:2px
    classDef domain fill:#EAFAF1,stroke:#27AE60,color:#145A32,stroke-width:2px
    classDef filter fill:#EBDEF0,stroke:#8E44AD,color:#512E5F,stroke-width:2px
    classDef infra fill:#F2F3F4,stroke:#7B7D7D,color:#2C3E50,stroke-width:2px
    classDef config fill:#FCF3CF,stroke:#B7950B,color:#7D6608,stroke-width:2px
```
