# aidenkitamura/go-blind-watermark architecture

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

- Interactive diagram: https://gitdiagram.com/aidenkitamura/go-blind-watermark
- Repository: https://github.com/aidenkitamura/go-blind-watermark

## Overview

##### Project Type and Purpose
- This is an open-source command-line utility written in Go.
- It provides two modes—encode (embed a watermark into an image) and decode (extract a watermark from a blended image).
- Key functionality lives in two util packages:
– util/fileio.go handles image loading/saving
– util/imageUtil.go handles Fourier transforms and pixel blending

##### File Structure
Top level:
- go.mod – module definition & dependencies
- README.md – project overview & usage
- LICENSE
util/
- fileio.go – file system interfaces for reading/writing image files
- imageUtil.go – transforms (FFT, IFFT) & blending logic

##### Extract Further Insights from the README
- Describes encode/decode modes controlled by CLI flags (-encode, ‑decode, ‑o, ‑w, ‑d, ‑i, ‑c).
- Uses Fourier transforms to blend/extract watermark.
- No network or database; purely file-based image processing.

##### Main Components to Put
a. CLI Interface (main.go)
– Parses flags, dispatches to encode or decode workflow.
b. File I/O Component (util/fileio)
– Reads original and watermark images
– Writes output image
c. Image Processing Engine (util/imageUtil)
– Performs FFT on input images
– Applies watermark blending or extraction
– Performs inverse FFT
d. Third-Party Libraries / Go Standard Library
– “image” and “image/png/jpeg” packages
– Any FFT library (if external) or custom FFT code
e. File System (local disk)
– Source of input images, sink for output images

##### Relationships and Data Flow
- User invokes CLI → CLI Interface
- CLI Interface → File I/O: load images
- File I/O → Image Processing Engine: pass raw pixel buffers
- Image Processing Engine → Third-Party FFT modules
- Image Processing Engine → File I/O: return processed buffers
- File I/O → File System: write output file

##### Architectural Patterns & Principles
- Pipeline pattern: sequential stages (Load → Transform → Save)
- Single binary deployment (no external services)
- Separation of concerns: CLI parsing, file I/O, and image algorithms each in its own package
- Extensibility point: one could swap out the Fourier implementation or add new transform modes

[ ] Labeled components: CLI, File I/O, Image Processing, FFT library, File System
[ ] Brief notes on each component’s responsibility
[ ] Clear boundary around the Go binary vs. external libraries

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User
    U["User"]:::external
    %% Go Binary
    subgraph "go-blind-watermark Binary"
        CLI["CLI Interface\n(flags: -encode / -decode / -o / -w / -d / -i / -c)"]:::cli
        FileIO["File I/O\n(util/fileio.go)"]:::fileio
        ImageProc["Image Processing Engine\n(util/imageUtil.go)"]:::imageproc
    end
    %% External
    FFTLib["Third-Party Libraries\n(image, png/jpeg, FFT)"]:::external
    FS["File System\n(Local Disk)"]:::storage

    %% Data Flow
    U -->|"invokes CLI"| CLI
    CLI -->|"loadImages(ImageBuffer)"| FileIO
    FileIO -->|"ImageBuffer"| ImageProc
    ImageProc -->|"FFT(ImageBuffer)"| FFTLib
    FFTLib -->|"FFTResult"| ImageProc
    ImageProc -->|"ProcessedBuffer"| FileIO
    FileIO -->|"writeImage"| FS

    %% Click Events
    click FileIO "https://github.com/aidenkitamura/go-blind-watermark/blob/main/util/fileio.go"
    click ImageProc "https://github.com/aidenkitamura/go-blind-watermark/blob/main/util/imageUtil.go"

    %% Styles
    classDef cli fill:#AEDFF7,stroke:#0366d6,color:#000;
    classDef fileio fill:#CDEAC0,stroke:#2E8B57,color:#000;
    classDef imageproc fill:#FDEBC2,stroke:#DAA520,color:#000;
    classDef external fill:#E2E2E2,stroke:#666,color:#000,stroke-dasharray: 5 5;
    classDef storage fill:#F0D0D0,stroke:#A52A2A,color:#000;
```
