# obsg13/enso-monitor architecture

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

- Interactive diagram: https://gitdiagram.com/obsg13/enso-monitor
- Repository: https://github.com/obsg13/enso-monitor
- Video tour (about a minute): https://gitdiagram.com/obsg13/enso-monitor/video

## Overview

ENSO Monitor imports NOAA ONI v6 observations into PostgreSQL, then serves them through a filtered FastAPI API to a React interface for charting, tabulation, and historical episode comparison. The core paths and calls are evidenced by the excerpts and README; several presentation and extraction details are supported only by the README or SOURCE INDEX, so no unshown internal calls are asserted.

Main entry points: [`frontend/src/App.tsx`](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/App.tsx) (ENSO Monitor UI), [`backend/etl/run.py`](https://github.com/obsg13/enso-monitor/blob/main/backend/etl/run.py) (Import orchestrator), [`backend/app/routes.py`](https://github.com/obsg13/enso-monitor/blob/main/backend/app/routes.py) (API endpoints), [`frontend/src/components/EpisodeComparison.tsx`](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/EpisodeComparison.tsx) (Episode comparison)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["NOAA data import"]
  node_import_run["Import orchestrator<br/>[run.py]"]
  node_extract["Page extraction<br/>[extract.py]"]
  node_transform["Observation transform<br/>[transform.py]"]
  node_load["Idempotent load<br/>[load.py]"]
end

subgraph group_backend["API and analysis"]
  node_database[("PostgreSQL dataset<br/>[models.py]")]
  node_db_session["Database sessions<br/>[db.py]"]
  node_api_routes["API endpoints<br/>[routes.py]"]
  node_analysis["Period statistics<br/>[analysis.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
  node_api_main["API application<br/>[main.py]"]
end

subgraph group_frontend["Web exploration"]
  node_app["ENSO Monitor UI<br/>[App.tsx]"]
  node_hook["Observation state<br/>[useObservations.ts]"]
  node_client["API client<br/>[client.ts]"]
  node_types["Data contracts<br/>[types.ts]"]
  node_period_filter["Period filter<br/>[PeriodFilter.tsx]"]
  node_chart["ONI chart<br/>[OniChart.tsx]"]
  node_table["Observations table"]
  node_source_info["Source metadata<br/>[SourceInfo.tsx]"]
  node_episode["Episode comparison"]
  node_comparison_result["Comparison results"]
  node_interpretation["Cautious interpretation<br/>[interpretation.ts]"]
  node_period_utils["Period utilities<br/>[period.ts]"]
end

node_noaa(("NOAA ONI source"))
node_user(("Explorer"))

node_user -->|"explores"| node_app
node_noaa -->|"provides page"| node_extract
node_import_run -->|"downloads"| node_extract
node_extract -->|"returns raw file"| node_import_run
node_import_run -->|"transforms page"| node_transform
node_import_run -->|"loads rows"| node_load
node_load -->|"writes observations"| node_database
node_import_run -->|"records import"| node_database
node_import_run -->|"opens session"| node_db_session
node_api_main -->|"registers routes"| node_api_routes
node_api_routes -->|"depends on"| node_db_session
node_api_routes -->|"queries"| node_database
node_api_routes -->|"computes statistics"| node_analysis
node_api_routes -->|"validates responses"| node_schemas
node_app -->|"loads observations"| node_hook
node_app -->|"renders filter"| node_period_filter
node_app -->|"renders chart"| node_chart
node_app -->|"renders table"| node_table
node_app -->|"renders source"| node_source_info
node_app -->|"renders comparison"| node_episode
node_hook -->|"fetches observations"| node_client
node_client -->|"requests API"| node_api_routes
node_episode -->|"requests comparison"| node_client
node_episode -->|"validates periods"| node_period_utils
node_episode -->|"renders result"| node_comparison_result
node_comparison_result -->|"describes comparison"| node_interpretation
node_hook -->|"uses contracts"| node_types
node_client -->|"uses contracts"| node_types
node_episode -->|"uses contracts"| node_types
node_comparison_result -->|"uses contracts"| node_types
node_period_filter -->|"converts periods"| node_period_utils
node_source_info -->|"fetches metadata"| node_client

click node_import_run "https://github.com/obsg13/enso-monitor/blob/main/backend/etl/run.py"
click node_extract "https://github.com/obsg13/enso-monitor/blob/main/backend/etl/extract.py"
click node_transform "https://github.com/obsg13/enso-monitor/blob/main/backend/etl/transform.py"
click node_load "https://github.com/obsg13/enso-monitor/blob/main/backend/etl/load.py"
click node_database "https://github.com/obsg13/enso-monitor/blob/main/backend/app/models.py"
click node_db_session "https://github.com/obsg13/enso-monitor/blob/main/backend/app/db.py"
click node_api_routes "https://github.com/obsg13/enso-monitor/blob/main/backend/app/routes.py"
click node_analysis "https://github.com/obsg13/enso-monitor/blob/main/backend/app/analysis.py"
click node_schemas "https://github.com/obsg13/enso-monitor/blob/main/backend/app/schemas.py"
click node_api_main "https://github.com/obsg13/enso-monitor/blob/main/backend/app/main.py"
click node_app "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/App.tsx"
click node_hook "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/hooks/useObservations.ts"
click node_client "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/api/client.ts"
click node_types "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/api/types.ts"
click node_period_filter "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/PeriodFilter.tsx"
click node_chart "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/OniChart.tsx"
click node_table "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/ObservationsTable.tsx"
click node_source_info "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/SourceInfo.tsx"
click node_episode "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/EpisodeComparison.tsx"
click node_comparison_result "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/ComparisonResult.tsx"
click node_interpretation "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/interpretation.ts"
click node_period_utils "https://github.com/obsg13/enso-monitor/blob/main/frontend/src/period.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_import_run,node_extract,node_transform,node_load toneBlue
class node_database,node_db_session,node_api_routes,node_analysis,node_schemas,node_api_main toneAmber
class node_app,node_hook,node_client,node_types,node_period_filter,node_chart,node_table,node_source_info,node_episode,node_comparison_result,node_interpretation,node_period_utils toneMint
class node_noaa,node_user toneIndigo
```

## Components

### NOAA data import

- [Import orchestrator](https://github.com/obsg13/enso-monitor/blob/main/backend/etl/run.py): `backend/etl/run.py`
- [Page extraction](https://github.com/obsg13/enso-monitor/blob/main/backend/etl/extract.py): `backend/etl/extract.py`
- [Observation transform](https://github.com/obsg13/enso-monitor/blob/main/backend/etl/transform.py): `backend/etl/transform.py`
- [Idempotent load](https://github.com/obsg13/enso-monitor/blob/main/backend/etl/load.py): `backend/etl/load.py`

### API and analysis

- [PostgreSQL dataset](https://github.com/obsg13/enso-monitor/blob/main/backend/app/models.py): `backend/app/models.py`
- [Database sessions](https://github.com/obsg13/enso-monitor/blob/main/backend/app/db.py): `backend/app/db.py`
- [API endpoints](https://github.com/obsg13/enso-monitor/blob/main/backend/app/routes.py): `backend/app/routes.py`
- [Period statistics](https://github.com/obsg13/enso-monitor/blob/main/backend/app/analysis.py): `backend/app/analysis.py`
- [API schemas](https://github.com/obsg13/enso-monitor/blob/main/backend/app/schemas.py): `backend/app/schemas.py`
- [API application](https://github.com/obsg13/enso-monitor/blob/main/backend/app/main.py): `backend/app/main.py`

### Web exploration

- [ENSO Monitor UI](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Observation state](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/hooks/useObservations.ts): `frontend/src/hooks/useObservations.ts`
- [API client](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Data contracts](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/api/types.ts): `frontend/src/api/types.ts`
- [Period filter](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/PeriodFilter.tsx): `frontend/src/components/PeriodFilter.tsx`
- [ONI chart](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/OniChart.tsx): `frontend/src/components/OniChart.tsx`
- [Observations table](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/ObservationsTable.tsx): `frontend/src/components/ObservationsTable.tsx`
- [Source metadata](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/SourceInfo.tsx): `frontend/src/components/SourceInfo.tsx`
- [Episode comparison](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/EpisodeComparison.tsx): `frontend/src/components/EpisodeComparison.tsx`
- [Comparison results](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/components/ComparisonResult.tsx): `frontend/src/components/ComparisonResult.tsx`
- [Cautious interpretation](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/interpretation.ts): `frontend/src/interpretation.ts`
- [Period utilities](https://github.com/obsg13/enso-monitor/blob/main/frontend/src/period.ts): `frontend/src/period.ts`

### Other components

- **NOAA ONI source**
- **Explorer**

## Connections

- Explorer → ENSO Monitor UI: explores (evidence: `frontend/src/App.tsx`)
- NOAA ONI source → Page extraction: provides page (evidence: `README.md`)
- Import orchestrator → Page extraction: downloads (evidence: `backend/etl/run.py`)
- Page extraction → Import orchestrator: returns raw file (evidence: `backend/etl/run.py`)
- Import orchestrator → Observation transform: transforms page (evidence: `backend/etl/run.py`)
- Import orchestrator → Idempotent load: loads rows (evidence: `backend/etl/run.py`)
- Idempotent load → PostgreSQL dataset: writes observations (evidence: `backend/etl/load.py`)
- Import orchestrator → PostgreSQL dataset: records import (evidence: `backend/etl/run.py`)
- Import orchestrator → Database sessions: opens session (evidence: `backend/etl/run.py`)
- API application → API endpoints: registers routes (evidence: `backend/app/main.py`)
- API endpoints → Database sessions: depends on (evidence: `backend/app/routes.py`)
- API endpoints → PostgreSQL dataset: queries (evidence: `backend/app/routes.py`)
- API endpoints → Period statistics: computes statistics (evidence: `backend/app/routes.py`)
- API endpoints → API schemas: validates responses (evidence: `backend/app/routes.py`)
- ENSO Monitor UI → Observation state: loads observations (evidence: `frontend/src/App.tsx`)
- ENSO Monitor UI → Period filter: renders filter (evidence: `frontend/src/App.tsx`)
- ENSO Monitor UI → ONI chart: renders chart (evidence: `frontend/src/App.tsx`)
- ENSO Monitor UI → Observations table: renders table (evidence: `frontend/src/App.tsx`)
- ENSO Monitor UI → Source metadata: renders source (evidence: `frontend/src/App.tsx`)
- ENSO Monitor UI → Episode comparison: renders comparison (evidence: `frontend/src/App.tsx`)
- Observation state → API client: fetches observations (evidence: `frontend/src/hooks/useObservations.ts`)
- API client → API endpoints: requests API (evidence: `README.md`)
- Episode comparison → API client: requests comparison (evidence: `frontend/src/components/EpisodeComparison.tsx`)
- Episode comparison → Period utilities: validates periods (evidence: `frontend/src/components/EpisodeComparison.tsx`)
- Episode comparison → Comparison results: renders result (evidence: `frontend/src/components/EpisodeComparison.tsx`)
- Comparison results → Cautious interpretation: describes comparison (evidence: `frontend/src/components/ComparisonResult.tsx`)
- Observation state → Data contracts: uses contracts (evidence: `frontend/src/hooks/useObservations.ts`)
- API client → Data contracts: uses contracts (evidence: `frontend/src/api/client.ts`)
- Episode comparison → Data contracts: uses contracts (evidence: `frontend/src/components/EpisodeComparison.tsx`)
- Comparison results → Data contracts: uses contracts (evidence: `frontend/src/components/ComparisonResult.tsx`)
- Period filter → Period utilities: converts periods (evidence: `frontend/src/components/PeriodFilter.tsx`)
- Source metadata → API client: fetches metadata (evidence: `frontend/src/components/SourceInfo.tsx`)
