This is the Backend Server for the Rainwater Harvesting Dashboard 🌧️⚡ — a full-stack simulation that visualizes the process of rainwater collection, flow dynamics, turbine RPM, electricity generation, and battery charging.
🔗 Live API: https://rainwaterharvestingserver.onrender.com/
- ⏱️ Simulates environmental sensor data every 5 seconds
- 💧 Tracks tank level, flow rate, turbine RPM, electricity output, and battery storage
- 📡 Streams live data to frontend using Socket.IO
- 🗃️ Stores simulation logs in MongoDB Atlas
- ⚙️ Configurable refresh rate and thresholds
| Layer | Technology |
|---|---|
| Server | Node.js + Express |
| Realtime | Socket.IO |
| Database | MongoDB + Mongoose |
| Scheduling | setInterval + Logic |
| Deployment | Render |
git clone https://github.com/subramanyamchoda/rainwaterharvesting_server.git
cd rainwaterharvesting_servernpm installCreate a .env file in the root:
PORT=5000
MONGODB_URI=your-mongodb-uri
FRONTEND_ORIGIN=http://localhost:5173🔐 Replace
your-mongodb-uriwith your actual MongoDB Atlas connection string.
npm run devServer will run at: http://localhost:5000
Every 5 seconds:
- Simulates tank water levels (fill/drain)
- Calculates water flow rate
- Computes turbine RPM (capped at 1500 RPM)
- Derives power output (electricity generation)
- Updates battery storage levels
Data is streamed via Socket.IO to the client for real-time chart updates.
| Endpoint | Description |
|---|---|
/api/simulation/start |
Initiate simulation cycle (internal) |
/api/simulation/data |
Get latest simulation values |
/api/logs |
Fetch log of historical records |
Most communication is real-time over WebSockets.
We welcome all contributions!
# Fork the repository
# Create your feature branch
git checkout -b feature/YourFeature
# Commit your changes
git commit -m "Add YourFeature"
# Push and open a PR
git push origin feature/YourFeatureThis backend server was developed to:
- Learn WebSocket communication via Socket.IO
- Simulate environmental systems in a backend loop
- Stream and store data in real-time
- Support frontend dashboards with live insights
| Project | Link |
|---|---|
| 🌿 Frontend Client | https://pandarainwaterharvesting.vercel.app/ |
| 🧑💻 GitHub Repo | https://github.com/subramanyamchoda/rainwaterharvesting_server |
Thanks for checking out the backend! ⚙️ Feel free to clone, fork, and contribute 🌧️⚡