# phoboslab/qoi architecture

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

- Interactive diagram: https://gitdiagram.com/phoboslab/qoi
- Repository: https://github.com/phoboslab/qoi

## Overview

##### Main Components
a. Core Library: The heart of the project is the “qoi.h” file. This header encapsulates the encoding and decoding algorithms along with the format specification.
b. Sample Applications/Tools:
– qoiconv.c: A conversion tool demonstrating how to convert between PNG and QOI.
– qoibench.c: A benchmarking tool that wraps around QOI to compare image processing throughput against other libraries (e.g., libpng, stb_image_write.h).
– qoifuzz.c: Likely a fuzzing tool that tests the QOI implementation’s robustness.

##### Architectural Patterns & Design Principles
– Note the separation of concerns: the core algorithm is abstracted in qoi.h, while the sample programs provide usage examples and testing/benchmarking capabilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build and Metadata Section
    subgraph "Environment Setup"
        buildCfg["Build Configuration (Makefile)"]:::build
    end

    subgraph "Project Metadata"
        docReadme["Documentation: README.md"]:::build
        docLicense["Documentation: LICENSE"]:::build
        docGitignore["Documentation: .gitignore"]:::build
    end

    %% Utility Tools Section
    subgraph "Sample Applications"
        convQoi["Conversion Tool (qoiconv.c)"]:::tool
        benchQoi["Benchmark Tool (qoibench.c)"]:::tool
        fuzzQoi["Fuzz Tester (qoifuzz.c)"]:::tool
    end

    %% Core Library Section
    subgraph "Core Library"
        coreQoi["Core QOI Library (qoi.h)"]:::library
    end

    %% Data Flow for Conversion Process
    inputImg["Input Image (PNG)"]:::data
    outputImg["Output Image (QOI/PNG)"]:::data

    %% Connections: Build Configuration influences components
    buildCfg --> coreQoi
    buildCfg --> convQoi
    buildCfg --> benchQoi
    buildCfg --> fuzzQoi

    %% Connections: Documentation influences understanding (no direct dependency)
    docReadme --- coreQoi
    docLicense --- coreQoi
    docGitignore --- coreQoi

    %% Connections: Sample Applications use the Core Library
    convQoi -->|"encode/decode"| coreQoi
    benchQoi -->|"encode/decode"| coreQoi
    fuzzQoi -->|"testCalls"| coreQoi

    %% Additional Conversion Flow
    inputImg -->|"provides data"| convQoi
    coreQoi -->|"returns processed"| outputImg

    %% Styles
    classDef library fill:#b3d9ff,stroke:#333,stroke-width:2px;
    classDef tool fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef build fill:#ffdab9,stroke:#333,stroke-width:2px;
    classDef data fill:#ffffcc,stroke:#333,stroke-width:2px;

    %% Click Events
    click coreQoi "https://github.com/phoboslab/qoi/blob/master/qoi.h"
    click convQoi "https://github.com/phoboslab/qoi/blob/master/qoiconv.c"
    click benchQoi "https://github.com/phoboslab/qoi/blob/master/qoibench.c"
    click fuzzQoi "https://github.com/phoboslab/qoi/blob/master/qoifuzz.c"
    click buildCfg "https://github.com/phoboslab/qoi/tree/master/Makefile"
    click docReadme "https://github.com/phoboslab/qoi/blob/master/README.md"
    click docLicense "https://github.com/phoboslab/qoi/tree/master/LICENSE"
    click docGitignore "https://github.com/phoboslab/qoi/blob/master/.gitignore"
```
