Online WaterGAP
Run WaterGAP 2.2e in your browser.
About this project
Online WaterGAP puts a web interface around the official
ReWaterGAP
(WaterGAP 2.2e) code. The model itself is untouched — same source, same dependencies, same results as running it locally.
Everything web-related sits in the online/ directory and doesn't interfere with the rest of the repository.
Features
Configuration
Pick a time period, choose between natural and anthropogenic modes, select which variables to output, and decide between a global or basin-level run.
Remote execution
The simulation runs on a server, so you don't need WaterGAP installed locally. You can follow the log in real time or close the tab and come back later.
Visualization
View output variables as spatial maps, step through time, or upload your own NetCDF files to compare against.
Presets
Save a configuration under a name to reuse it later, or export/import configs as JSON files.
Getting started
Set up a simulation
Head to the Simulation tab. Load a preset or build your config from scratch — time period, output variables, global vs. basin extent.
Run it
Hit "Start Simulation". The Runs tab shows the live log and resource usage. The run keeps going even if you close the page.
Look at the output
Once the run finishes, open the Visualization tab. Pick the run and a variable, then browse the maps over time.
Select a data source above or drop a .nc file here
Choose from previous simulation runs, uploads, or upload a new NetCDF file
This page shows a summary of the online infrastructure. For the full ReWaterGAP documentation (model processes, user guide, tutorials, and more):
Online Infrastructure
OnlineWaterGap wraps the existing ReWaterGAP command-line application in a web-based frontend so that users can configure, launch, and visualize hydrological simulations from any modern browser.
Architecture
The stack consists of three components:
Static HTML/JS served by Vercel. Single-page app, no build step required.
FastAPI running in Docker on a Hetzner cloud server. Spawns run_watergap.py as a subprocess.
Supabase PostgreSQL instance tracking simulation jobs and uploaded datasets.
Request Flow
Browser │ ▼ Vercel (online-water-gap.vercel.app) │ serves static HTML/JS │ proxies /api/* via rewrite rules ▼ Hetzner Docker host (FastAPI + Uvicorn) │ starts run_watergap.py as subprocess ▼ WaterGAP simulation │ reads input_data/ (mounted read-only) │ writes results to output_data/ ▼ Browser receives status updates, logs, result maps
Repository Layout
online/ ├── api/ │ ├── main.py # FastAPI application │ └── static/ # Frontend (HTML, JS, CSS) ├── Dockerfile # Container image definition ├── docker-compose.yml # Service orchestration + volumes ├── run_web.py # Dev helper: installs deps + starts uvicorn └── vercel.json # Vercel routing & API proxy config
Docker Volumes
| Volume | Mode | Purpose |
|---|---|---|
| input_data | read-only | Climate forcing, water use, static data |
| watergap-jobs | read-write | Per-run config, logs, status |
| watergap-uploads | read-write | User-uploaded NetCDF files |
| watergap-output | read-write | Simulation result files |
| watergap-presets | read-write | Saved configuration presets |
API Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/health | Health check |
| POST | /api/simulate | Start a new simulation |
| GET | /api/status/{job_id} | Poll job status |
| POST | /api/cancel/{job_id} | Terminate a running simulation |
| GET | /api/jobs | List all runs with status |
| GET | /api/resources | Server resource usage (RAM, Swap, Disk) |
| GET | /api/presets | List saved presets |
| GET | /api/input-datasets | List available input data bundles |
| GET | /api/map/{source}/{var} | Render a spatial map (PNG) |
Changes Relative to the Original Code Base
The online version keeps changes minimal. The core model code
(model/,
controller/,
calibration/,
view/) and
requirements.txt
are identical to the upstream ReWaterGAP repository. All additions live exclusively in the
online/ directory.