# seeg-brazil/seeg_mut architecture

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

- Interactive diagram: https://gitdiagram.com/seeg-brazil/seeg_mut
- Repository: https://github.com/seeg-brazil/seeg_mut

## Overview

##### Project type and purpose
- This is a data‐processing pipeline rather than a traditional web or microservice application. Its goal is to generate high-resolution greenhouse-gas (GHG) emission/removal estimates for Brazil by
- running spatial analyses on Google Earth Engine (GEE)
- exporting geospatial outputs (GeoJSON)
- ingesting those outputs plus auxiliary tabular data into an R‐based estimation module

##### File structure
- Top-level directories:
1._Spatial_analyses – contains GEE JavaScript scripts (.js), Python scripts/notebooks (.py, .ipynb) for land‐cover transitions, mask creation, spatial filtering, area calculations, and export.
2._Estimates – an R project folder with an Estimates.R script under R/script, plus a data subfolder containing all auxiliary CSV/XLS(X)/ODS tables.
aux – houses images (logos, README illustrations).
__Output – holds the exported GeoJSON time‐series layers.
- Key indicators:
- A two‐stage ETL pipeline (Spatial → Export → Statistical Estimates).
- Dependencies on external cloud services (GEE), local runtimes (Python, R), and data files.

##### README for additional insights
- Confirms GEE (JavaScript + Python API) as the spatial‐analysis engine.
- Confirms R 4.x + RStudio for the estimation stage.
- Describes workflow:
Spatial analyses in GEE → export assets → local/Colab Python for some steps → R reads outputs & aux data for final emission/removal calculations.

##### Elements
- GEE Scripts → GEE Assets
- GEE Assets → __Output GeoJSON
- __Output & aux_data → R Script
- R Script → Final Outputs
- Blue for cloud services (GEE)
- Green for local code modules
- Orange for data stores/files

##### Final recommendations
- Essential elements (services, runtimes, data flows) without over-complicating; two layers (cloud vs. local) plus data exchange is enough

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Cloud Layer
    subgraph "Google Earth Engine (Cloud Services)" 
        direction TB
        GEE_API("GEE JS & Python API"):::cloud
        subgraph "GEE JS Scripts" 
            direction TB
            MaskJS["1.0_Deforestation_and_regeneration_masks.js"]:::cloud
            FilterJS["1.1_Spatial_filter.js"]:::cloud
            StabilizeJS["2.0_Stabilized_cover.js"]:::cloud
            TransitionJS["3.0_Transition_maps.js"]:::cloud
            ExportJS["3.1_Export_to_Asset.js"]:::cloud
        end
        subgraph "Python Notebooks/Scripts"
            direction TB
            CalcNB1["4.0_CalcAreaZone.ipynb"]:::cloud
            CalcNB2["4_0_CalcAreaZone_v2024.ipynb"]:::cloud
            CalcPy["4.1_CalcAreaZone.py"]:::cloud
        end
        GEE_Assets("GEE Assets (GeoJSON)"):::data
    end

    %% Local Layer
    subgraph "Developer Workstation (Local)" 
        direction TB
        subgraph "Spatial_analyses Module" 
            direction TB
            SA_Readme["README.md (Spatial_analyses)"]:::local
        end
        subgraph "__Output (GeoJSON Files)" 
            direction TB
            LocalOutput("GeoJSON Time-series"):::data
        end
        subgraph "Estimates Module" 
            direction TB
            Est_Readme["README.md (Estimates)"]:::local
            AuxData("aux_data (CSV/XLS/ODS)"):::data
            EstimatesR["Estimates.R"]:::local
        end
        FinalOutput("Final Tables, Plots, Reports"):::data
    end

    %% Top-level README and Aux Images
    TopReadme["README.md"]:::local
    AuxImages["aux/ (images & illustrations)"]:::local

    %% Data Flows
    MaskJS -->|runs on| GEE_API
    FilterJS -->|runs on| GEE_API
    StabilizeJS -->|runs on| GEE_API
    TransitionJS -->|runs on| GEE_API
    ExportJS -->|exports to| GEE_Assets

    CalcNB1 -->|uses API| GEE_API
    CalcNB2 -->|uses API| GEE_API
    CalcPy -->|uses API| GEE_API
    CalcNB1 -->|writes to| GEE_Assets
    CalcNB2 -->|writes to| GEE_Assets
    CalcPy -->|writes to| GEE_Assets

    GEE_Assets -->|sync to local| LocalOutput
    LocalOutput -->|input to| EstimatesR
    AuxData -->|input to| EstimatesR
    EstimatesR -->|produces| FinalOutput

    TopReadme -.-> SA_Readme
    TopReadme -.-> Est_Readme
    TopReadme -.-> AuxImages

    %% Click Events
    click MaskJS "https://github.com/seeg-brazil/seeg_mut/blob/main/1._Spatial_analyses/1.0_Deforestation_and_regeneration_masks.js"
    click FilterJS "https://github.com/seeg-brazil/seeg_mut/blob/main/1._Spatial_analyses/1.1_Spatial_filter.js"
    click StabilizeJS "https://github.com/seeg-brazil/seeg_mut/blob/main/1._Spatial_analyses/2.0_Stabilized_cover.js"
    click TransitionJS "https://github.com/seeg-brazil/seeg_mut/blob/main/1._Spatial_analyses/3.0_Transition_maps.js"
    click ExportJS "https://github.com/seeg-brazil/seeg_mut/blob/main/1._Spatial_analyses/3.1_Export_to_Asset.js"
    click CalcNB1 "https://github.com/seeg-brazil/seeg_mut/blob/main/1._Spatial_analyses/4.0_CalcAreaZone.ipynb"
    click CalcNB2 "https://github.com/seeg-brazil/seeg_mut/blob/main/1._Spatial_analyses/4_0_CalcAreaZone_v2024.ipynb"
    click CalcPy "https://github.com/seeg-brazil/seeg_mut/blob/main/1._Spatial_analyses/4.1_CalcAreaZone.py"
    click SA_Readme "https://github.com/seeg-brazil/seeg_mut/blob/main/1._Spatial_analyses/README.md"
    click LocalOutput "https://github.com/seeg-brazil/seeg_mut/tree/main/1.__Output/"
    click Est_Readme "https://github.com/seeg-brazil/seeg_mut/blob/main/2._Estimates/README.md"
    click EstimatesR "https://github.com/seeg-brazil/seeg_mut/blob/main/2._Estimates/R/script/Estimates.R"
    click AuxData "https://github.com/seeg-brazil/seeg_mut/tree/main/2._Estimates/data/aux_data/"
    click TopReadme "https://github.com/seeg-brazil/seeg_mut/blob/main/README.md"
    click AuxImages "https://github.com/seeg-brazil/seeg_mut/tree/main/aux/"

    %% Styles
    classDef cloud fill:#BBDEFB,stroke:#1E88E5,stroke-width:1px
    classDef local fill:#C8E6C9,stroke:#388E3C,stroke-width:1px
    classDef data fill:#FFE0B2,stroke:#FB8C00,stroke-width:1px,stroke-dasharray: 5 5
```
