# siapy/siapy-lib architecture

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

- Interactive diagram: https://gitdiagram.com/siapy/siapy-lib
- Repository: https://github.com/siapy/siapy-lib

## Overview

##### Main Components

The system architecture should be organized into the following major components, based on the package structure:

a. Core Layer:
- Configuration management
- Custom exceptions
- Logging system
- Type definitions

b. Entity Layer:
- SpectralImage
- SpectralImageSet
- Pixels
- Signatures

c. Processing Layers:
- Features (spectral indices, feature extraction)
- Transformations (image processing, co-registration)
- Optimizers (parameter optimization, scoring)

d. Support Layer:
- Datasets handling
- Utilities (plotting, evaluation, validation)
- Models and metrics

##### Component Relationships

a. Use a layered architecture approach:
**┌─────────────────────────────────────────────┐**
- Client Code                   │
- ┬─────────────┬───────────────┘
- ▲           ▲             ▲
**┌───┴───┐   ┌───┴───┐   ┌─────┴─────┐**
- Entities│   │Features│   │Transforms │
- ┬───┘   └───┬───┘   └─────┬─────┘

**┌───┴───────────┴─────────────┴───┐**
- Core Layer            │
- ┬─────────────────┘

**┌───────────────┴─────────────────┐**
- Support Layer            │
- ┘

##### Specific Component Details

a. Core Layer (Bottom):
- Configurations, logging, and type system

b. Entity Layer:
- Above core layer
- Relationships between different entity types

c. Processing Components:
- Parallel to entity layer
- Data flow between components

d. Support Layer:
- On the side or bottom
- Utility connections to other components

##### Data Flow Indicators

- Data transformation flow between components
- Input/output relationships

##### Integration Points

- External library integration points (e.g., spectral library)
- CLI integration points
- Public API boundaries

##### Additional Elements

- Version information
- Main entry points
- Test coverage boundaries

##### Technical Details

- Image processing pipelines
- Spectral analysis workflows
- Model integration points
- Data validation flows

- The modular nature of the system
- Clear separation of concerns
- Data processing pipelines
- Extension points for future features

Remember to:
- Use consistent styling
- Document any assumptions

This architecture should reflect SiaPy's focus on spectral image processing while maintaining extensibility for future enhancements.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#2b4b6b,color:white
    classDef entity fill:#3d8f5f,color:white
    classDef processing fill:#a65d57,color:white
    classDef support fill:#666666,color:white
    classDef feature fill:#d4826a,color:white
    classDef transform fill:#8b575a,color:white
    classDef optimizer fill:#7a4446,color:white

    %% Core Layer
    subgraph CoreLayer["Core Layer"]
        Config["Configuration"]:::core
        Exceptions["Exceptions"]:::core
        Logging["Logging"]:::core
        Types["Types"]:::core
    end

    %% Entity Layer
    subgraph EntityLayer["Entity Layer"]
        SpectralImage["SpectralImage"]:::entity
        ImageSet["SpectralImageSet"]:::entity
        Pixels["Pixels"]:::entity
        Shapes["Shapes"]:::entity
        Signatures["Signatures"]:::entity
    end

    %% Processing Layer
    subgraph ProcessingLayer["Processing Layer"]
        subgraph Features["Features"]
            MainFeatures["Features"]:::feature
            SpectralIndices["Spectral Indices"]:::feature
            FeatureHelpers["Feature Helpers"]:::feature
        end

        subgraph Transforms["Transformations"]
            ImageProcessing["Image Processing"]:::transform
            CoRegistration["Co-registration"]:::transform
        end

        subgraph Optimizers["Optimizers"]
            MainOptimizers["Optimizers"]:::optimizer
            Parameters["Parameters"]:::optimizer
            Scorers["Scorers"]:::optimizer
        end
    end

    %% Support Layer
    subgraph SupportLayer["Support Layer"]
        subgraph Datasets["Datasets"]
            DataHelpers["Dataset Helpers"]:::support
            Schemas["Schemas"]:::support
            Tabular["Tabular Data"]:::support
        end

        subgraph Utils["Utilities"]
            Plotting["Plotting"]:::support
            Evaluation["Evaluation"]:::support
            ImageUtils["Image Utils"]:::support
            Validators["Validators"]:::support
        end

        subgraph Models["Models"]
            Metrics["Metrics"]:::support
        end
    end

    %% Relationships
    CoreLayer --> EntityLayer
    CoreLayer --> ProcessingLayer
    CoreLayer --> SupportLayer
    EntityLayer --> ProcessingLayer
    ProcessingLayer --> SupportLayer
    EntityLayer --> SupportLayer

    %% Click Events
    click Config "https://github.com/siapy/siapy-lib/blob/main/siapy/core/configs.py"
    click Exceptions "https://github.com/siapy/siapy-lib/blob/main/siapy/core/exceptions.py"
    click Logging "https://github.com/siapy/siapy-lib/blob/main/siapy/core/logger.py"
    click Types "https://github.com/siapy/siapy-lib/blob/main/siapy/core/types.py"
    click SpectralImage "https://github.com/siapy/siapy-lib/blob/main/siapy/entities/images.py"
    click ImageSet "https://github.com/siapy/siapy-lib/blob/main/siapy/entities/imagesets.py"
    click Pixels "https://github.com/siapy/siapy-lib/blob/main/siapy/entities/pixels.py"
    click Shapes "https://github.com/siapy/siapy-lib/blob/main/siapy/entities/shapes.py"
    click Signatures "https://github.com/siapy/siapy-lib/blob/main/siapy/entities/signatures.py"
    click MainFeatures "https://github.com/siapy/siapy-lib/blob/main/siapy/features/features.py"
    click SpectralIndices "https://github.com/siapy/siapy-lib/blob/main/siapy/features/spectral_indices.py"
    click FeatureHelpers "https://github.com/siapy/siapy-lib/blob/main/siapy/features/helpers.py"
    click ImageProcessing "https://github.com/siapy/siapy-lib/blob/main/siapy/transformations/image.py"
    click CoRegistration "https://github.com/siapy/siapy-lib/blob/main/siapy/transformations/corregistrator.py"
    click MainOptimizers "https://github.com/siapy/siapy-lib/blob/main/siapy/optimizers/optimizers.py"
    click Parameters "https://github.com/siapy/siapy-lib/blob/main/siapy/optimizers/parameters.py"
    click Scorers "https://github.com/siapy/siapy-lib/blob/main/siapy/optimizers/scorers.py"
    click DataHelpers "https://github.com/siapy/siapy-lib/blob/main/siapy/datasets/helpers.py"
    click Schemas "https://github.com/siapy/siapy-lib/blob/main/siapy/datasets/schemas.py"
    click Tabular "https://github.com/siapy/siapy-lib/blob/main/siapy/datasets/tabular.py"
    click Plotting "https://github.com/siapy/siapy-lib/blob/main/siapy/utils/plots.py"
    click Evaluation "https://github.com/siapy/siapy-lib/blob/main/siapy/utils/evaluators.py"
    click ImageUtils "https://github.com/siapy/siapy-lib/blob/main/siapy/utils/images.py"
    click Validators "https://github.com/siapy/siapy-lib/blob/main/siapy/utils/validators.py"
    click Metrics "https://github.com/siapy/siapy-lib/blob/main/siapy/models/metrics.py"
```
