# keithcu/solarfleet architecture

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

- Interactive diagram: https://gitdiagram.com/keithcu/solarfleet
- Repository: https://github.com/keithcu/solarfleet

## Overview

##### Main Components
- Dashboard/UI Component: Represented by Dashboard.py, this is the front-end interface built with Streamlit.
- API Integration Modules: Files such as SolarEdge.py, Enphase.py, SolArk.py (plus any future integrations) handle communication with external solar APIs or perform web scraping.
- Data Collection/Business Logic: FleetCollector.py likely encapsulates the logic for aggregating data from the different API modules.
- Database Access Layer: Database.py and SqlModels.py handle data persistence, caching of API responses, and possibly ORM-related maintenance.
- Auxiliary File: .htaccess might be included for web server configuration but is less central to the application logic.

##### File Structure
- Flat file structure where each Python file appears to directly correspond to a specific function or integration (e.g., SolarPlatform.py may serve as an abstraction or aggregator for the different solar APIs).
- The separation by file names indicates a modular design where each integration’s logic is encapsulated within its own file.
- The presence of a dedicated SQL Models file signifies an intentional separation between business logic and data schema/logic.

##### Core Architectural Patterns and Technologies
- The dashboard follows a Model-View (UI) separation: using Streamlit for the interface and separate modules to handle data retrieval and processing.
- Use of caching mechanisms to optimize API call frequency indicates a focus on performance and efficiency.
- Dependency on both API interactions and Selenium-based web scraping suggests a hybrid integration approach.
- Python serves as the primary programming language with specialized technologies such as Streamlit and Selenium playing central roles.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        A["Streamlit Dashboard"]:::ui
    end

    subgraph "Business Logic Layer"
        B["Fleet Collector"]:::logic
    end

    subgraph "Integration Layer"
        C["SolarEdge Integration"]:::integration
        D["Enphase Integration"]:::integration
        E["Sol-Ark (Selenium) Integration"]:::integration
        F["SolarPlatform Integration"]:::integration
    end

    subgraph "Data Layer"
        G["Database"]:::database
        H["SQL Models"]:::database
    end

    subgraph "External Sources"
        I["SolarEdge External API"]:::external
        J["Enphase External API"]:::external
        K["Sol-Ark External Website"]:::external
    end

    A -->|"requests_data"| B
    B -->|"calls"| C
    B -->|"calls"| D
    B -->|"calls"| E
    B -->|"aggregates"| F
    C -->|"API_call"| I
    D -->|"API_call"| J
    E -->|"Selenium_scrape"| K
    B <-->|"intelligent_caching"| G
    G -->|"ORM_calls"| H

    click A "https://github.com/keithcu/solarfleet/blob/main/Dashboard.py"
    click C "https://github.com/keithcu/solarfleet/blob/main/SolarEdge.py"
    click D "https://github.com/keithcu/solarfleet/blob/main/Enphase.py"
    click E "https://github.com/keithcu/solarfleet/blob/main/SolArk.py"
    click F "https://github.com/keithcu/solarfleet/blob/main/SolarPlatform.py"
    click B "https://github.com/keithcu/solarfleet/blob/main/FleetCollector.py"
    click G "https://github.com/keithcu/solarfleet/blob/main/Database.py"
    click H "https://github.com/keithcu/solarfleet/blob/main/SqlModels.py"

    classDef ui fill:#F8C471,stroke:#641E16,stroke-width:2px;
    classDef logic fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef integration fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef database fill:#F5B7B1,stroke:#78281F,stroke-width:2px;
    classDef external fill:#D2B4DE,stroke:#512E5F,stroke-width:2px;
```
