
RainBank Flex: turning monsoon rain into a year-round water plan on AWS
In many Indian cities the same story repeats every year. In July, heavy rain floods the streets and most rooftop water runs into the drains. By May, groundwater has dropped and families are paying for tankers. The issue is often not that there is no water. It’s that there’s too much rain at the wrong time and not enough storage for the dry months.
What RainBank Flex does
You pick a city and enter your roof area, tank size and daily water use. RainBank Flex replays the last five years of real daily rainfall, one year at a time, and simulates the tank day by day. It then compares a typical year with the driest year and recommends a tank size.
For example, with a 120 m² roof, a 5,000 litre tank and 400 litres of daily use in Bengaluru, a typical year in our data captured about 101,650 litres of rain, but the tank still ran empty on 171 days. In the driest of the five years, it ran empty on 233 days. Tank size matters, but only up to a point. After 5,000 litres, a bigger tank barely changed the dry-year result in this setup.
We chose to simulate each year separately instead of averaging them. Averaging every 15 July across years turns a few heavy storms into light drizzle every day, so the tank would never overflow. The daily bursts are the whole story, so we kept them.
There’s also a Data Center mode. Its message is deliberately honest: rain captured is not rain you can store and use. A big roof can catch a lot of water in one storm, but a tank can only hold so much, so rain can offset only part of the cooling-water demand.
How we used AWS
The flow is simple. A browser loads the site from AWS Amplify Hosting. The page sends the user’s inputs to Amazon API Gateway, which triggers an AWS Lambda function. The Lambda reads five years of daily rainfall from Amazon DynamoDB, or downloads it from the free Open-Meteo weather API the first time a city is requested and saves it. It runs the simulation, picks the recommended tank, saves the run, and returns the result. Amazon CloudWatch Logs records every call.
- AWS Amplify Hosting serves the web app at a public link.
- Amazon API Gateway (HTTP API) exposes
POST /simulate, with CORS turned on.
- AWS Lambda (Node.js) runs the simulation and the tank-size rule.
- Amazon DynamoDB (on-demand) caches rainfall history per location and stores each scenario.
- Amazon CloudWatch Logs shows what each request did.
The Lambda uses the AWS SDK for JavaScript v3 to talk to DynamoDB. The code also contains an optional Amazon Bedrock call for an AI-written explanation, but we kept it switched off for cost reasons, so the advisor uses a built-in text template.
One design choice we like: the tank recommendation is calculated by code with a clear rule (the smallest tank where the next size cuts dry-year empty days by less than 5%). If Bedrock is turned on, it only explains the result and can’t change the number.
What went wrong, and what we learned
Our region was locked. Our account was on the Free plan and was assigned the Sydney region, even though our event is in India. The console told us we’d need to upgrade for other regions. We stayed in Sydney, since nothing in the app depends on the region, and we learned to check the region in the address bar of every AWS page.
Our first Lambda test failed in exactly 3 seconds. That’s the default timeout, and the first request had to download five years of rainfall. After raising the timeout to 30 seconds and the memory to 512 MB, it worked. The second run for the same city took about 46 milliseconds, because the data now came from DynamoDB. It’s a nice demonstration of why we added a cache.
CORS needed one extra click. In API Gateway we typed
* as the allowed origin but didn’t press Add, so the console still said “No Origins are allowed”. Small detail, big difference for a website calling an API.We couldn’t find the Invoke URL. We built the address from the API ID, the region and the route, and it worked.
What we’d do next
If we continue this project, we’d add a seven-day forecast, rain alerts such as “tank nearly full”, multiple languages and a map view. We’d also turn on Bedrock for the explanations once we’re sure about cost.
Rainwater harvesting won’t solve a city’s water crisis by itself, and our results are estimates, not guarantees. Rainwater also needs treatment and testing before anyone drinks it. But a planning tool that shows when a tank will fill, overflow or run dry can turn “should we install a tank?” into an answer with numbers behind it.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article