# ibrahimm96/flowpywr architecture

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

- Interactive diagram: https://gitdiagram.com/ibrahimm96/flowpywr
- Repository: https://github.com/ibrahimm96/flowpywr
- Video tour (about a minute): https://gitdiagram.com/ibrahimm96/flowpywr/video

## Overview

FlowPywr is a water-resource and hydropower optimization web app. Its visible workflow is to select river models and map filters, load model nodes and edges, and visualize infrastructure, flow links, and selected-node details; the home page also directs users to upload models or view analysis results. The graph includes authentication and upload/analysis entry points, but their deeper behavior is not established by the excerpts. Model data is fetched from static JSON paths; no optimization engine or upload-processing backend is shown.

Main entry points: [`components/map.tsx`](https://github.com/ibrahimm96/flowpywr/blob/wip3/components/map.tsx) (Interactive map), [`app/model-visualization/page.tsx`](https://github.com/ibrahimm96/flowpywr/blob/wip3/app/model-visualization/page.tsx) (Model visualization page), [`contexts/AuthContext.tsx`](https://github.com/ibrahimm96/flowpywr/blob/wip3/contexts/AuthContext.tsx) (Auth context), [`lib/supabase.tsx`](https://github.com/ibrahimm96/flowpywr/blob/wip3/lib/supabase.tsx) (Supabase client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and navigation"]
  node_home["Home page<br/>[page.tsx]"]
  node_authpage["Sign-in page<br/>[page.tsx]"]
  node_auth["Auth context<br/>[AuthContext.tsx]"]
  node_supabase["Supabase client<br/>[supabase.tsx]"]
  node_sidebar["App navigation<br/>[sidebar.tsx]"]
end

subgraph group_models["Model data"]
  node_modeldata["Model data context"]
  node_loader["Model JSON loader"]
  node_staticmodels["Static model JSON"]
end

subgraph group_mapping["Map visualization"]
  node_modelview["Model visualization page<br/>[page.tsx]"]
  node_mapcontrols["Map controls<br/>[mapSideBar.tsx]"]
  node_mapstate["Map context<br/>[MapContext.tsx]"]
  node_map["Interactive map<br/>[map.tsx]"]
  node_markers["Node markers<br/>[useAddMarkers.tsx]"]
  node_flow["Flow rendering<br/>[useShowFlow.tsx]"]
  node_boundaries["Map boundaries"]
end

subgraph group_operations["Model operations"]
  node_upload["Model upload page<br/>[page.tsx]"]
  node_analysis["Analysis page<br/>[page.tsx]"]
end

node_visitor(("App user"))
node_mapbox["Mapbox GL"]

node_visitor -->|"opens"| node_home
node_visitor -.->|"opens"| node_authpage
node_visitor -.->|"opens"| node_modelview
node_visitor -.->|"opens"| node_upload
node_visitor -.->|"opens"| node_analysis
node_home -->|"checks loading"| node_auth
node_authpage -->|"uses auth"| node_supabase
node_auth -->|"reads session"| node_supabase
node_sidebar -->|"reads user"| node_auth
node_sidebar -->|"uses client"| node_supabase
node_modelview -->|"renders"| node_map
node_modelview -->|"renders"| node_mapcontrols
node_modeldata -->|"loads via"| node_loader
node_loader -->|"fetches JSON"| node_staticmodels
node_mapcontrols -->|"updates filters"| node_mapstate
node_map -->|"reads models"| node_modeldata
node_map -->|"reads settings"| node_mapstate
node_map -->|"adds markers"| node_markers
node_map -->|"renders flows"| node_flow
node_map -->|"adds boundaries"| node_boundaries
node_markers -->|"sets selection"| node_mapstate
node_map -->|"configures map"| node_mapbox

click node_home "https://github.com/ibrahimm96/flowpywr/blob/wip3/app/page.tsx"
click node_authpage "https://github.com/ibrahimm96/flowpywr/blob/wip3/app/auth/page.tsx"
click node_auth "https://github.com/ibrahimm96/flowpywr/blob/wip3/contexts/AuthContext.tsx"
click node_supabase "https://github.com/ibrahimm96/flowpywr/blob/wip3/lib/supabase.tsx"
click node_sidebar "https://github.com/ibrahimm96/flowpywr/blob/wip3/components/sidebar.tsx"
click node_modelview "https://github.com/ibrahimm96/flowpywr/blob/wip3/app/model-visualization/page.tsx"
click node_upload "https://github.com/ibrahimm96/flowpywr/blob/wip3/app/upload/page.tsx"
click node_analysis "https://github.com/ibrahimm96/flowpywr/blob/wip3/app/analysis/page.tsx"
click node_modeldata "https://github.com/ibrahimm96/flowpywr/blob/wip3/contexts/ModelDataContext.tsx"
click node_loader "https://github.com/ibrahimm96/flowpywr/blob/wip3/hooks/useGetModelData.tsx"
click node_mapcontrols "https://github.com/ibrahimm96/flowpywr/blob/wip3/components/mapSideBar.tsx"
click node_mapstate "https://github.com/ibrahimm96/flowpywr/blob/wip3/contexts/MapContext.tsx"
click node_map "https://github.com/ibrahimm96/flowpywr/blob/wip3/components/map.tsx"
click node_markers "https://github.com/ibrahimm96/flowpywr/blob/wip3/hooks/useAddMarkers.tsx"
click node_flow "https://github.com/ibrahimm96/flowpywr/blob/wip3/hooks/useShowFlow.tsx"
click node_boundaries "https://github.com/ibrahimm96/flowpywr/blob/wip3/hooks/useAddBoundaries.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_home,node_authpage,node_auth,node_supabase,node_sidebar,node_visitor toneBlue
class node_modeldata,node_loader,node_staticmodels toneAmber
class node_modelview,node_mapcontrols,node_mapstate,node_map,node_markers,node_flow,node_boundaries toneMint
class node_upload,node_analysis toneRose
class node_mapbox toneIndigo
```

## Components

### Access and navigation

- [Home page](https://github.com/ibrahimm96/flowpywr/blob/wip3/app/page.tsx): `app/page.tsx`
- [Sign-in page](https://github.com/ibrahimm96/flowpywr/blob/wip3/app/auth/page.tsx): `app/auth/page.tsx`
- [Auth context](https://github.com/ibrahimm96/flowpywr/blob/wip3/contexts/AuthContext.tsx): `contexts/AuthContext.tsx`
- [Supabase client](https://github.com/ibrahimm96/flowpywr/blob/wip3/lib/supabase.tsx): `lib/supabase.tsx`
- [App navigation](https://github.com/ibrahimm96/flowpywr/blob/wip3/components/sidebar.tsx): `components/sidebar.tsx`

### Model data

- [Model data context](https://github.com/ibrahimm96/flowpywr/blob/wip3/contexts/ModelDataContext.tsx): `contexts/ModelDataContext.tsx`
- [Model JSON loader](https://github.com/ibrahimm96/flowpywr/blob/wip3/hooks/useGetModelData.tsx): `hooks/useGetModelData.tsx`
- **Static model JSON**

### Map visualization

- [Model visualization page](https://github.com/ibrahimm96/flowpywr/blob/wip3/app/model-visualization/page.tsx): `app/model-visualization/page.tsx`
- [Map controls](https://github.com/ibrahimm96/flowpywr/blob/wip3/components/mapSideBar.tsx): `components/mapSideBar.tsx`
- [Map context](https://github.com/ibrahimm96/flowpywr/blob/wip3/contexts/MapContext.tsx): `contexts/MapContext.tsx`
- [Interactive map](https://github.com/ibrahimm96/flowpywr/blob/wip3/components/map.tsx): `components/map.tsx`
- [Node markers](https://github.com/ibrahimm96/flowpywr/blob/wip3/hooks/useAddMarkers.tsx): `hooks/useAddMarkers.tsx`
- [Flow rendering](https://github.com/ibrahimm96/flowpywr/blob/wip3/hooks/useShowFlow.tsx): `hooks/useShowFlow.tsx`
- [Map boundaries](https://github.com/ibrahimm96/flowpywr/blob/wip3/hooks/useAddBoundaries.tsx): `hooks/useAddBoundaries.tsx`

### Model operations

- [Model upload page](https://github.com/ibrahimm96/flowpywr/blob/wip3/app/upload/page.tsx): `app/upload/page.tsx`
- [Analysis page](https://github.com/ibrahimm96/flowpywr/blob/wip3/app/analysis/page.tsx): `app/analysis/page.tsx`

### Other components

- **App user**
- **Mapbox GL**

## Connections

- App user → Home page: opens (evidence: `app/page.tsx`)
- App user → Sign-in page: opens
- App user → Model visualization page: opens
- App user → Model upload page: opens
- App user → Analysis page: opens
- Home page → Auth context: checks loading (evidence: `app/page.tsx`)
- Sign-in page → Supabase client: uses auth (evidence: `app/auth/page.tsx`)
- Auth context → Supabase client: reads session (evidence: `contexts/AuthContext.tsx`)
- App navigation → Auth context: reads user (evidence: `components/sidebar.tsx`)
- App navigation → Supabase client: uses client (evidence: `components/sidebar.tsx`)
- Model visualization page → Interactive map: renders (evidence: `app/model-visualization/page.tsx`)
- Model visualization page → Map controls: renders (evidence: `app/model-visualization/page.tsx`)
- Model data context → Model JSON loader: loads via (evidence: `contexts/ModelDataContext.tsx`)
- Model JSON loader → Static model JSON: fetches JSON (evidence: `hooks/useGetModelData.tsx`)
- Map controls → Map context: updates filters (evidence: `components/mapSideBar.tsx`)
- Interactive map → Model data context: reads models (evidence: `components/map.tsx`)
- Interactive map → Map context: reads settings (evidence: `components/map.tsx`)
- Interactive map → Node markers: adds markers (evidence: `components/map.tsx`)
- Interactive map → Flow rendering: renders flows (evidence: `components/map.tsx`)
- Interactive map → Map boundaries: adds boundaries (evidence: `components/map.tsx`)
- Node markers → Map context: sets selection (evidence: `hooks/useAddMarkers.tsx`)
- Interactive map → Mapbox GL: configures map (evidence: `components/map.tsx`)
