# ascorbic/unpic-img architecture

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

- Interactive diagram: https://gitdiagram.com/ascorbic/unpic-img
- Repository: https://github.com/ascorbic/unpic-img

## Overview

##### Main Components Structure

a. Core Layer (Center):
- Image Processing Logic
- CDN Detection
- URL Generation
- Type Definitions

b. Framework Implementations (Surrounding the Core):
- Create connected modules for each framework implementation:
- React
- Vue
- Svelte
- Angular
- Astro
- Preact
- Qwik
- WebC
- Lit
- SolidJS

##### Integration Layers

a. CDN Integration Layer (Top):
- Major providers like:
- Cloudinary
- Imgix
- Shopify
- Vercel
- Others (grouped)

b. Features Layer (Bottom):
- Create connected modules for key features:
- Responsive Sizing
- Lazy Loading
- Format Optimization
- Placeholder Generation
- Art Direction

##### Implementation Details

- Hexagons for core components
- Rectangles for framework implementations
- Rounded rectangles for features

##### Data Flow Indicators

- Image request flow
- CDN transformation pipeline
- Framework component initialization
- Asset optimization path

##### Component Relationships

How different parts interact:
- Core to framework adapters
- Framework-specific implementations
- CDN service connections
- Feature availability per framework

##### Technical Details

Annotations for:
- Zero-runtime JavaScript note
- Browser native features usage
- CDN API integration points
- Framework-specific optimizations

##### Optimization Flow

- Input image handling
- CDN transformation
- Browser delivery
- Responsive adaptation

Key Considerations:

##### Documentation
- Version information
- Performance characteristics
- Browser compatibility
- Reference key configuration options

- The framework-agnostic nature of the core
- The plug-and-play nature of framework implementations
- The seamless integration with various CDNs
- The zero-runtime JavaScript architecture
- The focus on performance and best practices

Remember to maintain a balance between technical detail and clarity, as this is a complex system with multiple integration points and framework-specific implementations.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core["Core Layer"]
        UnpicCore(("unpic-core")):::core
        URLGen["URL Generation"]:::core
        CDNDetect["CDN Detection"]:::core
        TypeDefs["Type Definitions"]:::core
        ImgProc["Image Processing"]:::core
        
        UnpicCore --- URLGen
        UnpicCore --- CDNDetect
        UnpicCore --- TypeDefs
        UnpicCore --- ImgProc
    end

    subgraph CDNs["CDN Integration Layer"]
        Cloudinary["Cloudinary"]:::cdn
        Imgix["Imgix"]:::cdn
        Shopify["Shopify"]:::cdn
        Vercel["Vercel"]:::cdn
        OtherCDNs["Other CDNs"]:::cdn
    end

    subgraph Frameworks["Framework Implementations"]
        direction TB
        React["React"]:::framework
        Vue["Vue"]:::framework
        Svelte["Svelte"]:::framework
        Angular["Angular"]:::framework
        Astro["Astro"]:::framework
        Preact["Preact"]:::framework
        Qwik["Qwik"]:::framework
        WebC["WebC"]:::framework
        Lit["Lit"]:::framework
        Solid["SolidJS"]:::framework
    end

    subgraph Features["Features Layer"]
        ResponsiveSize["Responsive Sizing"]:::feature
        LazyLoad["Lazy Loading"]:::feature
        FormatOpt["Format Optimization"]:::feature
        Placeholder["Placeholder Generation"]:::feature
        ArtDirection["Art Direction"]:::feature
    end

    %% Connections
    CDNs --> UnpicCore
    UnpicCore --> Frameworks
    Features --> UnpicCore

    %% Click Events
    click UnpicCore "https://github.com/ascorbic/unpic-img/tree/main/packages/core/src/"
    click URLGen "https://github.com/ascorbic/unpic-img/blob/main/packages/core/src/base.ts"
    click TypeDefs "https://github.com/ascorbic/unpic-img/blob/main/packages/core/src/types.ts"
    click React "https://github.com/ascorbic/unpic-img/tree/main/packages/react/src/"
    click Vue "https://github.com/ascorbic/unpic-img/tree/main/packages/vue/src/"
    click Svelte "https://github.com/ascorbic/unpic-img/tree/main/packages/svelte/src/lib/"
    click Angular "https://github.com/ascorbic/unpic-img/tree/main/packages/angular/src/lib/"
    click Astro "https://github.com/ascorbic/unpic-img/tree/main/packages/astro/src/"
    click Preact "https://github.com/ascorbic/unpic-img/tree/main/packages/preact/src/"
    click Qwik "https://github.com/ascorbic/unpic-img/tree/main/packages/qwik/src/components/"
    click WebC "https://github.com/ascorbic/unpic-img/tree/main/packages/webc/"
    click Lit "https://github.com/ascorbic/unpic-img/tree/main/packages/lit/src/"
    click Solid "https://github.com/ascorbic/unpic-img/tree/main/packages/solid/src/"

    %% Styling
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef cdn fill:#85C1E9,stroke:#333,stroke-width:1px
    classDef framework fill:#82E0AA,stroke:#333,stroke-width:1px
    classDef feature fill:#F8C471,stroke:#333,stroke-width:1px

    %% Legend
    subgraph Legend
        CoreLegend["Core Components"]:::core
        CDNLegend["CDN Services"]:::cdn
        FrameworkLegend["Framework Implementations"]:::framework
        FeatureLegend["Features"]:::feature
    end
```
