How zengroot147/groundwater-potential-zone-identification works
1. What this repository is
- A groundwater potential prediction application with two main runtime layers: a Python/Flask backend and a React/TypeScript frontend.
- The webapp/ folder appears to be the primary integrated app; the top-level frontend/ directory is a near-duplicate React client and likely a parallel/extracted copy.
2. Primary runtime boundary
- Browser users interact with the React SPA.
- The SPA sends API calls to the Flask service on port 5000.
- The backend returns predictions, statistics, map bounds, borewell estimates, reports, and overlay assets.
3. Backend architecture
- The core server is webapp/app_hybrid.py.
- It exposes endpoints under /api/ for:
- groundwater prediction by coordinates
- analytics/statistics
- map boundary metadata
- borewell depth prediction
- PDF/report generation
- It also serves the groundwater overlay image (gwp_overlay.png), and CORS is enabled so the frontend can call it cross-origin during development.
4. Backend responsibilities
- The README indicates the backend does the domain-heavy work:
- reads/uses the groundwater map overlay
- computes environmental features such as NDVI, NDWI, and elevation from coordinates
- integrates weather data
- produces dashboard statistics
- This is the main computation and data-access boundary in the system.
5. Frontend architecture
- The frontend is a single-page app built with React 18, TypeScript, Vite, TailwindCSS, React Router, Leaflet/react-leaflet, Chart.js, Framer Motion, and Axios.
- It is organized around pages such as:
- LandingPage
- MapViewer
- Dashboard
- About
- BatchAnalysis
- ExplainableAI
- LocationComparison
- AdvancedFeatures
6. Frontend feature boundaries
- InteractiveMap is the map-centric component and is the main spatial interaction surface.
- Navbar, HeroVisual, StatsBar, and DataSourcesStrip support the landing/dashboard experience.
- The app is presentation-heavy, but all real prediction logic is delegated to the backend through HTTP calls.
7. Core data flow
- User selects a point on the map or enters coordinates.
- Frontend sends the coordinates to the Flask API.
- Backend processes the location against geospatial/environmental inputs and returns a groundwater classification plus derived metrics.
- The frontend renders the result in the map view and dashboard charts.
8. Geospatial and scientific assets
- The repo includes multiple data files that likely feed preprocessing or offline analysis:
- raster imagery: .tif, .jp2
- vector GIS layers: .shp, .shx, .dbf, .prj
- climate/model data: .nc
- sample inputs: sample_batch_locations.csv
- notebooks/scripts for analysis: Groundwater.ipynb, debug_coordinates.py, get_coordinates.py
- These assets are central to the domain model even though the live app exposes them through the backend.
9. Legacy / alternate UI paths
- webapp/templates/ contains old Flask-rendered HTML pages, but the README says those routes were removed in favor of the React SPA.
- Several backup versions exist for the map page (MapViewer_backup.tsx, MapViewer_old.tsx) and landing page.
- This suggests an evolution from server-rendered pages to a client-rendered SPA with API-backed data.
10. Build and deployment shape
- Frontend development uses Vite; built artifacts are checked in under frontend/dist and webapp/frontend/dist.
- Python dependencies live in webapp/requirements.txt.
- Windows startup scripts (START_ALL_SERVERS.bat, start.bat, start.ps1) indicate the app is intended for local desktop launch with separate backend/frontend terminals.
11. What to draw in an architecture diagram
- Show three main boxes:
- Browser / React SPA
- Flask API backend
- Geospatial/data assets and analysis inputs
- Draw request/response arrows from SPA to Flask.
- Draw backend-to-data arrows to the overlay image, raster/vector datasets, and any weather/API integration.
- Treat report generation and analytics as backend subflows, not separate services.
12. Important architectural takeaway
- This is not a generic web app: it is a GIS/ML-style decision support system where the frontend is mostly an interactive visualization layer, and the backend owns the actual groundwater inference and data processing.
Main entry points: app_hybrid.py Flask API · main.tsx Routing · App.tsx React SPA · InteractiveMap.tsx Map view
Components 20
Client app
React single-page application used by browser users
- Browser · End users interact with the SPA in the browser
- React SPA · Primary TypeScript single-page application
webapp/frontend/src/App.tsx - Routing · Routes between landing, map, dashboard, and feature pages
webapp/frontend/src/main.tsx - Map view · Interactive mapping and coordinate selection surface
webapp/frontend/src/components/InteractiveMap.tsx - Dashboard · Charts and summary panels for predictions and statistics
webapp/frontend/src/pages/Dashboard.tsx - Landing UI · Entry experience with hero, nav, and summary components
webapp/frontend/src/pages/LandingPage.tsx - Feature pages · Batch analysis, explainable AI, comparison, and advanced features pages
webapp/frontend/src/pages/BatchAnalysis.tsx - HTTP client · Browser-side calls to the Flask API
API backend
Flask service that computes groundwater results and serves assets
- Flask API · Core server that exposes groundwater prediction and metadata endpoints
webapp/app_hybrid.py - Prediction API · Coordinate-based groundwater classification and derived metrics
webapp/app_hybrid.py - Analytics API · Statistics, dashboard summaries, and map boundary metadata
webapp/app_hybrid.py - Report API · Borewell estimates and PDF/report generation endpoints
webapp/app_hybrid.py - Overlay asset · Groundwater overlay imagery served by the backend
- CORS / static · Cross-origin access and static asset serving for the SPA
webapp/app_hybrid.py - Legacy templates · Old Flask HTML pages retained as legacy paths
webapp/templates/index.html
Data and analysis
Geospatial layers, models, and offline analysis inputs
- Geospatial rasters · Raster inputs used for terrain, climate, and environmental context
out.tif - GIS vectors · District and boundary shapefiles used for spatial context
District.shp - Climate model · NetCDF climate or model input used by the backend
rf_1deg_dec_clm.nc - Sample inputs · CSV sample locations and batch-analysis inputs
sample_batch_locations.csv - Notebook analysis · Exploratory groundwater analysis and feature experimentation
Groundwater.ipynb
Connections 22
- Browser → React SPA: uses · Users interact with the application through the React SPA
- React SPA → Routing: routes · SPA routes to pages and feature views
- Routing → Map view: opens · One major route centers on interactive map workflows
- Routing → Dashboard: opens · One major route shows prediction summaries and charts
- Routing → Landing UI: opens · Landing pages provide entry and overview content
- Routing → Feature pages: opens · Additional pages expose advanced workflows
- Map view → HTTP client: requests · Map interactions trigger backend lookup and prediction calls
- Dashboard → HTTP client: requests · Dashboard fetches analytics and statistics from the API
- Feature pages → HTTP client: requests · Advanced workflows rely on API-backed inference and reports
- HTTP client → Flask API: calls · Frontend communicates with the Flask service
- Flask API → Prediction API: exposes · Prediction endpoints implement the main groundwater inference flow
- Flask API → Analytics API: exposes · Analytics endpoints provide summaries and map metadata
- Flask API → Report API: exposes · Report and borewell endpoints support decision workflows
- Flask API → Overlay asset: serves · Backend serves overlay imagery used by the map UI
- Flask API → CORS / static: enables · CORS and static serving make SPA-backend integration work
- Prediction API → Geospatial rasters: uses · Predictions incorporate raster-derived environmental features
- Prediction API → GIS vectors: uses · Predictions use district and boundary layers for spatial context
- Prediction API → Climate model: uses · Predictions may incorporate climate/model inputs
- Analytics API → Overlay asset: summarizes · Analytics and map metadata are tied to overlay context
- Report API → Sample inputs: uses · Batch and report workflows consume sample location data
- Sample inputs → Notebook analysis: feeds · Offline notebooks and scripts support analysis and experimentation
- Legacy templates → Flask API: legacy path · Old server-rendered pages were replaced by the SPA