# ktwu01/alphaearthhack architecture

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

- Interactive diagram: https://gitdiagram.com/ktwu01/alphaearthhack
- Repository: https://github.com/ktwu01/alphaearthhack

## Overview

##### What this project is (type + purpose)
This repo is a **geospatial analytics + visualization hackathon project**. Architecturally, it’s not a traditional “backend service + database + frontend app” repo; it’s closer to a **research/analysis workflow** with:
- **Interactive analysis notebooks** (Jupyter) that run Python-based remote sensing workflows.
- A **static interactive dashboard** (hosted on GitHub Pages) that visualizes outputs using **Leaflet.js + Plotly.js**.
- Heavy reliance on **external geospatial compute/data platforms**: **Google Earth Engine (GEE)**, plus datasets/approaches named **AlphaEarth** and **LandTrendr**.

So the “system” is best diagrammed as a **pipeline + visualization system**: user → notebooks (compute + export) → artifacts (rasters/metrics/screenshots) → web dashboard for exploration.

##### README signals (stack + interactions)
The README explicitly lists:
- Python/libs: NumPy, tqdm, ipyleaflet, “Google Earth Engine map”.
- Web libs: Leaflet.js, Plotly.js.
- Platforms/models: Google Earth Engine, AlphaEarth (embeddings / mapping), LandTrendr (change detection).
And it links to a GitHub Pages “interactive dashboard”.

This implies two primary “execution environments”:
1) **Local Jupyter runtime** (Python 3.12.11) used by researchers to run analyses and generate outputs.

##### Main components
**Actors**
- “Researcher / Analyst” (runs notebooks)
- “Dashboard User” (views web dashboard)

**Compute & Apps**
- “Jupyter Notebooks (Python 3.12)”
Files to cite in a label or footnote: `AlphaEarth_Story.ipynb`, `AlphaEarth_Interactive_Mapping.ipynb`, `LandTrendr_AlphaEarth.ipynb`, etc.
- “Static Web Dashboard (GitHub Pages)”
Tech: HTML/CSS/JS + Leaflet.js + Plotly.js

**External Services / Dependencies**
- “Google Earth Engine (GEE)” (data catalog + compute)
- “LandTrendr (on GEE)” (algorithm executed within GEE)

- “Exported outputs” (rasters/tiles/geojson/csv/images)
In this repo, you visibly have `images/` and `backup/*.csv`. Even if other exports aren’t committed, the pipeline likely generates them.

- Researcher → Jupyter Notebooks (runs analysis)
- Notebooks → Google Earth Engine (API calls for data + compute)
- GEE → Notebooks (returns imagery, embeddings, change metrics)
- Notebooks → Outputs/Artifacts (exports images/CSVs/geo layers)
- Dashboard User → Static Web Dashboard (browser)
- Web Dashboard → Outputs/Artifacts (loads precomputed layers/data)

##### Stage A — Data Access & Preprocessing (GEE + Notebook)
- Inputs:
- Satellite imagery/time series (via GEE catalog)
- Region of interest (Austin example is present; also global views)
- Operations:
- Masking, compositing, time slicing, sampling
- Embedding retrieval/derivation (AlphaEarth)
- Notebook references to attach: the mapping and tutorial notebooks.

##### Stage B — Change Detection Computation
Run **two parallel branches** (this is important, because the repo emphasizes comparison):
##### AlphaEarth-derived change metrics
- Example metrics shown in images: magnitude, duration, “year of change (yoc)”, cosine similarity
##### LandTrendr change metrics
- Magnitude, duration, year of change

##### Stage C — Comparison / Fusion / Evaluation
- “AlphaEarth vs LandTrendr comparison”
(explicitly supported by `AlphaEarth_LandTrendr_ChangeComparison.ipynb`)
- Optional outputs:
- correlation/stat summaries (matches `backup/lt_training_*.csv`)
- qualitative comparison maps (screenshots in `images/`)

##### Stage D — Export & Packaging
- Export geospatial layers (raster/tiles) and derived tables
- Generate assets consumed by:
- Notebook interactive widgets (ipyleaflet)
- Web dashboard (Leaflet + Plotly)
- Persist:
- `images/` (committed)
- `backup/*.csv` (committed)

##### Notebook visualization
- ipyleaflet maps
- interactive exploration inside Jupyter
##### Web dashboard visualization
- Leaflet map layers
- Plotly charts (dissimilarity plots, time-series, etc.)

- “Imagery/time series” → preprocessing → (AlphaEarth metrics, LandTrendr metrics) → comparison → exports → dashboard/notebook
- That **LandTrendr runs on GEE** (compute happens “in GEE”), while notebooks orchestrate.

- Jupyter: “Python 3.12 + NumPy + tqdm + ipyleaflet”
- External compute: “Google Earth Engine (data + compute)”
- Algorithms: “LandTrendr (GEE implementation)”, “AlphaEarth embeddings/field model”
- Web: “Leaflet.js + Plotly.js (static dashboard on GitHub Pages)”

##### Does the GitHub Pages dashboard load data from
- committed files in the repo,
- GEE tile endpoints,
- or another hosted bucket?
2) In notebooks: are exports written locally only, to Drive/GEE Assets, or to web-consumable tiles?
3) Is there any hidden backend not shown in file tree (e.g., separate repo or branch)? If yes, add it explicitly.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% =========================
  %% Diagram 1: Context / Container (C4-ish)
  %% =========================
  subgraph C1["Context / Container View"]
    direction TB

    A1["Researcher / Analyst"]:::actor
    A2["Dashboard User"]:::actor

    subgraph C1N["Jupyter Notebook Environment (Local)"]
      direction TB
      N0["Notebook Orchestrator (Python 3.12)"]:::compute
      N1["Story / Narrative Notebook"]:::notebook
      N2["Interactive Mapping Notebook"]:::notebook
      N3["LandTrendr + AlphaEarth Workflow Notebook"]:::notebook
      N4["Change Comparison Notebook"]:::notebook
      N5["Austin Change Notebook"]:::notebook
      N6["Tutorial / Onboarding Notebook"]:::notebook
      N7["Archived / Experimental Notebooks + Scripts"]:::notebook
    end

    subgraph C1E["External Geospatial Compute & Data Platforms"]
      direction TB
      E1["Google Earth Engine (GEE)\n(Data Catalog + Compute)"]:::external
      E2["LandTrendr (runs in GEE)"]:::external
      E3["AlphaEarth (embeddings / derived products)\n(external source via GEE / data provider)"]:::external
      E4["Satellite Imagery / Time Series\n(via GEE Catalog)"]:::external
    end

    subgraph C1S["Artifacts / Outputs (Repo + Exports)"]
      direction TB
      S0[("Artifact Store\n(Exported outputs)")]:::storage
      S1[("Visual Artifacts\n(images/)")]:::storage
      S2[("Tabular Artifacts\n(CSV summaries)")]:::storage
      S3[("Exported Geospatial Layers\n(GeoTIFF / GeoJSON / tiles)\n(not all committed)")]:::storage
    end

    subgraph C1W["Static Web Dashboard (GitHub Pages)"]
      direction TB
      W0["Dashboard UI (Static HTML/CSS/JS)"]:::ui
      W1["Leaflet.js Map"]:::ui
      W2["Plotly.js Charts"]:::ui
      W3["Hosted Static Assets\n(GitHub Pages)\n(assumption: loads precomputed artifacts)"]:::ui
    end

    NOTE1["Notes:\n- Compute is largely externalized to GEE\n- No custom backend in repo; preprocessing via notebooks\n- Precompute-heavy workflow for fast interactive viewing"]:::note

    %% Relationships
    A1 -->|"runs"| N0
    N0 -->|"implemented_by"| N1
    N0 -->|"implemented_by"| N2
    N0 -->|"implemented_by"| N3
    N0 -->|"implemented_by"| N4
    N0 -->|"implemented_by"| N5
    N0 -->|"implemented_by"| N6
    N0 -->|"includes"| N7

    N0 -.->|"GEE_API_calls"| E1
    E1 -->|"imagery_Collections"| E4
    E1 -->|"executes"| E2
    E1 -->|"provides_embeddings"| E3
    E1 -->|"returns_imagery_embeddings_metrics"| N0

    N0 -->|"exports_PNG_CSV_GeoTIFF_GeoJSON_tiles"| S0
    S0 -->|"committed_subset"| S1
    S0 -->|"committed_subset"| S2
    S0 -->|"optional_exports"| S3

    A2 -->|"views"| W0
    W0 -->|"renders"| W1
    W0 -->|"renders"| W2
    W0 -->|"served_as"| W3
    W0 -->|"loads_precomputed_assets"| S0

    NOTE1 -.-> N0
    NOTE1 -.-> E1
    NOTE1 -.-> W0
  end

  %% =========================
  %% Diagram 2: Workflow / Dataflow (Pipeline)
  %% =========================
  subgraph D1["Workflow / Dataflow View (Notebook-Orchestrated Pipeline)"]
    direction TB

    U0["Researcher / Analyst"]:::actor

    subgraph D1A["Stage A — Data Access & Preprocessing (Notebook + GEE)"]
      direction TB
      A10["ROI Definition\n(e.g., Austin + other regions)"]:::process
      A11["Preprocessing\n(masking / compositing / time_slicing / sampling)"]:::process
      A12["AlphaEarth Embedding Retrieval/Derivation\n(via GEE / provider)"]:::process
      A13["GEE ImageCollection Inputs\n(satellite time series)"]:::external
      A14["GEE Compute (orchestrated)"]:::external
    end

    subgraph D1B["Stage B — Change Detection Computation (Parallel Branches)"]
      direction TB

      subgraph D1B1["Branch 1 — AlphaEarth-Derived Change Metrics"]
        direction TB
        B11["Compute AlphaEarth Change Metrics\n(cosine_similarity / dissimilarity)\n(magnitude / duration / yoc)"]:::process
      end

      subgraph D1B2["Branch 2 — LandTrendr Change Metrics (in GEE)"]
        direction TB
        B21["Run LandTrendr on GEE"]:::external
        B22["Compute LandTrendr Metrics\n(magnitude / duration / yoc)"]:::process
      end
    end

    subgraph D1C["Stage C — Comparison / Fusion / Evaluation"]
      direction TB
      C10["AlphaEarth vs LandTrendr Comparison\n(correlations / stats / qualitative maps)"]:::process
      C11["Training/Correlation Summaries\n(CSV outputs)"]:::process
    end

    subgraph D1D["Stage D — Export & Packaging"]
      direction TB
      D10[("Artifact Store")]:::storage
      D11[("Visual Exports\n(images/ screenshots/figures)")]:::storage
      D12[("Tabular Exports\n(CSV summaries)")]:::storage
      D13[("Geospatial Layer Exports\n(GeoTIFF / GeoJSON / tiles)\n(not all committed)")]:::storage
    end

    subgraph D1E["Stage E — Visualization (Two Endpoints)"]
      direction TB

      subgraph D1E1["Endpoint 1 — Notebook Visualization"]
        direction TB
        E11["Jupyter Interactive Maps\n(ipyleaflet / GEE map)"]:::ui
      end

      subgraph D1E2["Endpoint 2 — Web Dashboard Visualization (Static)"]
        direction TB
        E21["GitHub Pages Dashboard"]:::ui
        E22["Leaflet.js Layers"]:::ui
        E23["Plotly.js Charts"]:::ui
      end
    end

    %% Workflow connections
    U0 -->|"runs_notebooks"| A10
    A10 -->|"ROI"| A11
    A13 -->|"imagery_time_series"| A11
    A11 -.->|"compute_requests"| A14
    A12 -.->|"embedding_ops_requests"| A14

    A14 -->|"preprocessed_imagery"| A11
    A14 -->|"embeddings"| A12

    A11 -->|"features_timeseries"| B11
    A12 -->|"embeddings"| B11

    A11 -->|"time_series"| B21
    B21 -->|"LandTrendr_outputs"| B22

    B11 -->|"AlphaEarth_metrics"| C10
    B22 -->|"LandTrendr_metrics"| C10

    C10 -->|"stats_correlations"| C11
    C10 -->|"comparison_maps"| D10
    C11 -->|"CSV_tables"| D10

    D10 -->|"persist"| D11
    D10 -->|"persist"| D12
    D10 -->|"persist"| D13

    D10 -->|"loads_assets"| E11
    D10 -->|"loads_assets"| E21
    E21 -->|"renders"| E22
    E21 -->|"renders"| E23
  end

  %% =========================
  %% Click Events (from component_mapping)
  %% =========================
  click N1 "https://github.com/ktwu01/alphaearthhack/blob/main/AlphaEarth_Story.ipynb"
  click N2 "https://github.com/ktwu01/alphaearthhack/blob/main/AlphaEarth_Interactive_Mapping.ipynb"
  click N4 "https://github.com/ktwu01/alphaearthhack/blob/main/AlphaEarth_LandTrendr_ChangeComparison.ipynb"
  click N3 "https://github.com/ktwu01/alphaearthhack/blob/main/LandTrendr_AlphaEarth.ipynb"
  click N5 "https://github.com/ktwu01/alphaearthhack/blob/main/austin_change.ipynb"
  click N6 "https://github.com/ktwu01/alphaearthhack/blob/main/alpha_tutorial.ipynb"
  click N7 "https://github.com/ktwu01/alphaearthhack/tree/main/backup/"
  click S1 "https://github.com/ktwu01/alphaearthhack/tree/main/images/"
  click S2 "https://github.com/ktwu01/alphaearthhack/blob/main/backup/lt_training_asset_summary.csv"
  click W0 "https://github.com/ktwu01/alphaearthhack/blob/main/README.md"

  click C11 "https://github.com/ktwu01/alphaearthhack/blob/main/backup/lt_training_corr_all_assets.csv"
  click C10 "https://github.com/ktwu01/alphaearthhack/blob/main/backup/lt_training_stats_all_assets.csv"

  click NOTE1 "https://github.com/ktwu01/alphaearthhack/blob/main/Criteria.md"

  %% Archived specifics
  click N7 "https://github.com/ktwu01/alphaearthhack/tree/main/backup/"
  click B22 "https://github.com/ktwu01/alphaearthhack/blob/main/backup/Austin_LandTrendr.py"
  click D12 "https://github.com/ktwu01/alphaearthhack/blob/main/backup/lt_training_asset_summary.csv"
  click D12 "https://github.com/ktwu01/alphaearthhack/blob/main/backup/lt_training_corr_all_assets.csv"
  click D12 "https://github.com/ktwu01/alphaearthhack/blob/main/backup/lt_training_stats_all_assets.csv"

  %% Additional mapped files (archived notebooks & deck)
  click N7 "https://github.com/ktwu01/alphaearthhack/blob/main/backup/AlphaEarth_EDA.ipynb"
  click N7 "https://github.com/ktwu01/alphaearthhack/blob/main/backup/LandTrendr_EDA.ipynb"
  click N7 "https://github.com/ktwu01/alphaearthhack/blob/main/backup/Austin_LandTrendr_Changes.ipynb"
  click W3 "https://github.com/ktwu01/alphaearthhack/blob/main/presentation.pdf"

  %% =========================
  %% Styles
  %% =========================
  classDef actor fill:#ffffff,stroke:#374151,stroke-width:2px,color:#111827;
  classDef compute fill:#dbeafe,stroke:#1d4ed8,stroke-width:2px,color:#0b1b3a;
  classDef notebook fill:#bfdbfe,stroke:#1e40af,stroke-width:1.5px,color:#0b1b3a;
  classDef external fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#111827;
  classDef storage fill:#ffedd5,stroke:#c2410c,stroke-width:2px,color:#7c2d12;
  classDef ui fill:#dcfce7,stroke:#166534,stroke-width:2px,color:#052e16;
  classDef process fill:#e0e7ff,stroke:#4338ca,stroke-width:2px,color:#1e1b4b;
  classDef note fill:#fef9c3,stroke:#a16207,stroke-width:1.5px,color:#713f12;
```
