Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚙️ Rainwater Harvesting – Backend API (rainwaterharvesting_server)

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/


🚀 Features

  • ⏱️ 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

🛠️ Tech Stack

Layer Technology
Server Node.js + Express
Realtime Socket.IO
Database MongoDB + Mongoose
Scheduling setInterval + Logic
Deployment Render

📦 Getting Started

1. Clone the Repository

git clone https://github.com/subramanyamchoda/rainwaterharvesting_server.git
cd rainwaterharvesting_server

2. Install Dependencies

npm install

3. Environment Variables

Create a .env file in the root:

PORT=5000
MONGODB_URI=your-mongodb-uri
FRONTEND_ORIGIN=http://localhost:5173

🔐 Replace your-mongodb-uri with your actual MongoDB Atlas connection string.

4. Start the Server

npm run dev

Server will run at: http://localhost:5000


🔁 Real-Time Simulation Logic

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.


🧪 API Endpoints Overview

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.


🤝 Contributing

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/YourFeature

🙌 Acknowledgments

This 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

🌐 Related Projects

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 🌧️⚡

About

Rainwater Harvesting – Backend API A real-time simulation server that models rainwater collection, flow dynamics, and electricity generation. Built with Node.js, Express, MongoDB, and Socket.IO, it streams live sensor data every 5 seconds to power a dynamic environmental dashboard.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages