# agentsquidflaps/picture architecture

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

- Interactive diagram: https://gitdiagram.com/agentsquidflaps/picture
- Repository: https://github.com/agentsquidflaps/picture

## Overview

##### Core Components
- Picture Generator (Central Component)
- Source Adapters Layer
- Media Query Handler
- Image Processing Pipeline

##### Adapter Integration Layer
Following adapters with clear separation:
- Cloudfront Adapter
- Intervention Adapter
- PicSum Adapter
- PlaceImg Adapter
- NullImg Adapter

##### Feature Processing Modules
- WebP Conversion
- Retina Processing
- Lazy Loading
- MIME Type Handler

##### Component Relationships
- Picture → Source (composition)
- Source → Adapters (implementation)
- Picture → MediaQuery (association)
- Adapters → ImageMimeType (dependency)

##### Process Flow
Image processing pipeline:
1. Input (original image) →
2. Adapter Processing →
3. Feature Application (WebP/Retina/Lazy) →
4. HTML Output Generation

##### Configuration Layer
Environment configuration:
- PICTURE_WEB_ROOT
- PICTURE_CACHE_RELATIVE_PATH

- [Picture] ← Central class
- [Source] ← Source handling
- [MediaQuery] ← Media query processing
- [ImageMimeType] ← MIME type handling

##### Adapter Interface (Hexagon)
- <AdapterInterface>

##### Implementation Classes (Rounded Rectangles)
- (Cloudfront)
- (Intervention)
- (PicSum)
- (PlaceImg)
- (NullImg)

- [ChecksForSetValuesTrait]
- [RequiresAttributeMarkupTrait]
- [isLocalTrait]
- [isSourceTrait]

##### Clear separation between
- Local image processing (Intervention)
- Remote image services (Cloudfront, PicSum, PlaceImg)

##### Extensibility points
- Adapter interface
- Trait implementations
- Configuration options

##### External dependencies
- GD Library
- Symfony HTTP Foundation
- Intervention Image

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core
        Picture["Picture Generator"]
        Source["Source Handler"]
        MediaQuery["Media Query Handler"]
        ImageMimeType["MIME Type Handler"]
    end

    subgraph "Adapter Layer"
        AdapterInterface["Adapter Interface"]
        
        subgraph "Remote Adapters"
            Cloudfront["Cloudfront Adapter"]
            PicSum["PicSum Adapter"]
            PlaceImg["PlaceImg Adapter"]
            NullImg["NullImg Adapter"]
        end
        
        subgraph "Local Adapters"
            Intervention["Intervention Adapter"]
        end
    end

    subgraph "Utility Traits"
        ChecksForSetValues["Checks For Set Values"]
        RequiresAttributeMarkup["Requires Attribute Markup"]
        IsLocal["Is Local"]
        IsSource["Is Source"]
    end

    subgraph "External Dependencies"
        GD["GD Library"]
        Symfony["Symfony HTTP Foundation"]
        InterventionLib["Intervention Image"]
    end

    %% Core Relationships
    Picture --> Source
    Picture --> MediaQuery
    Source --> AdapterInterface
    Picture --> ImageMimeType

    %% Adapter Implementations
    AdapterInterface --> Cloudfront
    AdapterInterface --> PicSum
    AdapterInterface --> PlaceImg
    AdapterInterface --> NullImg
    AdapterInterface --> Intervention

    %% Trait Usage
    Picture -.-> ChecksForSetValues
    Picture -.-> RequiresAttributeMarkup
    Source -.-> IsLocal
    Source -.-> IsSource

    %% External Dependencies
    Intervention --> GD
    Intervention --> InterventionLib
    Picture --> Symfony

    %% Click Events
    click Picture "https://github.com/agentsquidflaps/picture/blob/master/src/Picture.php"
    click Source "https://github.com/agentsquidflaps/picture/blob/master/src/Source.php"
    click MediaQuery "https://github.com/agentsquidflaps/picture/blob/master/src/MediaQuery.php"
    click ImageMimeType "https://github.com/agentsquidflaps/picture/blob/master/src/ImageMimeType.php"
    click AdapterInterface "https://github.com/agentsquidflaps/picture/blob/master/src/Adapter/AdapterInterface.php"
    click Cloudfront "https://github.com/agentsquidflaps/picture/blob/master/src/Adapter/Cloudfront.php"
    click PicSum "https://github.com/agentsquidflaps/picture/blob/master/src/Adapter/PicSum.php"
    click PlaceImg "https://github.com/agentsquidflaps/picture/blob/master/src/Adapter/PlaceImg.php"
    click NullImg "https://github.com/agentsquidflaps/picture/blob/master/src/Adapter/NullImg.php"
    click Intervention "https://github.com/agentsquidflaps/picture/blob/master/src/Adapter/Intervention.php"
    click ChecksForSetValues "https://github.com/agentsquidflaps/picture/blob/master/src/Traits/ChecksForSetValuesTrait.php"
    click RequiresAttributeMarkup "https://github.com/agentsquidflaps/picture/blob/master/src/Traits/RequiresAttributeMarkupTrait.php"
    click IsLocal "https://github.com/agentsquidflaps/picture/blob/master/src/Traits/isLocalTrait.php"
    click IsSource "https://github.com/agentsquidflaps/picture/blob/master/src/Traits/isSourceTrait.php"

    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef adapter fill:#48a9a6,stroke:#48a9a6,color:#fff
    classDef trait fill:#e4cc37,stroke:#e4cc37,color:#000
    classDef external fill:#999,stroke:#999,color:#fff

    class Picture,Source,MediaQuery,ImageMimeType core
    class AdapterInterface,Cloudfront,PicSum,PlaceImg,NullImg,Intervention adapter
    class ChecksForSetValues,RequiresAttributeMarkup,IsLocal,IsSource trait
    class GD,Symfony,InterventionLib external
```
