# danieldotnl/ha-multiscrape architecture

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

- Interactive diagram: https://gitdiagram.com/danieldotnl/ha-multiscrape
- Repository: https://github.com/danieldotnl/ha-multiscrape

## Overview

##### Main Components Identification
The system should be represented with these key components:

a. Core Component Layer:
- Integration Core (`__init__.py`)
- Data Coordinator (`coordinator.py`)
- Configuration Handler (`form.py`, `schema.py`)
- Scraping Engine (`scraper.py`)

b. Entity Layer:
- Sensor Entities (`sensor.py`)
- Binary Sensor Entities (`binary_sensor.py`)
- Button Entities (`button.py`)

c. Support Layer:
- HTTP Client (`http.py`)
- File Handler (`file.py`)
- Utility Functions (`util.py`)
- Selector Logic (`selector.py`)

##### Component Relationships

**[Home Assistant Core] <---> [Integration Core]**

- [Data Coordinator]

- [Config Handler] [Scraping Engine]

- [Entity Layer] <-----> [HTTP Client]

##### Data Flow Representation

- Configuration flow: Config Handler → Data Coordinator
- Scraping flow: HTTP Client → Scraping Engine → Data Coordinator → Entities
- Service calls: Home Assistant → Integration Core → Data Coordinator

##### Detailed Component Descriptions

**[Data Coordinator]**
- Manages update intervals
- Handles data synchronization
- Coordinates scraping operations

**[Scraping Engine]**
- CSS Selector processing
- BeautifulSoup parsing
- Value extraction
- Template rendering

**[Entity Layer]**
- Sensor state management
- Attribute handling
- Value formatting

##### Integration Points

External interfaces:
- Home Assistant Core Integration
- Web Scraping Targets
- Configuration System
- Service Registry

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Systems
    HA[Home Assistant Core]:::external
    Web[Web Resources]:::external

    %% Core Layer
    subgraph Core
        Init["Integration Core"]:::core
        Coord["Data Coordinator"]:::core
        Config["Configuration Handler"]:::core
        Scraper["Scraping Engine"]:::core
    end

    %% Entity Layer
    subgraph Entities
        Sensor["Sensor Entities"]:::entity
        BSensor["Binary Sensor Entities"]:::entity
        Button["Button Entities"]:::entity
        BaseEntity["Base Entity"]:::entity
    end

    %% Support Layer
    subgraph Support
        HTTP["HTTP Client"]:::support
        File["File Handler"]:::support
        Util["Utility Functions"]:::support
        Selector["Selector Logic"]:::support
        Service["Service Layer"]:::support
        Constants["Constants"]:::support
    end

    %% Relationships
    HA <--> Init
    Init --> Coord
    Coord --> Config
    Coord --> Scraper
    Scraper --> HTTP
    HTTP --> Web
    
    Coord --> Entities
    BaseEntity --> Sensor
    BaseEntity --> BSensor
    BaseEntity --> Button
    
    Service --> Coord
    Scraper --> Selector
    Scraper --> File
    Scraper --> Util
    Config --> Constants

    %% Click Events
    click Init "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/__init__.py"
    click Coord "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/coordinator.py"
    click Config "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/form.py"
    click Scraper "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/scraper.py"
    click Sensor "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/sensor.py"
    click BSensor "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/binary_sensor.py"
    click Button "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/button.py"
    click BaseEntity "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/entity.py"
    click HTTP "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/http.py"
    click File "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/file.py"
    click Util "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/util.py"
    click Selector "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/selector.py"
    click Service "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/service.py"
    click Constants "https://github.com/danieldotnl/ha-multiscrape/blob/master/custom_components/multiscrape/const.py"

    %% Styles
    classDef core fill:#2374e1,color:white
    classDef entity fill:#4caf50,color:white
    classDef support fill:#757575,color:white
    classDef external fill:#ff9800,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Entity Components]:::entity
        L3[Support Components]:::support
        L4[External Systems]:::external
    end
```
