# demandregioteam/disaggregator architecture

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

- Interactive diagram: https://gitdiagram.com/demandregioteam/disaggregator
- Repository: https://github.com/demandregioteam/disaggregator

## Overview

##### Project Type and Purpose
- The project is a Python-based toolkit combined with demonstration notebooks. Its purpose is to perform spatial and temporal disaggregation of energy demand (electricity, heat, and gas) for different sectors (private households, commerce/CTS, and industry).
- The README describes the setup of a database plus the “disaggregator” toolkit. Its primary aim is to process input data (from Excel, CSV, shapefiles, etc.) and generate disaggregated output.

##### File Structure
- Top-level files include multiple Jupyter Notebooks that demonstrate various aspects (data configuration, spatial and temporal disaggregation, industry specific examples, etc.).
- The “disaggregator” directory contains the Python modules that constitute the core functions for disaggregation (animation, config, data handling, plotting, spatial and temporal operations).
- Other important files are environment.yml (which defines the conda environment and dependencies), README.md (which explains usage and overview), and LICENSE.

##### README for Additional Insights
- The README clearly outlines how to install dependencies, start a Jupyter Notebook session, and run demo notebooks. This indicates that the end-user interface is via Jupyter.
- The “How does it work?” section notes that functions in the “disaggregator” are applied to data extracted from a database or data files to produce spatial and temporal disaggregations.

a. Main Components to Include:
- Data Input Layer: Represent the “data_in” directory and its subdirectories (dimensionless, regional, temporal). This component feeds raw data into the system.
- Core Toolkit (“disaggregator” Package): Show individual modules (data handling, config, spatial, temporal, plotting, animation). This is the engine that applies transformations and analytics.
- Demo Interface: The Jupyter Notebooks (e.g., 01_Demo_data-and-config.ipynb, etc.) demonstrate how users interact with the toolkit.
- Environment and Dependency Management: Acknowledge the role of the conda environment (environment.yml) that assures correct library installations.
- (Optional) External Data Sources and Databases: Although not a live database service, the project includes pre-processed data to simulate a database input.

b. Relationships and Interactions:
- The notebooks serve as a UI layer that orchestrates calls to the “disaggregator” modules and displays output (e.g., plotted graphics, results).
- Dependency of disaggregation functions on configuration settings (as loaded from config.py and config_example.yaml).
- Interactions like data preprocessing, applying transformation functions, and plotting animated results.

c. Architectural Patterns & Design Principles:
- Clearly separate concerns: one layer for data input/handling, one for computational logic (disaggregation), and one for presentation (Jupyter notebooks / plotting).
- Leverage modularity by isolating spatial and temporal processing in separate modules.
- The project follows a pipeline style architecture where data is read, transformed, and visualized.

d. Relevant Technologies and Frameworks:
- Python (core language)
- Jupyter Notebook for interactive demonstration and prototyping.
- Conda for environment management.
- Data file formats (Excel, CSV, shapefiles) and libraries that likely include pandas, geopandas, matplotlib, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Input Layer
    subgraph "Data Input Layer"
        DI["data_in"]:::data
        DI_dim["data_in/dimensionless"]:::data
        DI_reg["data_in/regional"]:::data
        DI_temp["data_in/temporal"]:::data
    end

    %% Core Toolkit – Disaggregation Modules
    subgraph "Core Toolkit - Disaggregation Modules"
        DT["disaggregator"]:::toolkit
        DT_anim["animation.py"]:::toolkit
        DT_config["config.py"]:::toolkit
        DT_data["data.py"]:::toolkit
        DT_plot["plot.py"]:::toolkit
        DT_spatial["spatial.py"]:::toolkit
        DT_temporal["temporal.py"]:::toolkit
        DT_configEx["config_example.yaml"]:::toolkit
    end

    %% Demo Notebook Interface
    subgraph "Demo Notebook Interface"
        NB1["01_Demo_data-and-config.ipynb"]:::notebook
        NB2["02_Demo_households_spatial_disaggregations.ipynb"]:::notebook
        NB3["03_Demo_households_temporal_disaggregations.ipynb"]:::notebook
        NB4["04_Demo_CTS_Industry_disaggregation.ipynb"]:::notebook
        NB5["90_Accessing_geographical_data.ipynb"]:::notebook
    end

    %% Environment Management
    ENV["environment.yml"]:::env

    %% Concept Overview Diagram
    IMG["Overview Diagram"]:::diagram

    %% Data Flow from Data Input to Core Toolkit
    DI_dim -->|"provides_data"| DT_data
    DI_reg  -->|"regional_data"| DT_spatial
    DI_temp -->|"temporal_data"| DT_temporal

    %% Configuration dependency within Toolkit
    DT_config ---|"configures"| DT_data
    DT_config ---|"configures"| DT_spatial
    DT_config ---|"configures"| DT_temporal
    DT_configEx ---|"sample_config"| DT_config

    %% Toolkit Modules to Notebook Interface interactions
    DT_data -->|"processes"| NB1
    DT_spatial -->|"processes"| NB2
    DT_temporal -->|"processes"| NB3
    DT_plot -->|"generates_plot"| NB1
    DT_anim -->|"generates_animation"| NB4

    %% Environment influences Toolkit and Notebooks
    ENV -->|"dependency"| DT
    ENV -->|"dependency"| NB1

    %% Concept overview supports overall design
    IMG ---|"overview"| DT

    %% Click Events for Data Input Layer
    click DI "https://github.com/demandregioteam/disaggregator/tree/master/data_in"
    click DI_dim "https://github.com/demandregioteam/disaggregator/tree/master/data_in/dimensionless"
    click DI_reg "https://github.com/demandregioteam/disaggregator/tree/master/data_in/regional"
    click DI_temp "https://github.com/demandregioteam/disaggregator/tree/master/data_in/temporal"

    %% Click Events for Core Toolkit – Disaggregation Modules
    click DT "https://github.com/demandregioteam/disaggregator/tree/master/disaggregator"
    click DT_anim "https://github.com/demandregioteam/disaggregator/blob/master/disaggregator/animation.py"
    click DT_config "https://github.com/demandregioteam/disaggregator/blob/master/disaggregator/config.py"
    click DT_data "https://github.com/demandregioteam/disaggregator/blob/master/disaggregator/data.py"
    click DT_plot "https://github.com/demandregioteam/disaggregator/blob/master/disaggregator/plot.py"
    click DT_spatial "https://github.com/demandregioteam/disaggregator/blob/master/disaggregator/spatial.py"
    click DT_temporal "https://github.com/demandregioteam/disaggregator/blob/master/disaggregator/temporal.py"
    click DT_configEx "https://github.com/demandregioteam/disaggregator/blob/master/disaggregator/config_example.yaml"

    %% Click Events for Demo Notebook Interface
    click NB1 "https://github.com/demandregioteam/disaggregator/blob/master/01_Demo_data-and-config.ipynb"
    click NB2 "https://github.com/demandregioteam/disaggregator/blob/master/02_Demo_households_spatial_disaggregations.ipynb"
    click NB3 "https://github.com/demandregioteam/disaggregator/blob/master/03_Demo_households_temporal_disaggregations.ipynb"
    click NB4 "https://github.com/demandregioteam/disaggregator/blob/master/04_Demo_CTS_Industry_disaggregation.ipynb"
    click NB5 "https://github.com/demandregioteam/disaggregator/blob/master/90_Accessing_geographical_data.ipynb"

    %% Click Event for Environment Management
    click ENV "https://github.com/demandregioteam/disaggregator/blob/master/environment.yml"

    %% Click Event for Concept Overview Diagram
    click IMG "https://github.com/demandregioteam/disaggregator/blob/master/img/overview.pptx"

    %% Styles
    classDef data fill:#C3FDB8,stroke:#333,stroke-width:2px;
    classDef toolkit fill:#B8D9F9,stroke:#333,stroke-width:2px;
    classDef notebook fill:#F9E0B8,stroke:#333,stroke-width:2px;
    classDef env fill:#E0B8F9,stroke:#333,stroke-width:2px;
    classDef diagram fill:#F9B8E0,stroke:#333,stroke-width:2px;
```
