Learning Enhanced Watershed Assessment System (LEWAS) Lab
Virginia Tech - Environmental Data Visualization Platform
🔗 Access the Dashboard: https://lewas.vercel.app/
The LEWAS Frontend is a modern, responsive web application that provides real-time visualization and analysis of environmental monitoring data from the Webb Branch watershed. Built with Next.js and D3.js, it offers researchers, students, and the public an intuitive interface to explore water quality, flow dynamics, and weather data collected 24/7 from sophisticated sensors.
🔗 Related Projects: This frontend connects to the LEWAS Backend API for data and integrates with the LEWAS AI Chatbot for natural language queries.
- Real-time Charts: Live updating graphs with D3.js
- Multi-parameter Display: Overlay up to 3 different measurements
- Time Range Controls: From 12 hours to 12 days of data
- Unit System Toggle: Switch between SI and US Imperial units
- Responsive Design: Works on desktop, tablet, and mobile
- pH Level: Water acidity/alkalinity measurement
- Dissolved Oxygen: Critical for aquatic ecosystem health
- Water Temperature: Thermal monitoring with unit conversion
- Turbidity: Water clarity in Nephelometric Turbidity Units
- Specific Conductance: Electrical conductivity measurement
- Salinity: Salt content in parts per thousand
- ORP: Oxidation Reduction Potential in millivolts
- Stage: Water level with datum offset correction
- Flow Rate: Estimated volumetric flow using advanced algorithms
- Smoothed Velocity: Processed water speed with noise reduction
- Downstream Velocity: Raw velocity measurements
- Air Temperature: Atmospheric temperature with unit conversion
- Humidity: Relative humidity percentage
- Air Pressure: Barometric pressure with altitude correction
- Rain Intensity: Real-time precipitation rate
- Rain Accumulation: Cumulative rainfall totals
- Rain Duration: Duration of precipitation events
- Real-time Processing: Applies the same scientific algorithms used in research
- Stage Correction: Datum offset adjustments for accurate water levels
- Velocity Smoothing: Adaptive alpha filtering for cleaner velocity data
- Flow Rate Calculation: Cubic polynomial conversion from velocity measurements
- Pressure Correction: Altitude-adjusted atmospheric pressure readings
- Node.js 18+ installed
- Access to LEWAS Backend API
- Modern web browser
- Clone the repository
git clone https://github.com/lewaslab/lewas-frontend
cd lewas-frontend
- Install dependencies
npm install
- Configure environment variables
# Create .env file from the .env.example file
NEXT_PUBLIC_API_URL=<BACKEND URL>
NEXT_PUBLIC_API_KEY=<BACKEND API KEY>
- Run development server
npm run dev
- Access the application Open http://localhost:3000 in your browser
# Build for production
npm run build
# Start production server
npm run start
# Or export static files
npm run build && npm run export
- Framework: Next.js 15.2.4 (React 19)
- Visualization: D3.js 7.9.0 for advanced charting
- Data Processing: Custom algorithms matching research standards
- Deployment: Static export compatible with any hosting platform
src/
├── components/
│ ├── Layout.js # Main layout with navigation
│ ├── RawDataDisplay.js # Debug data visualization
│ └── SensorTable.js # Tabular data display
├── pages/
│ ├── index.js # Landing page with overview
│ ├── live-data.js # Main interactive dashboard
│ ├── team.js # Research team information
│ ├── chatbot.js # AI assistant integration
├── services/
│ └── api.js # Backend API integration
├── utils/
│ └── dataProcessor.js # Scientific data processing
└── styles/
└── globals.css # Global styling and themes
- Navigate to the Live Creek Data page
- Select your preferred unit system (SI or US Imperial)
- Choose a time range for data display
- Configure up to 3 parameters for simultaneous viewing
- Axis 1 (Blue): Primary measurement, always visible
- Axis 2 (Red): Secondary measurement, toggleable
- Axis 3 (Green): Tertiary measurement, toggleable
- Interactive Tooltips: Hover over data points for detailed information
- Zoom and Pan: Explore specific time periods in detail
- Real-time Updates: Click "Update Chart" for latest data
- Multi-scale Display: Different Y-axes for parameters with different ranges
- Past 12 Hours: High-resolution recent data
- Past 3 Days: Short-term trend analysis
- Past 6 Days: Weekly pattern observation
- Past 12 Days: Extended trend monitoring
// src/services/api.js
export const ApiService = {
baseURL: `${process.env.NEXT_PUBLIC_API_URL}/v1/sensors`,
apiKey: process.env.NEXT_PUBLIC_API_KEY,
// ... additional configuration
};
The application maps frontend parameters to backend API calls:
// Example parameter configuration
export const PARAMETER_CONFIG = {
water_temperature: {
metric: "temperature",
medium: "water",
instrument: "sonde",
processing: "none",
},
stage: {
metric: "velocity-z",
medium: "water",
instrument: "argonaut",
processing: "stage_correction",
},
// ... more parameters
};
The frontend replicates research-grade processing:
// Stage correction example
if (param === "water/velocity-z") {
for (let i in response.data) {
response.data[i].y = response.data[i].y + 0.128; // Datum offset
}
}
// Velocity smoothing example
for (let i = 1; i < response.data.length; i++) {
const absValue = Math.abs(response.data[i].y);
const alpha = Math.min(Math.max(absValue, 24.5) - 23, 30) / 30;
response.data[i].y =
(1 - alpha) * response.data[i - 1].y + alpha * response.data[i].y;
}
- Update Parameter Config: Add to
PARAMETER_CONFIG
inapi.js
- Add to Dropdown Options: Update
parameterOptions
inlive-data.js
- Configure Processing: Add processing logic if needed
- Update Labels: Add user-friendly labels and units
The D3.js integration allows for custom chart types:
// Example: Adding a new chart type
const customChart = d3
.select(container)
.append("svg")
.attr("width", width)
.attr("height", height);
// Add your custom visualization logic
The frontend seamlessly integrates with the LEWAS Backend API:
// Real-time data fetching
const fetchParameterData = async (parameterType, startTime, endTime) => {
const response = await ApiService.fetchParameterData(
config,
startTime,
endTime
);
return dataProcessor.processParameterData(
response.observations,
parameterType,
unitSystem
);
};
Links to the LEWAS Chatbot for natural language data queries:
- Direct link to Streamlit chatbot application
- Contextual help and example questions
- Seamless user experience between platforms
- API Integration: Add new endpoints in
services/api.js
- Data Processing: Extend
utils/dataProcessor.js
for new algorithms
# Build static files
npm run build
# Serve static files
npx serve@latest exportable
- GitHub Pages: Free hosting for static sites
- Vercel: Optimal for Next.js applications
- Netlify: Great for static sites with forms
- AWS S3 + CloudFront: Scalable cloud hosting
- Virginia Tech Servers: Internal hosting option
- Real-time Data: Current environmental conditions for class discussions
- Historical Analysis: Trend analysis for research projects
- Interactive Learning: Hands-on data exploration
- Cross-disciplinary: Supports environmental, engineering, and data science courses
- Publication-ready Visualizations: High-quality charts for papers
- Hypothesis Testing: Visual correlation analysis
- API keys stored in environment variables
- HTTPS-only communication
- No personal data collection
- Environmental data only
- Transparent data usage
- Research compliance standards
- Technical Issues: Submit GitHub issues
- Educational Use: Contact Dr. Vinod Lohani ([email protected])
- Development: Contact Dhruv Varshney ([email protected]) | LinkedIn
This project is part of the LEWAS Lab research initiative at Virginia Tech.
Dhruv Varshney | LEWAS Lab | Virginia Tech | Real-time Environmental Data Since 2010
Making environmental data accessible through innovative visualization and interactive technologies.