Architecture and Developer Guide#

The developer-facing reference for HydroModPy. Documents the package architecture, design patterns, storage layout, test layers, and the contributor recipes for extending the toolbox.

For user-facing documentation, see User Guide. For scientific notes and equations, see Theory.

Get started as a contributor#

Contributor handbook

Editable clone, pre-commit hooks, [dev,test,docs] extras, WSL/PETSc helpers, ruff workflow, test ladder, Sphinx build with -j auto and PlantUML setup, and the pull-request conventions. Start here on day one.

Contribute

Foundations#

Mental model

How a TOML becomes a persisted run. Read this once before diving into any package.

Mental Model & Design Choices
Design patterns

Canonical patterns reused across the codebase: SolverAdapter, Step, Figure, DataManager, ProcessSpatial.

Design Patterns
Package layout

The top-level subpackages, the facade layers, and the public-symbol contract.

Package Layout
Layered architecture

The strict 18-layer dependency matrix and the one-way import rule that every commit must respect.

Layered Architecture
Storage layout

DuckDB schema, Zarr stores, Parquet tables, and the basename rule that ties them together.

Storage Layout
Code reading guide

Recommended package-by-package reading paths through the source tree.

Code Reading Guide
GitHub Actions

Pull-request gate, specialized checks, scheduled suites, and how to triage each failing GitHub check.

GitHub Actions workflows

Per-package reference#

All top-level subpackages

One focused page per top-level subpackage. Each page covers the package role, its sub-modules, the key public symbols, and the recommended reading path through the code.

Per-Package Reference

Contributor recipes#

How-to index

Prescriptive recipes: add a solver, a config field, a data source, a figure, a test, a CLI command, a calibration method, an exporter, or build a frontend. Start here when extending HydroModPy.

How-to Recipes

Subsystem deep dives#

Simulation

Orchestration walkthrough, class diagrams, time-cycle diagrams, the comparison-workflow internals, and the testbed workflow.

Simulation Architecture
Solver backends

MODFLOW 6, MODFLOW-NWT, Boussinesq architecture notes, plus the MODFLOW DIS and BAS contracts honoured by HydroModPy.

Solver Architecture
Mesh architecture

Catchment-conformal Gmsh meshing, structured-grid path, and the cross-mesh pivot format used by every backend.

Mesh Architecture
Calibration internals

Code-oriented architecture map plus the full operational calibration guide for adding methods and objectives.

Calibration Architecture
Data and field

Data planning and runtime loading, the field abstraction shared by every solver, and the external data-source policy.

Data Loading Architecture
Spatial support and hydrography

Support selection, hydrography UML, and the simulated active network inventory for stream and seepage diagnostics.

Spatial Support and Hydrography