# frequenz-floss/frequenz-sdk-python architecture

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

- Interactive diagram: https://gitdiagram.com/frequenz-floss/frequenz-sdk-python
- Repository: https://github.com/frequenz-floss/frequenz-sdk-python

## Overview

##### Main Components

a. Core SDK Components:
- Actor System (src/frequenz/sdk/actor)
- Microgrid Management (src/frequenz/sdk/microgrid)
- Time Series Processing (src/frequenz/sdk/timeseries)
- Configuration Management (src/frequenz/sdk/config)

b. Key Subsystems:
- Power Distribution System
- Data Sourcing System
- Formula Engine
- Component Pools (Battery, EV Charger, PV)

**┌─────────────────────────────────────────────────────────────┐**
- Client Applications                      │
- ┘
- ▲

**┌─────────────────────────────────────────────────────────────┐**
- SDK Core                            │
- ┬────────────────┬──────────────┬──────────────┤
- Actor      │   Microgrid    │  Time Series │    Config    │
- System     │   Management   │  Processing  │  Management  │
- ┴────────────────┴──────────────┴──────────────┘
- ▲

**┌─────────────────────────────────────────────────────────────┐**
- Component Management                      │
- ┬────────────────┬──────────────┬──────────────┤
- Battery    │  EV Charger    │     PV       │   Logical    │
- Pool     │     Pool       │    Pool      │    Meter     │
- ┴────────────────┴──────────────┴──────────────┘
- ▲

**┌─────────────────────────────────────────────────────────────┐**
- Power Management                          │
- ┬────────────────┬──────────────┬──────────────┤
- Power     │     Power      │    Power     │   Formula    │
- Distribution │   Managing     │   Wrapper    │   Engine     │
- ┴────────────────┴──────────────┴──────────────┘
- ▲

**┌─────────────────────────────────────────────────────────────┐**
- Data Processing                           │
- ┬────────────────┬──────────────┬──────────────┤
- Data      │   Resampling   │  Ring Buffer │   Moving     │
- Sourcing   │               │              │   Window     │
- ┴────────────────┴──────────────┴──────────────┘

##### Important Relationships to Highlight

- Actor System's relationship with all components (central to architecture)
- Data flow from Data Sourcing through Power Management to Component Pools
- Formula Engine's integration with Time Series Processing
- Component Pool interactions with Power Distribution

##### Additional Elements

A separate panel showing:
- External interfaces (API connections)
- Configuration flow
- Error handling paths
- Monitoring and logging paths

##### Implementation Details

- Async nature of the system (shown in actor system)
- Data pipeline architecture
- Component pooling and management
- Power distribution algorithms
- Time series processing capabilities

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Applications"]
        App1[Application 1]
        App2[Application 2]
    end

    subgraph Core["SDK Core"]
        Actor["Actor System"]:::core
        Microgrid["Microgrid Management"]:::core
        TimeSeries["Time Series Processing"]:::core
        Config["Config Management"]:::core
    end

    subgraph Components["Component Management"]
        Battery["Battery Pool"]:::component
        EVCharger["EV Charger Pool"]:::component
        PV["PV Pool"]:::component
        LogicalMeter["Logical Meter"]:::component
    end

    subgraph Power["Power Management"]
        PowerDist["Power Distribution"]:::power
        PowerManage["Power Managing"]:::power
        PowerWrap["Power Wrapper"]:::power
        Formula["Formula Engine"]:::power
    end

    subgraph Data["Data Processing"]
        DataSource["Data Sourcing"]:::data
        Resampling["Resampling"]:::data
        RingBuffer["Ring Buffer"]:::data
        MovingWindow["Moving Window"]:::data
    end

    %% Connections
    Client --> Core
    Core --> Components
    Core --> Power
    Core --> Data

    %% Internal Core Connections
    Actor <--> Microgrid
    Actor <--> TimeSeries
    Actor <--> Config

    %% Component Connections
    Battery <--> PowerDist
    EVCharger <--> PowerDist
    PV <--> PowerDist
    LogicalMeter <--> PowerDist

    %% Power Management Connections
    PowerDist <--> PowerManage
    PowerManage <--> PowerWrap
    Formula <--> TimeSeries

    %% Data Processing Connections
    DataSource --> RingBuffer
    RingBuffer --> MovingWindow
    MovingWindow --> Resampling

    %% Click Events
    click Actor "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/actor/"
    click Microgrid "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/microgrid/"
    click TimeSeries "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/timeseries/"
    click Config "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/config/"
    click PowerDist "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/microgrid/_power_distributing/"
    click DataSource "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/microgrid/_data_sourcing/"
    click Formula "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/timeseries/formula_engine/"
    click Battery "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/timeseries/battery_pool/"
    click EVCharger "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/timeseries/ev_charger_pool/"
    click PV "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/timeseries/pv_pool/"
    click PowerManage "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/microgrid/_power_managing/"
    click LogicalMeter "https://github.com/frequenz-floss/frequenz-sdk-python/tree/v1.x.x/src/frequenz/sdk/timeseries/logical_meter/"

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef component fill:#2ecc71,stroke:#27ae60,color:white
    classDef power fill:#e67e22,stroke:#d35400,color:white
    classDef data fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        CoreL["Core Components"]:::core
        CompL["Component Management"]:::component
        PowerL["Power Management"]:::power
        DataL["Data Processing"]:::data
    end
```
