# os-climate/witness-core architecture

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

- Interactive diagram: https://gitdiagram.com/os-climate/witness-core
- Repository: https://github.com/os-climate/witness-core

## Overview

##### Main Components Architecture

The system should be organized into these major components:

a) Core Models Layer:
- Climate Models (temperature change, carbon cycle, GHG emissions)
- Economic Models (macroeconomics, damage assessment, utility)
- Resource Models (coal, gas, oil, uranium)
- Agricultural Models (land use, crop production)
- Population Models

b) Wrapping Layer:
- Model-specific wrappers that handle data transformation and business logic
- Discipline implementations that connect models to the framework
- Process management components

c) Process Layer:
- Witness processes (main integration processes)
- Optimization processes
- Scenario management

##### Key Relationships to Highlight

- Data flow between climate and economic models
- Resource consumption impacts on emissions
- Feedback loops between damage models and economic outputs
- Integration points between sectors (agriculture, energy, industry)

##### Technical Implementation Details

Technical elements like:
- Python package structure
- Test framework integration
- Documentation system
- Data management components

##### Implementation Layers

Distinct layers:
**┌─────────────────────────────────────────┐**
- Process Layer                │
- (Witness, Optimization, Scenarios)     │
- ┤
- Wrapping Layer               │
- (Discipline Implementation, Services)  │
- ┤
- Core Layer                  │
- (Climate, Economic, Resource Models)   │
- ┤
- Data Layer                  │
- (Input/Output, Calibration Data)      │
- ┘

##### Key Integration Points

Highlight:
- Model coupling mechanisms
- Optimization framework integration
- Data validation and transformation points
- Process orchestration components

##### Cross-cutting Concerns

Include:
- Testing framework integration
- Documentation system
- Configuration management
- Performance monitoring points

This architecture reflects the project's focus on climate-economy modeling while maintaining a modular, testable, and maintainable structure.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef climate fill:#90EE90,stroke:#333,stroke-width:2px
    classDef economic fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef resource fill:#FFA500,stroke:#333,stroke-width:2px
    classDef agriculture fill:#98FB98,stroke:#333,stroke-width:2px
    classDef population fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef wrapper fill:#F0E68C,stroke:#333,stroke-width:2px
    classDef process fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef data fill:#D3D3D3,stroke:#333,stroke-width:2px

    subgraph ProcessLayer["Process Layer"]
        WP[Witness Processes]:::process
        OP[Optimization Processes]:::process
        SM[Scenario Management]:::process
    end

    subgraph WrappingLayer["Wrapping Layer"]
        MW[Model Wrappers]:::wrapper
        DI[Discipline Implementations]:::wrapper
        PM[Process Management]:::wrapper
    end

    subgraph CoreLayer["Core Layer"]
        subgraph Climate["Climate Models"]
            TM[Temperature Model]:::climate
            CC[Carbon Cycle]:::climate
            GE[GHG Emissions]:::climate
        end

        subgraph Economic["Economic Models"]
            ME[Macroeconomics]:::economic
            DM[Damage Model]:::economic
            UM[Utility Model]:::economic
        end

        subgraph Resources["Resource Models"]
            CM[Coal Model]:::resource
            GM[Gas Model]:::resource
            OM[Oil Model]:::resource
            UM2[Uranium Model]:::resource
        end

        subgraph Agriculture["Agricultural Models"]
            AG[Agriculture]:::agriculture
            CR[Crop]:::agriculture
            LU[Land Use]:::agriculture
        end

        POP[Population Model]:::population
    end

    subgraph DataLayer["Data Layer"]
        ID[Input/Output Data]:::data
        CD[Calibration Data]:::data
    end

    %% Relationships
    ProcessLayer --> WrappingLayer
    WrappingLayer --> CoreLayer
    CoreLayer --> DataLayer

    Climate --> Economic
    Resources --> GE
    Economic --> DM
    Agriculture --> Economic
    POP --> Economic

    %% Click events
    click TM "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_witness/tempchange_model.py"
    click CC "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_witness/carbon_cycle_model.py"
    click GE "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_emissions/ghg_emissions_model.py"
    click ME "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_witness/macroeconomics_model_v1.py"
    click DM "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_witness/damage_model.py"
    click UM "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_witness/utility_model.py"
    click CM "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_resources/models/coal_resource/coal_resource_model.py"
    click GM "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_resources/models/gas_resource/gas_resource_model.py"
    click OM "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_resources/models/oil_resource/oil_resource_model.py"
    click UM2 "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_resources/models/uranium_resource/uranium_resource_model.py"
    click AG "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_agriculture/agriculture.py"
    click CR "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_agriculture/crop.py"
    click LU "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_land_use/land_use_v2.py"
    click POP "https://github.com/os-climate/witness-core/blob/main/climateeconomics/core/core_witness/population_model.py"
    click MW "https://github.com/os-climate/witness-core/tree/main/climateeconomics/sos_wrapping"
    click DI "https://github.com/os-climate/witness-core/tree/main/climateeconomics/sos_wrapping/sos_wrapping_witness"
    click WP "https://github.com/os-climate/witness-core/tree/main/climateeconomics/sos_processes/iam/witness"
    click OP "https://github.com/os-climate/witness-core/tree/main/climateeconomics/sos_processes/iam/witness/witness_optim_process"
    click ID "https://github.com/os-climate/witness-core/tree/main/climateeconomics/data"
    click CD "https://github.com/os-climate/witness-core/tree/main/climateeconomics/calibration"

    %% Legend
    subgraph Legend
        L1[Climate Components]:::climate
        L2[Economic Components]:::economic
        L3[Resource Components]:::resource
        L4[Agricultural Components]:::agriculture
        L5[Population Components]:::population
        L6[Wrapper Components]:::wrapper
        L7[Process Components]:::process
        L8[Data Components]:::data
    end
```
