# slvler/etherscan-service architecture

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

- Interactive diagram: https://gitdiagram.com/slvler/etherscan-service
- Repository: https://github.com/slvler/etherscan-service

## Overview

##### Main Components

a. Client Application Layer
- Represents the Laravel application using this package

b. Package Core Components
- EtherServiceProvider (Main service provider)
- EtherScanService (Core service class)
- Resource handlers (Balance)
- Exception handlers

c. External Service Layer
- Etherscan.io API

**[Client Laravel Application]**
- ↓
**[EtherServiceProvider]**
- ↓
**[EtherScanService]**
- ↙     ↓     ↘
**[Balance] [Exceptions] [Config]**
- ↓
**[Etherscan.io API]**

##### Component Details

- Blue: Client application
- Green: Package core components
- Yellow: Resource handlers
- Red: Exception handlers
- Purple: External API service
- Gray: Configuration components

b. Connection Types:

##### Specific Elements

a. Service Provider Layer:
- EtherServiceProvider as the entry point
- Config binding process
- Service registration flow

b. Service Layer:
- EtherScanService with its main methods:
- balance()
- balance_multiple()
- transactions_normal()
- transactions_internal()
- etc.

c. Resource Handlers:
- Balance class and its relationship with the service
- Potential expansion points for future resources

d. Exception Handling:
- Three exception types:
- ErrorException
- MissingApiKey
- MissingArgumentException

e. Configuration:
- Config/etherscan.php integration
- Environment variable dependencies

##### Notes for Implementation

- Clear separation between package components and external services
- API integration points
- Error handling flow
- Configuration management process

##### Optional Additions

- Testing workflow integration

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef provider fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#27ae60,stroke:#219a52,color:white
    classDef resource fill:#f1c40f,stroke:#f39c12,color:black
    classDef exception fill:#e74c3c,stroke:#c0392b,color:white
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef test fill:#1abc9c,stroke:#16a085,color:white

    %% Client Application Layer
    Client["Laravel Application"]:::client

    %% Service Provider Layer
    Provider["EtherServiceProvider"]:::provider
    click Provider "https://github.com/slvler/etherscan-service/blob/main/src/EtherServiceProvider.php"

    %% Service Layer
    Service["EtherScanService"]:::service
    click Service "https://github.com/slvler/etherscan-service/blob/main/src/Services/EtherScanService.php"

    %% Resource Layer
    Balance["Balance Handler"]:::resource
    click Balance "https://github.com/slvler/etherscan-service/blob/main/src/Resources/Balance.php"

    %% Exception Layer
    subgraph Exceptions
        ErrorEx["ErrorException"]:::exception
        ApiKeyEx["MissingApiKey"]:::exception
        ArgEx["MissingArgumentException"]:::exception
    end
    click ErrorEx "https://github.com/slvler/etherscan-service/blob/main/src/Exception/ErrorException.php"
    click ApiKeyEx "https://github.com/slvler/etherscan-service/blob/main/src/Exception/MissingApiKey.php"
    click ArgEx "https://github.com/slvler/etherscan-service/blob/main/src/Exception/MissingArgumentException.php"
    click Exceptions "https://github.com/slvler/etherscan-service/tree/main/src/Exception/"

    %% Configuration
    Config["etherscan.php"]:::config
    click Config "https://github.com/slvler/etherscan-service/blob/main/config/etherscan.php"

    %% Testing Infrastructure
    subgraph Testing
        FeatureTest["Feature Tests"]:::test
        UnitTest["Unit Tests"]:::test
        Pipeline["CI/CD Pipeline"]:::test
    end
    click FeatureTest "https://github.com/slvler/etherscan-service/blob/main/tests/Feature/EtherScanTest.php"
    click UnitTest "https://github.com/slvler/etherscan-service/blob/main/tests/Unit/TestCase.php"
    click Pipeline "https://github.com/slvler/etherscan-service/blob/main/.github/workflows/tests.yml"

    %% External API
    API["Etherscan.io API"]:::external

    %% Relationships
    Client --> Provider
    Provider --> Service
    Provider --> Config
    Service --> Balance
    Service --> Exceptions
    Service --> API
    Balance --> API
    Testing --> Service

    %% Legend
    subgraph Legend
        L1["Client Application"]:::client
        L2["Service Provider"]:::provider
        L3["Core Service"]:::service
        L4["Resource Handler"]:::resource
        L5["Exception Handler"]:::exception
        L6["Configuration"]:::config
        L7["External Service"]:::external
        L8["Testing"]:::test
    end
```
