# carbonplan/oae-web architecture

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

- Interactive diagram: https://gitdiagram.com/carbonplan/oae-web
- Repository: https://github.com/carbonplan/oae-web

## Overview

Main Components to Include:

##### Frontend Architecture (Primary Focus)
- Next.js Application Layer
- Pages (Route Handlers)
- Components Layer
- Store (State Management)
- Utils (Helpers)

##### Data Processing Pipeline
- Region Data Processing Scripts
- Tile Generation System

##### Core Application Structure

a) Client Layer (Top)
- Main entry points (/pages directory)
- To the component composition layer

b) Component Layer (Middle)
- Components into logical sections:
- Visualization Components (map.js, chart-section.js, timeseries.js)
- UI Controls (region-picker.js, footer components)
- Data Display (region-info.js, display-section.js)

c) Data & Utils Layer (Bottom)
- Store management (store/index.js)
- Utility functions (utils/)
- Data processing utilities (zarr.js, csv.js)

##### Data Flow Patterns
- Data flow from store to components
- User interaction flows
- Data processing pipelines

##### External Systems
Connections to:
- Static tile server (process-region-data/tiles)
- Data sources (geojson files, NetCDF data)

- Blue: Core Next.js components
- Green: Data visualization components
- Orange: Data processing utilities
- Purple: External data sources
- Gray: Utility functions

Specific Implementation Details:

##### Inside this container, create sections for
- Pages (/_app.js, /research/oae-efficiency)
- Components (showing hierarchy and relationships)
- Store (state management)
- Utils (supporting functions)

- Python scripts (build-tiles.py, convert.py)
- To the tile output directory
- Data transformation flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Application"
        subgraph "Pages Layer"
            OAE["OAE Efficiency Page"]
            click OAE "https://github.com/carbonplan/oae-web/blob/main/pages/research/oae-efficiency/index.js"
        end

        subgraph "Component Layer"
            subgraph "Visualization Components"
                Map["Map Component"]
                click Map "https://github.com/carbonplan/oae-web/blob/main/components/map.js"
                TimeSeries["Time Series"]
                click TimeSeries "https://github.com/carbonplan/oae-web/blob/main/components/timeseries.js"
                ChartSection["Chart Section"]
                click ChartSection "https://github.com/carbonplan/oae-web/blob/main/components/chart-section.js"
            end

            subgraph "Data Display"
                RegionInfo["Region Information"]
                click RegionInfo "https://github.com/carbonplan/oae-web/blob/main/components/region-info.js"
                DisplaySection["Display Section"]
                click DisplaySection "https://github.com/carbonplan/oae-web/blob/main/components/display-section.js"
            end

            subgraph "UI Controls"
                RegionPicker["Region Picker"]
                click RegionPicker "https://github.com/carbonplan/oae-web/blob/main/components/region-picker.js"
                Footer["Footer Controls"]
                click Footer "https://github.com/carbonplan/oae-web/blob/main/components/footer/index.js"
                TimeSlider["Time Slider"]
                click TimeSlider "https://github.com/carbonplan/oae-web/blob/main/components/footer/time-slider.js"
                MonthSelect["Injection Month"]
                click MonthSelect "https://github.com/carbonplan/oae-web/blob/main/components/footer/injection-month.js"
            end

            subgraph "Layout Components"
                MainLayout["Main Layout"]
                click MainLayout "https://github.com/carbonplan/oae-web/blob/main/components/main.js"
                Header["Header"]
                click Header "https://github.com/carbonplan/oae-web/blob/main/components/header.js"
                FooterWrapper["Footer Wrapper"]
                click FooterWrapper "https://github.com/carbonplan/oae-web/blob/main/components/footer/footer-wrapper.js"
            end
        end

        subgraph "Data & Utils Layer"
            Store["State Management"]
            click Store "https://github.com/carbonplan/oae-web/blob/main/store/index.js"
            URLSync["URL Sync Utility"]
            click URLSync "https://github.com/carbonplan/oae-web/blob/main/utils/useRegionUrlSync.js"
            ZarrUtil["Zarr Utilities"]
            click ZarrUtil "https://github.com/carbonplan/oae-web/blob/main/utils/zarr.js"
            CSVUtil["CSV Processing"]
            click CSVUtil "https://github.com/carbonplan/oae-web/blob/main/utils/csv.js"
            ColorUtil["Color Management"]
            click ColorUtil "https://github.com/carbonplan/oae-web/blob/main/utils/color.js"
        end
    end

    subgraph "Data Processing Pipeline"
        TileGen["Tile Generator"]
        click TileGen "https://github.com/carbonplan/oae-web/blob/main/process-region-data/build-tiles.py"
        DataConvert["Data Converter"]
        click DataConvert "https://github.com/carbonplan/oae-web/blob/main/process-region-data/convert.py"
        RegionData["Region GeoJSON"]
        click RegionData "https://github.com/carbonplan/oae-web/blob/main/process-region-data/regions.geojson"
        TileStorage["Tile Storage"]
        click TileStorage "https://github.com/carbonplan/oae-web/tree/main/process-region-data/tiles"
    end

    %% Relationships
    OAE --> MainLayout
    MainLayout --> Header
    MainLayout --> Map
    MainLayout --> DisplaySection
    MainLayout --> FooterWrapper
    FooterWrapper --> Footer
    Footer --> TimeSlider
    Footer --> MonthSelect
    DisplaySection --> RegionInfo
    DisplaySection --> ChartSection
    ChartSection --> TimeSeries
    Store --> Map
    Store --> TimeSeries
    Store --> RegionInfo
    URLSync --> Store
    TileGen --> TileStorage
    DataConvert --> TileGen
    RegionData --> TileGen
    TileStorage --> Map
    RegionPicker --> Store

    %% Styling
    classDef page fill:#2196F3,stroke:#1565C0,color:white
    classDef viz fill:#4CAF50,stroke:#388E3C,color:white
    classDef ui fill:#FF9800,stroke:#F57C00,color:white
    classDef data fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef util fill:#757575,stroke:#616161,color:white
    classDef layout fill:#00BCD4,stroke:#0097A7,color:white
    classDef pipeline fill:#FF5722,stroke:#E64A19,color:white

    class OAE page
    class Map,TimeSeries,ChartSection viz
    class RegionPicker,Footer,TimeSlider,MonthSelect ui
    class Store,RegionData,TileStorage data
    class ZarrUtil,CSVUtil,ColorUtil,URLSync util
    class MainLayout,Header,FooterWrapper layout
    class TileGen,DataConvert pipeline
```
