# swagduck/ml_natural architecture

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

- Interactive diagram: https://gitdiagram.com/swagduck/ml_natural
- Repository: https://github.com/swagduck/ml_natural

## Overview

Disaster Globe combines live global hazard events with multi-model weather forecasts in an interactive 3D globe. Its main flow collects hazard feeds into persistent storage, prepares forecast products and verification data, exposes them through an API, and renders them in the web client. The client also supports Model Lab and privacy-first Near Me workflows. The README documents the overall product flow; sampled source and index references support selected implementation links, while unsampled internals are not asserted in detail.

Main entry points: [`web/src/main.ts`](https://github.com/swagduck/ml_natural/blob/main/web/src/main.ts) (Globe client), [`pipeline/run.py`](https://github.com/swagduck/ml_natural/blob/main/pipeline/run.py) (Weather pipeline), [`server/src/app.ts`](https://github.com/swagduck/ml_natural/blob/main/server/src/app.ts) (Fastify API), [`server/src/adapters`](https://github.com/swagduck/ml_natural/tree/main/server/src/adapters) (Feed adapters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hazards["Hazard ingestion"]
  node_hazardadapters["Feed adapters"]
  node_eventingest["Event ingest<br/>[ingestService.ts]"]
  node_ingestscheduler["Ingest scheduler<br/>[scheduler.ts]"]
end

subgraph group_weather["Forecast and verification"]
  node_weatherpipeline["Weather pipeline<br/>[run.py]"]
  node_modelrunners["Forecast models"]
  node_gfsml["GFS-ML correction<br/>[gfs_ml.py]"]
  node_regrid["Grid regridding<br/>[regrid.py]"]
  node_weatherstorage[("Weather storage<br/>[storage.py]")]
  node_mltraining["ML training and evaluation"]
  node_verification["Forecast verification<br/>[verify.py]"]
  node_cyclonetracking["Cyclone tracking<br/>[cyclone_tracker.py]"]
end

subgraph group_service["API and persistence"]
  node_database[("MongoDB")]
  node_api["Fastify API<br/>[app.ts]"]
  node_weatherroute["Weather routes<br/>[weather.ts]"]
  node_verificationroute["Verification routes<br/>[verification.ts]"]
end

subgraph group_client["Globe application"]
  node_webmain["Globe client<br/>[main.ts]"]
  node_hazardlayers["Hazard rendering"]
  node_weathertextures["Weather textures"]
  node_modellab["Model Lab<br/>[modelLabPanel.ts]"]
  node_nearby["Near Me ranking<br/>[relevanceEngine.ts]"]
  node_geoutils["Geospatial utilities<br/>[geo.ts]"]
  node_layout["Responsive layout<br/>[layoutManager.ts]"]
end

node_visitor(("Globe user"))
node_usgs["USGS feed"]
node_gdacs["GDACS feed"]
node_eonet["NASA EONET"]
node_forecastfeeds["Forecast feeds"]
node_era5["Copernicus ERA5"]
node_ibtracs["NOAA IBTrACS"]

node_usgs -->|"provides events"| node_hazardadapters
node_gdacs -->|"provides alerts"| node_hazardadapters
node_eonet -->|"provides events"| node_hazardadapters
node_hazardadapters -->|"supplies feeds"| node_ingestscheduler
node_ingestscheduler -->|"schedules ingest"| node_eventingest
node_eventingest -->|"upserts events"| node_database
node_forecastfeeds -->|"supplies forecasts"| node_weatherpipeline
node_weatherpipeline -->|"runs models"| node_modelrunners
node_modelrunners -->|"regrids fields"| node_regrid
node_modelrunners -->|"selects model"| node_gfsml
node_gfsml -->|"uses grid tools"| node_regrid
node_gfsml -->|"loads inference"| node_mltraining
node_weatherpipeline -->|"writes products"| node_weatherstorage
node_weatherstorage -->|"stores manifests"| node_database
node_era5 -->|"provides truth"| node_verification
node_ibtracs -->|"provides tracks"| node_cyclonetracking
node_weatherpipeline -->|"scores forecasts"| node_verification
node_cyclonetracking -->|"supports scoring"| node_verification
node_verification -->|"stores scores"| node_database
node_weatherpipeline -.->|"scheduled by"| node_ingestscheduler
node_api -->|"registers routes"| node_weatherroute
node_api -->|"registers routes"| node_verificationroute
node_weatherroute -->|"reads runs"| node_database
node_verificationroute -->|"reads scores"| node_database
node_database -->|"serves records"| node_api
node_visitor -->|"uses globe"| node_webmain
node_webmain -->|"requests data"| node_api
node_webmain -->|"renders hazards"| node_hazardlayers
node_webmain -->|"loads weather"| node_weathertextures
node_weathertextures -->|"fetches manifests"| node_api
node_webmain -->|"opens lab"| node_modellab
node_webmain -->|"ranks hazards"| node_nearby
node_nearby -->|"uses distance tools"| node_geoutils
node_webmain -.->|"wires interface"| node_layout

click node_hazardadapters "https://github.com/swagduck/ml_natural/tree/main/server/src/adapters"
click node_eventingest "https://github.com/swagduck/ml_natural/blob/main/server/src/ingest/ingestService.ts"
click node_ingestscheduler "https://github.com/swagduck/ml_natural/blob/main/server/src/ingest/scheduler.ts"
click node_weatherpipeline "https://github.com/swagduck/ml_natural/blob/main/pipeline/run.py"
click node_modelrunners "https://github.com/swagduck/ml_natural/tree/main/pipeline/models"
click node_gfsml "https://github.com/swagduck/ml_natural/blob/main/pipeline/models/gfs_ml.py"
click node_regrid "https://github.com/swagduck/ml_natural/blob/main/pipeline/regrid.py"
click node_weatherstorage "https://github.com/swagduck/ml_natural/blob/main/pipeline/storage.py"
click node_mltraining "https://github.com/swagduck/ml_natural/tree/main/ml"
click node_verification "https://github.com/swagduck/ml_natural/blob/main/pipeline/verify.py"
click node_cyclonetracking "https://github.com/swagduck/ml_natural/blob/main/pipeline/cyclone_tracker.py"
click node_api "https://github.com/swagduck/ml_natural/blob/main/server/src/app.ts"
click node_weatherroute "https://github.com/swagduck/ml_natural/blob/main/server/src/routes/weather.ts"
click node_verificationroute "https://github.com/swagduck/ml_natural/blob/main/server/src/routes/verification.ts"
click node_webmain "https://github.com/swagduck/ml_natural/blob/main/web/src/main.ts"
click node_hazardlayers "https://github.com/swagduck/ml_natural/blob/main/web/src/layers/hazardLayerManager.ts"
click node_weathertextures "https://github.com/swagduck/ml_natural/blob/main/web/src/weather/weatherTextureManager.ts"
click node_modellab "https://github.com/swagduck/ml_natural/blob/main/web/src/lab/modelLabPanel.ts"
click node_nearby "https://github.com/swagduck/ml_natural/blob/main/web/src/near/relevanceEngine.ts"
click node_geoutils "https://github.com/swagduck/ml_natural/blob/main/web/src/near/geo.ts"
click node_layout "https://github.com/swagduck/ml_natural/blob/main/web/src/ui/layoutManager.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_hazardadapters,node_eventingest,node_ingestscheduler,node_visitor toneBlue
class node_weatherpipeline,node_modelrunners,node_gfsml,node_regrid,node_weatherstorage,node_mltraining,node_verification,node_cyclonetracking toneAmber
class node_database,node_api,node_weatherroute,node_verificationroute toneMint
class node_webmain,node_hazardlayers,node_weathertextures,node_modellab,node_nearby,node_geoutils,node_layout toneRose
class node_usgs,node_gdacs,node_eonet,node_forecastfeeds,node_era5,node_ibtracs toneIndigo
```

## Components

### Hazard ingestion

- [Feed adapters](https://github.com/swagduck/ml_natural/tree/main/server/src/adapters): `server/src/adapters`
- [Event ingest](https://github.com/swagduck/ml_natural/blob/main/server/src/ingest/ingestService.ts): `server/src/ingest/ingestService.ts`
- [Ingest scheduler](https://github.com/swagduck/ml_natural/blob/main/server/src/ingest/scheduler.ts): `server/src/ingest/scheduler.ts`

### Forecast and verification

- [Weather pipeline](https://github.com/swagduck/ml_natural/blob/main/pipeline/run.py): `pipeline/run.py`
- [Forecast models](https://github.com/swagduck/ml_natural/tree/main/pipeline/models): `pipeline/models`
- [GFS-ML correction](https://github.com/swagduck/ml_natural/blob/main/pipeline/models/gfs_ml.py): `pipeline/models/gfs_ml.py`
- [Grid regridding](https://github.com/swagduck/ml_natural/blob/main/pipeline/regrid.py): `pipeline/regrid.py`
- [Weather storage](https://github.com/swagduck/ml_natural/blob/main/pipeline/storage.py): `pipeline/storage.py`
- [ML training and evaluation](https://github.com/swagduck/ml_natural/tree/main/ml): `ml`
- [Forecast verification](https://github.com/swagduck/ml_natural/blob/main/pipeline/verify.py): `pipeline/verify.py`
- [Cyclone tracking](https://github.com/swagduck/ml_natural/blob/main/pipeline/cyclone_tracker.py): `pipeline/cyclone_tracker.py`

### API and persistence

- **MongoDB**
- [Fastify API](https://github.com/swagduck/ml_natural/blob/main/server/src/app.ts): `server/src/app.ts`
- [Weather routes](https://github.com/swagduck/ml_natural/blob/main/server/src/routes/weather.ts): `server/src/routes/weather.ts`
- [Verification routes](https://github.com/swagduck/ml_natural/blob/main/server/src/routes/verification.ts): `server/src/routes/verification.ts`

### Globe application

- [Globe client](https://github.com/swagduck/ml_natural/blob/main/web/src/main.ts): `web/src/main.ts`
- [Hazard rendering](https://github.com/swagduck/ml_natural/blob/main/web/src/layers/hazardLayerManager.ts): `web/src/layers/hazardLayerManager.ts`
- [Weather textures](https://github.com/swagduck/ml_natural/blob/main/web/src/weather/weatherTextureManager.ts): `web/src/weather/weatherTextureManager.ts`
- [Model Lab](https://github.com/swagduck/ml_natural/blob/main/web/src/lab/modelLabPanel.ts): `web/src/lab/modelLabPanel.ts`
- [Near Me ranking](https://github.com/swagduck/ml_natural/blob/main/web/src/near/relevanceEngine.ts): `web/src/near/relevanceEngine.ts`
- [Geospatial utilities](https://github.com/swagduck/ml_natural/blob/main/web/src/near/geo.ts): `web/src/near/geo.ts`
- [Responsive layout](https://github.com/swagduck/ml_natural/blob/main/web/src/ui/layoutManager.ts): `web/src/ui/layoutManager.ts`

### Other components

- **Globe user**
- **USGS feed**
- **GDACS feed**
- **NASA EONET**
- **Forecast feeds**
- **Copernicus ERA5**
- **NOAA IBTrACS**

## Connections

- USGS feed → Feed adapters: provides events
- GDACS feed → Feed adapters: provides alerts
- NASA EONET → Feed adapters: provides events
- Feed adapters → Ingest scheduler: supplies feeds (evidence: `server/src/index.ts`)
- Ingest scheduler → Event ingest: schedules ingest
- Event ingest → MongoDB: upserts events
- Forecast feeds → Weather pipeline: supplies forecasts
- Weather pipeline → Forecast models: runs models (evidence: `pipeline/run.py`)
- Forecast models → Grid regridding: regrids fields (evidence: `pipeline/models/ecmwf_base.py`)
- Forecast models → GFS-ML correction: selects model (evidence: `pipeline/run.py`)
- GFS-ML correction → Grid regridding: uses grid tools (evidence: `pipeline/models/gfs_ml.py`)
- GFS-ML correction → ML training and evaluation: loads inference (evidence: `pipeline/models/gfs_ml.py`)
- Weather pipeline → Weather storage: writes products (evidence: `pipeline/run.py`)
- Weather storage → MongoDB: stores manifests (evidence: `pipeline/storage.py`)
- Copernicus ERA5 → Forecast verification: provides truth
- NOAA IBTrACS → Cyclone tracking: provides tracks
- Weather pipeline → Forecast verification: scores forecasts (evidence: `pipeline/run.py`)
- Cyclone tracking → Forecast verification: supports scoring
- Forecast verification → MongoDB: stores scores
- Weather pipeline → Ingest scheduler: scheduled by
- Fastify API → Weather routes: registers routes (evidence: `server/src/app.ts`)
- Fastify API → Verification routes: registers routes (evidence: `server/src/app.ts`)
- Weather routes → MongoDB: reads runs (evidence: `server/src/routes/weather.ts`)
- Verification routes → MongoDB: reads scores
- MongoDB → Fastify API: serves records
- Globe user → Globe client: uses globe
- Globe client → Fastify API: requests data (evidence: `web/src/main.ts`)
- Globe client → Hazard rendering: renders hazards (evidence: `web/src/main.ts`)
- Globe client → Weather textures: loads weather (evidence: `web/src/main.ts`)
- Weather textures → Fastify API: fetches manifests (evidence: `web/src/weather/weatherTextureManager.ts`)
- Globe client → Model Lab: opens lab (evidence: `web/src/main.ts`)
- Globe client → Near Me ranking: ranks hazards (evidence: `web/src/main.ts`)
- Near Me ranking → Geospatial utilities: uses distance tools (evidence: `web/src/near/relevanceEngine.ts`)
- Globe client → Responsive layout: wires interface (evidence: `web/src/main.ts`)
