# oceanmodeling/seanode architecture

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

- Interactive diagram: https://gitdiagram.com/oceanmodeling/seanode
- Repository: https://github.com/oceanmodeling/seanode

## Overview

1. **What this repository is**
   - `seanode` is a Python library for extracting ocean/atmospheric model values at station or point locations.
   - It is not an application server; the main boundary is a callable library API exposed through `seanode.api`.

2. **Primary entry point**
   - The top-level workflow starts with `get_surge_model_at_stations(...)` in `seanode/api.py`.
   - That function likely accepts a request describing stations, model choice, variables, and time range, then returns extracted model data.

3. **Request and configuration layer**
   - `request.py` and `request_options.py` define the input contract and query options.
   - This layer separates user-facing parameters from the internal execution logic, which is important for diagramming the front edge of the system.

4. **Model selection and routing**
   - `model_factory.py` chooses the correct model implementation based on the request.
   - `seanode/models/` contains model-specific adapters for supported datasets: `gfs`, `hrrr`, `stofs_2d_glo`, and `stofs_3d_atl`.
   - `model_task_creator.py` suggests a second routing step that turns a model choice into the appropriate analysis task.

5. **Grid vs mesh processing paths**
   - The codebase has distinct task modules for `analysis_task_grid.py` and `analysis_task_mesh.py`, plus a shared `analysis_task.py`.
   - This indicates two major data geometry paths:
     - **grid-based models** such as GFS and HRRR
     - **mesh-based models** such as STOFS variants
   - This split is a key architecture boundary.

6. **Field sourcing and data access**
   - `field_source.py` appears to abstract where model fields come from.
   - `data_stores.py` and `data_store_factory.py` indicate a pluggable storage/access layer, likely hiding whether data comes from local files, remote URLs, or cached references.
   - `kerchunker.py` suggests support for kerchunk-based virtual datasets, which is a material part of the data-access architecture.

7. **Model-specific implementations**
   - Each model module likely encodes dataset-specific metadata, variable names, coordinate conventions, and extraction rules.
   - The tests show separate coverage for each model and for kerchunked GFS, implying model adapters are not generic wrappers but contain important model logic.

8. **Core data flow**
   - The likely flow is:
     - user calls the API
     - request/options are normalized
     - a model adapter is selected
     - a task creator builds a grid or mesh analysis task
     - the task resolves the backing data store / kerchunk source
     - fields are extracted at station locations
     - results are returned to the caller
   - For an architecture diagram, this is the central left-to-right pipeline.

9. **Supported model families**
   - The repository explicitly supports:
     - **GFS**: global forecast system, grid-based
     - **HRRR**: high-resolution rapid refresh, grid-based
     - **STOFS 2D GLO**: likely a global 2D storm surge/ocean product
     - **STOFS 3D ATL**: likely an Atlantic 3D product
   - The STOFS entries each have both standard and `_mesh` tests, reinforcing the geometry split.

10. **Testing and validation**
    - The `tests/` directory is extensive and model-specific, with separate API tests, model tests, and mesh/grid tests.
    - This suggests the repository’s correctness depends heavily on validating model-specific extraction behavior rather than just generic library mechanics.

11. **Developer-facing examples**
    - `example_points_query.ipynb` and the tests serve as usage examples.
    - The notebook likely demonstrates the end-to-end point-query workflow from Python code.

12. **Project shape and tooling**
    - This is a packaged Python library managed by `pyproject.toml` and `requirements.txt`.
    - There is no visible runtime infrastructure, queue, database, or web service layer in the tree; the architecture is focused on in-process data extraction and model adaptation.

13. **Important architectural boundary**
    - The key abstraction boundary is between **request/model selection** and **dataset access/extraction mechanics**.
    - Another important boundary is **grid vs mesh**, because those paths imply different interpolation or indexing strategies.

14. **How to draw it**
    - A good diagram would show a single public API feeding a request/configuration layer, then branching into model-specific adapters, then into grid/mesh analysis tasks, then into data-store/kerchunk-backed field retrieval, and finally into extracted station results.

Main entry points: [`seanode/model_factory.py`](https://github.com/oceanmodeling/seanode/blob/main/seanode/model_factory.py) (Model Factory), [`seanode/models/model_task_creator.py`](https://github.com/oceanmodeling/seanode/blob/main/seanode/models/model_task_creator.py) (Task Creator), [`seanode/data_store_factory.py`](https://github.com/oceanmodeling/seanode/blob/main/seanode/data_store_factory.py) (Store Factory), [`seanode/analysis_task.py`](https://github.com/oceanmodeling/seanode/blob/main/seanode/analysis_task.py) (Analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Public API"]
  node_api["API<br/>library entrypoint<br/>[api.py]"]
  node_request["Request<br/>input contract<br/>[request.py]"]
  node_request_options["Options<br/>[request_options.py]"]
  node_results["Results<br/>extracted values"]
end

subgraph group_routing["Model Routing"]
  node_model_factory{{"Model Factory<br/>selector<br/>[model_factory.py]"}}
  node_task_creator{{"Task Creator<br/>task router"}}
end

subgraph group_analysis["Analysis Tasks"]
  node_analysis_task["Analysis<br/>shared task<br/>[analysis_task.py]"]
  node_analysis_grid["Grid Task<br/>grid extraction"]
  node_analysis_mesh["Mesh Task<br/>mesh extraction"]
end

subgraph group_access["Data Access"]
  node_field_source[("Field Source<br/>data source abstraction<br/>[field_source.py]")]
  node_store_factory{{"Store Factory<br/>store selector"}}
  node_data_stores[("Data Stores<br/>storage backends<br/>[data_stores.py]")]
  node_kerchunker[("Kerchunk<br/>virtual dataset<br/>[kerchunker.py]")]
end

subgraph group_models["Model Adapters"]
  node_gfs["GFS<br/>grid model<br/>[gfs.py]"]
  node_hrrr["HRRR<br/>grid model<br/>[hrrr.py]"]
  node_stofs2d["STOFS 2D<br/>mesh model<br/>[stofs_2d_glo.py]"]
  node_stofs3d["STOFS 3D<br/>mesh model<br/>[stofs_3d_atl.py]"]
end

node_api -->|"accepts"| node_request
node_api -->|"uses"| node_request_options
node_request -->|"selects"| node_model_factory
node_request_options -->|"constrains"| node_model_factory
node_model_factory -->|"routes"| node_gfs
node_model_factory -->|"routes"| node_hrrr
node_model_factory -->|"routes"| node_stofs2d
node_model_factory -->|"routes"| node_stofs3d
node_gfs -->|"builds"| node_task_creator
node_hrrr -->|"builds"| node_task_creator
node_stofs2d -->|"builds"| node_task_creator
node_stofs3d -->|"builds"| node_task_creator
node_task_creator -->|"creates"| node_analysis_grid
node_task_creator -->|"creates"| node_analysis_mesh
node_analysis_grid -->|"shares"| node_analysis_task
node_analysis_mesh -->|"shares"| node_analysis_task
node_analysis_task -->|"reads"| node_field_source
node_field_source -->|"selects"| node_store_factory
node_store_factory -->|"opens"| node_data_stores
node_store_factory -->|"may use"| node_kerchunker
node_data_stores -->|"feeds"| node_results
node_kerchunker -->|"feeds"| node_results

click node_api "https://github.com/oceanmodeling/seanode/blob/main/seanode/api.py"
click node_request "https://github.com/oceanmodeling/seanode/blob/main/seanode/request.py"
click node_request_options "https://github.com/oceanmodeling/seanode/blob/main/seanode/request_options.py"
click node_model_factory "https://github.com/oceanmodeling/seanode/blob/main/seanode/model_factory.py"
click node_task_creator "https://github.com/oceanmodeling/seanode/blob/main/seanode/models/model_task_creator.py"
click node_analysis_task "https://github.com/oceanmodeling/seanode/blob/main/seanode/analysis_task.py"
click node_analysis_grid "https://github.com/oceanmodeling/seanode/blob/main/seanode/analysis_task_grid.py"
click node_analysis_mesh "https://github.com/oceanmodeling/seanode/blob/main/seanode/analysis_task_mesh.py"
click node_field_source "https://github.com/oceanmodeling/seanode/blob/main/seanode/field_source.py"
click node_store_factory "https://github.com/oceanmodeling/seanode/blob/main/seanode/data_store_factory.py"
click node_data_stores "https://github.com/oceanmodeling/seanode/blob/main/seanode/data_stores.py"
click node_kerchunker "https://github.com/oceanmodeling/seanode/blob/main/seanode/kerchunker.py"
click node_gfs "https://github.com/oceanmodeling/seanode/blob/main/seanode/models/gfs.py"
click node_hrrr "https://github.com/oceanmodeling/seanode/blob/main/seanode/models/hrrr.py"
click node_stofs2d "https://github.com/oceanmodeling/seanode/blob/main/seanode/models/stofs_2d_glo.py"
click node_stofs3d "https://github.com/oceanmodeling/seanode/blob/main/seanode/models/stofs_3d_atl.py"

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_api,node_request,node_request_options,node_results toneBlue
class node_model_factory,node_task_creator toneAmber
class node_analysis_task,node_analysis_grid,node_analysis_mesh toneMint
class node_field_source,node_store_factory,node_data_stores,node_kerchunker toneRose
class node_gfs,node_hrrr,node_stofs2d,node_stofs3d toneIndigo
```

## Components

### Public API

User-facing entry points and request normalization.

- [API](https://github.com/oceanmodeling/seanode/blob/main/seanode/api.py): library entrypoint · Top-level callable interface for station extraction. · `seanode/api.py`
- [Request](https://github.com/oceanmodeling/seanode/blob/main/seanode/request.py): input contract · User request object and core query parameters. · `seanode/request.py`
- [Options](https://github.com/oceanmodeling/seanode/blob/main/seanode/request_options.py): query options · Optional filters and extraction settings. · `seanode/request_options.py`
- **Results**: extracted values · Station-level model values returned to the caller.

### Model Routing

Selects model-specific behavior and task shape.

- [Model Factory](https://github.com/oceanmodeling/seanode/blob/main/seanode/model_factory.py): selector · Chooses the appropriate model implementation. · `seanode/model_factory.py`
- [Task Creator](https://github.com/oceanmodeling/seanode/blob/main/seanode/models/model_task_creator.py): task router · Turns a model choice into a concrete analysis task. · `seanode/models/model_task_creator.py`

### Analysis Tasks

Grid and mesh extraction execution paths.

- [Analysis](https://github.com/oceanmodeling/seanode/blob/main/seanode/analysis_task.py): shared task · Common task logic shared by grid and mesh paths. · `seanode/analysis_task.py`
- [Grid Task](https://github.com/oceanmodeling/seanode/blob/main/seanode/analysis_task_grid.py): grid extraction · Processing path for structured grid models. · `seanode/analysis_task_grid.py`
- [Mesh Task](https://github.com/oceanmodeling/seanode/blob/main/seanode/analysis_task_mesh.py): mesh extraction · Processing path for unstructured mesh models. · `seanode/analysis_task_mesh.py`

### Data Access

Field sourcing, storage, and kerchunk-backed dataset resolution.

- [Field Source](https://github.com/oceanmodeling/seanode/blob/main/seanode/field_source.py): data source abstraction · Abstracts where model fields come from. · `seanode/field_source.py`
- [Store Factory](https://github.com/oceanmodeling/seanode/blob/main/seanode/data_store_factory.py): store selector · Selects a concrete data store implementation. · `seanode/data_store_factory.py`
- [Data Stores](https://github.com/oceanmodeling/seanode/blob/main/seanode/data_stores.py): storage backends · Pluggable backing store implementations. · `seanode/data_stores.py`
- [Kerchunk](https://github.com/oceanmodeling/seanode/blob/main/seanode/kerchunker.py): virtual dataset · Resolves kerchunk-backed dataset references. · `seanode/kerchunker.py`

### Model Adapters

Supported model-family implementations.

- [GFS](https://github.com/oceanmodeling/seanode/blob/main/seanode/models/gfs.py): grid model · Global Forecast System adapter and metadata. · `seanode/models/gfs.py`
- [HRRR](https://github.com/oceanmodeling/seanode/blob/main/seanode/models/hrrr.py): grid model · High-resolution rapid refresh adapter and metadata. · `seanode/models/hrrr.py`
- [STOFS 2D](https://github.com/oceanmodeling/seanode/blob/main/seanode/models/stofs_2d_glo.py): mesh model · 2D STOFS global adapter and geometry rules. · `seanode/models/stofs_2d_glo.py`
- [STOFS 3D](https://github.com/oceanmodeling/seanode/blob/main/seanode/models/stofs_3d_atl.py): mesh model · 3D STOFS Atlantic adapter and geometry rules. · `seanode/models/stofs_3d_atl.py`

## Connections

- API → Request: accepts · Public API receives the request object and parameters.
- API → Options: uses · API consults request options for query configuration.
- Request → Model Factory: selects · Request drives model selection.
- Options → Model Factory: constrains · Options refine the model and extraction route.
- Model Factory → GFS: routes · Chooses the GFS adapter for grid-based extraction.
- Model Factory → HRRR: routes · Chooses the HRRR adapter for grid-based extraction.
- Model Factory → STOFS 2D: routes · Chooses the STOFS 2D adapter for mesh-based extraction.
- Model Factory → STOFS 3D: routes · Chooses the STOFS 3D adapter for mesh-based extraction.
- GFS → Task Creator: builds · Model adapter informs which task to create.
- HRRR → Task Creator: builds · Model adapter informs which task to create.
- STOFS 2D → Task Creator: builds · Model adapter informs which task to create.
- STOFS 3D → Task Creator: builds · Model adapter informs which task to create.
- Task Creator → Grid Task: creates · Grid models are executed through the grid task path.
- Task Creator → Mesh Task: creates · Mesh models are executed through the mesh task path.
- Grid Task → Analysis: shares · Grid path reuses common analysis behavior.
- Mesh Task → Analysis: shares · Mesh path reuses common analysis behavior.
- Analysis → Field Source: reads · Analysis resolves model fields through the source abstraction.
- Field Source → Store Factory: selects · Field source chooses an appropriate store implementation.
- Store Factory → Data Stores: opens · Factory returns a concrete storage backend.
- Store Factory → Kerchunk: may use · Factory may resolve kerchunk-backed virtual datasets.
- Data Stores → Results: feeds · Backends provide data used for extraction.
- Kerchunk → Results: feeds · Kerchunk references provide data used for extraction.
