How omkar0816/hydrosnap-3d works
HydroSnap 3D is a browser-based watershed field-evidence and monitoring prototype for geo-coded photos, watershed boundaries, and satellite indicators; its demo records and analysis are illustrative, and no backend or database is connected. The main workflow begins when a field officer uses the browser app to prepare and save an observation: the app checks evidence and location in the client, stores the observation locally, and attempts to sync it when online. Other user workflows inspect watersheds and assets, view dashboard/map analytics, and generate exports or inspection PDFs.
Components
Browser app and user workflows
• Browser entry point — src/main.tsx: mounts the React application and imports its global styles.
• Routes and shared app state — src/App.tsx: defines route entry points for dashboard, map, upload, asset passport, and workspace views, plus shared watershed, layer, and notification state.
• Upload and evidence capture — src/pages/ImageUploadPage.tsx: provides the field-observation workflow, including image metadata/GPS handling and officer-confirmed location; the excerpt shows client trust assessment and save-oriented UI.
• Dashboard and workspace screens — src/pages/DashboardPage.tsx: implements the dashboard; src/pages/WorkspacePage.tsx groups workspace sections such as evidence, interventions, reports, and administration.
• Asset passport and inspection report — src/pages/AssetPassportPage.tsx: presents an asset’s inspection history and uses the report-PDF utility.
• Map analysis screen — src/pages/MapAnalysisPage.tsx: composes map analysis, timeline, watershed details, and export functionality.
• Map rendering and interaction — src/components/maps/WatershedMap.tsx: renders watershed and asset layers with MapLibre, optional PMTiles boundaries, basemaps, and measurement tools.
• Shared map detail and timeline UI — src/components/maps/WatershedPanel.tsx: shows selected-watershed details; src/components/maps/MapTimeline.tsx renders timeline controls.
• App shell and sync UI — src/components/layout/AppLayout.tsx: provides the shared shell; src/components/sync/SyncIndicator.tsx presents queue/sync status and controls.
• Trust explanation UI — src/components/evidence/TrustPanel.tsx: displays trust status and reasons.
Data access, persistence, and integration
• Query and mutation hooks — src/hooks/useHydroSnap.ts: exposes React Query reads and mutations for users, watersheds, assets, observations, analysis, interventions, and reports.
• Domain data service — src/services/hydrosnapService.ts: centralizes data I/O, selects mock or API behavior, and handles local-first observation saves.
• Demo records — src/services/mock/mockData.ts: holds the separately maintained demo data used by mock-mode reads.
• HTTP client — src/services/apiClient.ts: performs configured REST requests and converts non-success responses to ApiError.
• Offline queue — src/services/offlineStore.ts: persists queued observations in browser IndexedDB.
• Sync orchestration — src/services/syncService.ts: claims eligible queue records, uploads them, updates retry/sync state, and supports sync listeners.
• Domain and GeoJSON types — src/types/domain.ts: defines observations, assets, watersheds, trust assessments, sync state, and analysis types; src/types/geojson.ts defines the geometric structures they use.
• Environment selection — src/config/env.ts: reads API, mock-mode, and optional watershed-PMTiles settings.
Spatial analysis, evidence, and outputs
• Spatial operations — src/utils/geo.ts: implements coordinate validation, point-in-watershed resolution, geometry bounds, distances, and nearest-stream calculations.
• Evidence trust rules — src/utils/trust.ts: evaluates evidence consistency and produces a client-side trust assessment.
• Asset matching and watershed summaries — src/utils/assetMatch.ts matches nearby assets; src/utils/watershedStats.ts computes per-watershed counts.
• Timeline calculations — src/utils/timeline.ts: prepares timeline data used by map views.
• Exports and inspection PDF — src/utils/exporters.ts provides GeoJSON, CSV, and audit JSON exports; src/utils/reportPdf.ts generates a browser-side inspection PDF.
Data preparation
• Watershed boundary preparation — scripts/prepare_watersheds/prepare_watersheds.py: prepares real boundary data for PMTiles use, as documented in the README.
• Satellite-index pipeline fixture — scripts/compute_indices/compute_indices.py: computes NDVI/NDWI analysis for the documented pipeline fixture; the README cautions that this is not a real asset result.
Relationships
• Field officer -> Browser app and user workflows: initiates observation entry; evidence: README.md
• Browser app entry point -> Routes and shared app state: renders the application; evidence: src/main.tsx
• Routes and shared app state -> Upload and evidence capture: routes /upload to the upload page; evidence: src/App.tsx
• Routes and shared app state -> Dashboard and workspace screens: routes / and workspace paths to their screens; evidence: src/App.tsx
• Routes and shared app state -> Asset passport and inspection report: routes /assets/:assetId; evidence: src/App.tsx
• Routes and shared app state -> Map analysis screen: routes /map; evidence: src/App.tsx
• Upload and evidence capture -> Query and mutation hooks: uses the data hook; evidence: src/pages/ImageUploadPage.tsx
• Map analysis screen -> Query and mutation hooks: uses the data hook; evidence: src/pages/MapAnalysisPage.tsx
• Asset passport and inspection report -> Query and mutation hooks: uses the data hook; evidence: src/pages/AssetPassportPage.tsx
• Query and mutation hooks -> Domain data service: binds reads and mutations to service methods; evidence: src/hooks/useHydroSnap.ts
• Domain data service -> Demo records: uses demo collections in mock mode; evidence: src/services/hydrosnapService.ts
• Domain data service -> Offline queue: enqueues locally saved observations and reads queued records; evidence: src/services/hydrosnapService.ts
• Domain data service -> Sync orchestration: triggers sync after saving when online; evidence: src/services/hydrosnapService.ts
• Domain data service -> HTTP client: uses API requests when mock mode is disabled; evidence: src/services/hydrosnapService.ts
• Sync orchestration -> Offline queue: reads, claims, and updates queued records; evidence: src/services/syncService.ts
• Sync orchestration -> HTTP client: posts observations to the uploads endpoint outside mock mode; evidence: src/services/syncService.ts
• Upload and evidence capture -> Evidence trust rules: computes a trust preview for confirmed evidence; evidence: src/pages/ImageUploadPage.tsx
• Upload and evidence capture -> Spatial operations: uses location conversion and spatial helpers; evidence: src/pages/ImageUploadPage.tsx
• Map rendering and interaction -> Spatial operations: uses geometry bounds, distance, and center calculations; evidence: src/components/maps/WatershedMap.tsx
• Asset passport and inspection report -> Exports and inspection PDF: uses the PDF utility; evidence: src/pages/AssetPassportPage.tsx
• Map analysis screen -> Timeline calculations: uses timeline utilities; evidence: src/pages/MapAnalysisPage.tsx
Coverage limits
The repository and README describe a frontend-only prototype, not a deployed backend. The API’s server-side behavior, authentication, production persistence, and real satellite-monitoring operation are not established by these inputs. Script excerpts establish the existence of preparation and index-computation tools, but not their runtime connection to the app. Several source excerpts are partial, so relationships not shown above may exist.
Main entry points: App.tsx Routes and app state · hydrosnapService.ts HydroSnap service · ImageUploadPage.tsx Evidence capture · useHydroSnap.ts Query and mutation hooks
Components 18
Browser workflows
- Browser entry
src/main.tsx - Routes and app state
src/App.tsx - Evidence capture · Client-side evidence and location checks; observation save is local-first.
src/pages/ImageUploadPage.tsx - Dashboard and workspace
src/pages/DashboardPage.tsx - Asset passport
src/pages/AssetPassportPage.tsx - Map analysis
src/pages/MapAnalysisPage.tsx
Data and sync
- Query and mutation hooks
src/hooks/useHydroSnap.ts - HydroSnap service · Selects mock or API behavior and handles local-first observation saves.
src/services/hydrosnapService.ts - Demo records · Illustrative records used by mock-mode reads.
src/services/mock/mockData.ts - Offline queue · Stores queued observations in the browser.
src/services/offlineStore.ts - Sync orchestration
src/services/syncService.ts - HTTP client · API server-side behavior and production persistence are not established.
src/services/apiClient.ts
Spatial and evidence
- Evidence trust rules
src/utils/trust.ts - Spatial operations
src/utils/geo.ts - Map rendering · Renders watershed and asset layers with optional PMTiles boundaries.
src/components/maps/WatershedMap.tsx - Inspection PDF
src/utils/reportPdf.ts - Timeline calculations
src/utils/timeline.ts
Other components
- Field officer
Connections 21
- Field officer → Browser entry: starts observation
README.md - Browser entry → Routes and app state: renders app
src/main.tsx - Routes and app state → Evidence capture: routes to
src/App.tsx - Routes and app state → Dashboard and workspace: routes to
src/App.tsx - Routes and app state → Asset passport: routes to
src/App.tsx - Routes and app state → Map analysis: routes to
src/App.tsx - Evidence capture → Query and mutation hooks: uses data hooks
src/pages/ImageUploadPage.tsx - Map analysis → Query and mutation hooks: uses data hooks
src/pages/MapAnalysisPage.tsx - Asset passport → Query and mutation hooks: uses data hooks
src/pages/AssetPassportPage.tsx - Query and mutation hooks → HydroSnap service: calls service
src/hooks/useHydroSnap.ts - HydroSnap service → Demo records: uses mock data
src/services/hydrosnapService.ts - HydroSnap service → Offline queue: queues observations
src/services/hydrosnapService.ts - HydroSnap service → Sync orchestration: triggers sync
src/services/hydrosnapService.ts - HydroSnap service → HTTP client: uses API client
src/services/hydrosnapService.ts - Sync orchestration → Offline queue: reads and updates
src/services/syncService.ts - Sync orchestration → HTTP client: uploads observations
src/services/syncService.ts - Evidence capture → Evidence trust rules: assesses evidence
src/pages/ImageUploadPage.tsx - Evidence capture → Spatial operations: uses spatial helpers
src/pages/ImageUploadPage.tsx - Map rendering → Spatial operations: uses geometry helpers
src/components/maps/WatershedMap.tsx - Asset passport → Inspection PDF: generates report
src/pages/AssetPassportPage.tsx - Map analysis → Timeline calculations: uses timeline utilities
src/pages/MapAnalysisPage.tsx