# rubeshnpl13/riverwatch-nepal architecture

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

- Interactive diagram: https://gitdiagram.com/rubeshnpl13/riverwatch-nepal
- Repository: https://github.com/rubeshnpl13/riverwatch-nepal

## Overview

RiverWatch Nepal ingests BIPAD river data, validates and preserves raw records, processes typed datasets and quality reports, then serves monitoring analytics through a FastAPI API and React dashboard. Its event-driven cloud execution path supports ingestion and managed Spark processing. The graph combines sampled call relationships with README-documented capabilities; unsampled analytics, dashboard, and cloud subsystems are included at paths supported by the tree, but their internal links are not inferred where evidence is absent.

Main entry points: [`frontend/src/App.tsx`](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/App.tsx) (Dashboard application), [`src/riverwatch/ingestion/bipad/historical_service.py`](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/ingestion/bipad/historical_service.py) (Validate and ingest), [`src/riverwatch/processing/spark/pipeline.py`](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/processing/spark/pipeline.py) (Spark transformations), [`src/riverwatch/cloud/processing_pipeline.py`](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/cloud/processing_pipeline.py) (Cloud Spark pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_source["BIPAD ingestion"]
  node_client["Paginated API client<br/>[client.py]"]
  node_ingest["Validate and ingest"]
  node_endpoints["Source endpoints<br/>[endpoints.py]"]
end

subgraph group_data["Lake and processing"]
  node_raw[("Immutable raw records<br/>[raw.py]")]
  node_manifest["Run manifests<br/>[manifest.py]"]
  node_quarantine[("Quarantined records<br/>[quarantine.py]")]
  node_spark["Spark transformations<br/>[pipeline.py]"]
  node_quality["Quality reports<br/>[summary.py]"]
  node_processed[("Typed Parquet datasets<br/>[writer.py]")]
end

subgraph group_events["Event execution"]
  node_events["Event worker<br/>[worker.py]"]
  node_bus["Event bus<br/>[bus.py]"]
  node_cloud_ingest["Cloud ingestion service<br/>[ingestion_app.py]"]
  node_cloud_spark["Cloud Spark pipeline"]
end

subgraph group_serving["Analytics and API"]
  node_analytics["Network and basin analytics<br/>[service.py]"]
  node_bigquery["BigQuery analytics<br/>[bigquery.py]"]
  node_api["FastAPI endpoints<br/>[app.py]"]
end

subgraph group_ui["Dashboard"]
  node_app["Dashboard application<br/>[App.tsx]"]
  node_api_client["HTTP API client<br/>[client.ts]"]
  node_overview["Network overview"]
  node_map["Station map<br/>[StationMap.tsx]"]
  node_detail["Station history<br/>[StationDetail.tsx]"]
  node_table["Station table<br/>[StationTable.tsx]"]
  node_basin["Basin analytics view<br/>[BasinAnalytics.tsx]"]
end

node_bipad(("BIPAD Nepal"))
node_browser(("Dashboard user"))

node_client -->|"fetches pages"| node_bipad
node_ingest -->|"reads source"| node_client
node_ingest -->|"writes raw"| node_raw
node_ingest -->|"writes invalid"| node_quarantine
node_ingest -->|"records run"| node_manifest
node_ingest -->|"uses types"| node_endpoints
node_spark -->|"reads inputs"| node_raw
node_spark -->|"loads run"| node_manifest
node_spark -->|"writes datasets"| node_processed
node_spark -->|"evaluates quality"| node_quality
node_events -->|"consumes requests"| node_bus
node_events -.->|"runs ingestion"| node_ingest
node_cloud_ingest -->|"handles events"| node_events
node_cloud_spark -->|"loads inputs"| node_raw
node_cloud_spark -->|"commits datasets"| node_processed
node_cloud_spark -->|"creates reports"| node_quality
node_processed -.->|"feeds analytics"| node_analytics
node_analytics -->|"serves queries"| node_api
node_bigquery -.->|"cloud implementation"| node_analytics
node_browser -.->|"views dashboard"| node_app
node_app -.->|"requests data"| node_api_client
node_api_client -.->|"calls HTTP API"| node_api
node_app -->|"renders"| node_overview
node_app -->|"renders"| node_map
node_app -->|"renders"| node_detail
node_app -->|"renders"| node_basin
node_app -->|"renders"| node_table

click node_client "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/ingestion/bipad/client.py"
click node_ingest "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/ingestion/bipad/historical_service.py"
click node_endpoints "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/ingestion/bipad/endpoints.py"
click node_raw "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/storage/raw.py"
click node_manifest "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/storage/manifest.py"
click node_quarantine "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/storage/quarantine.py"
click node_spark "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/processing/spark/pipeline.py"
click node_quality "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/quality/spark/summary.py"
click node_processed "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/processing/spark/writer.py"
click node_events "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/events/worker.py"
click node_bus "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/events/bus.py"
click node_cloud_ingest "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/cloud/ingestion_app.py"
click node_cloud_spark "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/cloud/processing_pipeline.py"
click node_analytics "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/analytics/service.py"
click node_bigquery "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/analytics/bigquery.py"
click node_api "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/api/app.py"
click node_app "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/api/client.ts"
click node_overview "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/components/NetworkOverview.tsx"
click node_map "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/components/StationMap.tsx"
click node_detail "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/components/StationDetail.tsx"
click node_table "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/components/StationTable.tsx"
click node_basin "https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/components/BasinAnalytics.tsx"

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_client,node_ingest,node_endpoints,node_browser toneBlue
class node_raw,node_manifest,node_quarantine,node_spark,node_quality,node_processed toneAmber
class node_events,node_bus,node_cloud_ingest,node_cloud_spark toneMint
class node_analytics,node_bigquery,node_api toneRose
class node_app,node_api_client,node_overview,node_map,node_detail,node_table,node_basin,node_bipad toneIndigo
```

## Components

### BIPAD ingestion

- [Paginated API client](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/ingestion/bipad/client.py): `src/riverwatch/ingestion/bipad/client.py`
- [Validate and ingest](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/ingestion/bipad/historical_service.py): `src/riverwatch/ingestion/bipad/historical_service.py`
- [Source endpoints](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/ingestion/bipad/endpoints.py): `src/riverwatch/ingestion/bipad/endpoints.py`

### Lake and processing

- [Immutable raw records](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/storage/raw.py): `src/riverwatch/storage/raw.py`
- [Run manifests](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/storage/manifest.py): `src/riverwatch/storage/manifest.py`
- [Quarantined records](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/storage/quarantine.py): `src/riverwatch/storage/quarantine.py`
- [Spark transformations](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/processing/spark/pipeline.py): `src/riverwatch/processing/spark/pipeline.py`
- [Quality reports](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/quality/spark/summary.py): `src/riverwatch/quality/spark/summary.py`
- [Typed Parquet datasets](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/processing/spark/writer.py): `src/riverwatch/processing/spark/writer.py`

### Event execution

- [Event worker](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/events/worker.py): `src/riverwatch/events/worker.py`
- [Event bus](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/events/bus.py): `src/riverwatch/events/bus.py`
- [Cloud ingestion service](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/cloud/ingestion_app.py): `src/riverwatch/cloud/ingestion_app.py`
- [Cloud Spark pipeline](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/cloud/processing_pipeline.py): `src/riverwatch/cloud/processing_pipeline.py`

### Analytics and API

- [Network and basin analytics](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/analytics/service.py): `src/riverwatch/analytics/service.py`
- [BigQuery analytics](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/analytics/bigquery.py): `src/riverwatch/analytics/bigquery.py`
- [FastAPI endpoints](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/src/riverwatch/api/app.py): `src/riverwatch/api/app.py`

### Dashboard

- [Dashboard application](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [HTTP API client](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Network overview](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/components/NetworkOverview.tsx): `frontend/src/components/NetworkOverview.tsx`
- [Station map](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/components/StationMap.tsx): `frontend/src/components/StationMap.tsx`
- [Station history](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/components/StationDetail.tsx): `frontend/src/components/StationDetail.tsx`
- [Station table](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/components/StationTable.tsx): `frontend/src/components/StationTable.tsx`
- [Basin analytics view](https://github.com/rubeshnpl13/riverwatch-nepal/blob/main/frontend/src/components/BasinAnalytics.tsx): `frontend/src/components/BasinAnalytics.tsx`

### Other components

- **BIPAD Nepal**
- **Dashboard user**

## Connections

- Paginated API client → BIPAD Nepal: fetches pages (evidence: `src/riverwatch/ingestion/bipad/client.py`)
- Validate and ingest → Paginated API client: reads source (evidence: `src/riverwatch/ingestion/bipad/historical_service.py`)
- Validate and ingest → Immutable raw records: writes raw (evidence: `src/riverwatch/ingestion/bipad/historical_service.py`)
- Validate and ingest → Quarantined records: writes invalid (evidence: `src/riverwatch/ingestion/bipad/historical_service.py`)
- Validate and ingest → Run manifests: records run (evidence: `src/riverwatch/ingestion/bipad/historical_service.py`)
- Validate and ingest → Source endpoints: uses types (evidence: `src/riverwatch/ingestion/bipad/historical_service.py`)
- Spark transformations → Immutable raw records: reads inputs (evidence: `src/riverwatch/processing/spark/pipeline.py`)
- Spark transformations → Run manifests: loads run (evidence: `src/riverwatch/processing/spark/pipeline.py`)
- Spark transformations → Typed Parquet datasets: writes datasets (evidence: `src/riverwatch/processing/spark/pipeline.py`)
- Spark transformations → Quality reports: evaluates quality (evidence: `src/riverwatch/processing/spark/pipeline.py`)
- Event worker → Event bus: consumes requests (evidence: `src/riverwatch/events/worker.py`)
- Event worker → Validate and ingest: runs ingestion
- Cloud ingestion service → Event worker: handles events (evidence: `src/riverwatch/cloud/ingestion_app.py`)
- Cloud Spark pipeline → Immutable raw records: loads inputs (evidence: `src/riverwatch/cloud/processing_pipeline.py`)
- Cloud Spark pipeline → Typed Parquet datasets: commits datasets (evidence: `src/riverwatch/cloud/processing_pipeline.py`)
- Cloud Spark pipeline → Quality reports: creates reports (evidence: `src/riverwatch/cloud/processing_pipeline.py`)
- Typed Parquet datasets → Network and basin analytics: feeds analytics (evidence: `README.md`)
- Network and basin analytics → FastAPI endpoints: serves queries (evidence: `src/riverwatch/api/app.py`)
- BigQuery analytics → Network and basin analytics: cloud implementation (evidence: `README.md`)
- Dashboard user → Dashboard application: views dashboard
- Dashboard application → HTTP API client: requests data
- HTTP API client → FastAPI endpoints: calls HTTP API (evidence: `README.md`)
- Dashboard application → Network overview: renders (evidence: `frontend/src/App.tsx`)
- Dashboard application → Station map: renders (evidence: `frontend/src/App.tsx`)
- Dashboard application → Station history: renders (evidence: `frontend/src/App.tsx`)
- Dashboard application → Basin analytics view: renders (evidence: `frontend/src/App.tsx`)
- Dashboard application → Station table: renders (evidence: `frontend/src/App.tsx`)
