# maarsson/eloquent-getter architecture

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

- Interactive diagram: https://gitdiagram.com/maarsson/eloquent-getter
- Repository: https://github.com/maarsson/eloquent-getter

## Overview

##### Main Components

a) Core Package Components:
- GetterableTrait (key integration point)
- AbstractEloquentGetter (base filtering/sorting logic)
- Command System (for getter generation)

b) Integration Points:
- Laravel Model Layer
- Query Builder Interface
- HTTP Request Layer

##### Component Relationships

**HTTP Request → Laravel Model → GetterableTrait → AbstractEloquentGetter → Query Builder → Database**

##### Specific Implementation Details

a) Service Provider Layer:
- EloquentGetterServiceProvider (registration point)

b) Command Layer:
- MakeGetterCommand (code generation)

c) Core Features:
- Filtering System
- Sorting System
- Attribute Loading System

##### Flow Representation

- Request flow (→): How filters/sorts move through system
- Integration points (⇢): Where package connects to Laravel
- Extension points (⇢): Where users can add custom filters/sorters

##### Key Processes

a) Filter Flow:
**Request with filter[] → Model → GetterableTrait → Custom Filter Methods → Query Builder**

b) Sorter Flow:
**Request with sort_by → Model → GetterableTrait → Custom Sorter Methods → Query Builder**

c) Attribute Loading:
**withAttributes() → Model → Relation Loading → Attribute Selection**

##### Additional Elements

- Configuration points (config/eloquent-getter.php)
- Stub generation flow
- Extension points for custom filters/sorters

##### Implementation Notes

- How the trait injection works
- Where custom getter classes are generated
- Points where user customization is expected

- High-level architecture (package integration)
- Implementation details (filter/sort flow)
- Extension points (custom getters)

Remember to:
- Keep components clearly labeled
- Use consistent styling
- Version/dependency information
- Notes for important configuration options

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External
        HTTP[HTTP Request Layer]
        DB[(Database)]
    end

    subgraph Core["Core Package Components"]
        direction TB
        GT["GetterableTrait"]:::trait
        AEG["AbstractEloquentGetter"]:::core
        CMD["Command System"]:::command
        SP["EloquentGetterServiceProvider"]:::provider
    end

    subgraph Features["Core Features"]
        direction TB
        FS["Filtering System"]:::feature
        SS["Sorting System"]:::feature
        ALS["Attribute Loading System"]:::feature
    end

    subgraph Integration["Integration Layer"]
        direction TB
        LM["Laravel Model"]:::integration
        QB["Query Builder"]:::integration
    end

    subgraph Config["Configuration"]
        direction TB
        CF["Config File"]:::config
        ST["Getter Stub"]:::config
        SFU["Stub Function Utilities"]:::utility
        FCU["Folder Config Utilities"]:::utility
    end

    HTTP --> LM
    LM --> GT
    GT --> AEG
    AEG --> QB
    QB --> DB
    
    GT --> FS
    GT --> SS
    GT --> ALS
    
    SP --> Core
    CMD --> ST
    
    FS --> QB
    SS --> QB
    ALS --> QB

    %% Component Mappings
    click GT "https://github.com/maarsson/eloquent-getter/blob/master/src/Traits/GetterableTrait.php"
    click AEG "https://github.com/maarsson/eloquent-getter/blob/master/src/Getters/AbstractEloquentGetter.php"
    click CMD "https://github.com/maarsson/eloquent-getter/blob/master/src/Console/Commands/MakeGetterCommand.php"
    click SP "https://github.com/maarsson/eloquent-getter/blob/master/src/Providers/EloquentGetterServiceProvider.php"
    click CF "https://github.com/maarsson/eloquent-getter/blob/master/config/eloquent-getter.php"
    click ST "https://github.com/maarsson/eloquent-getter/blob/master/resources/stubs/Getter.stub"
    click SFU "https://github.com/maarsson/eloquent-getter/blob/master/src/Traits/UsesStubFunctionsTrait.php"
    click FCU "https://github.com/maarsson/eloquent-getter/blob/master/src/Traits/UsesFolderConfigTrait.php"

    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef trait fill:#4CAF50,stroke:#2E7D32,color:white
    classDef command fill:#FFC107,stroke:#FFA000,color:black
    classDef provider fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef feature fill:#00BCD4,stroke:#0097A7,color:white
    classDef integration fill:#FF5722,stroke:#E64A19,color:white
    classDef config fill:#795548,stroke:#5D4037,color:white
    classDef utility fill:#607D8B,stroke:#455A64,color:white
```
