A web-based AI assistant for analyzing water quality data using Google Gemini.
Designed to support SDG 6: Clean Water and Sanitation
WaterAI is a lightweight web application that uses the Gemini AI API to analyze water quality parameters based on WHO standards. With a modern UI and intelligent backend, it delivers:
- Overall water quality assessment
- Risk level estimation
- Recommendations and solutions
- SDG 6 alignment
All of this β through a single-page interface and a Flask backend.
- π Real-time water data input and visualization
- π§ͺ AI-driven water quality analysis
β οΈ Detection of key issues and health risks- π‘ Actionable short/long-term solutions
- π― SDG 6 (Clean Water and Sanitation) alignment
- π Fully responsive dark/light theme switcher
| Layer | Technology |
|---|---|
| π§ AI Engine | Google Gemini |
| βοΈ Backend | Flask + Python 3.11 |
| π Frontend | HTML5, CSS3, Vanilla JS |
| π Hosting | Render / Localhost |
WaterAI/
βββ app.py # Flask backend + Gemini integration
βββ templates/
β βββ index.html # Frontend form UI
βββ .env # API key (not committed)
βββ requirements.txt # Python dependencies
βββ README.md # You're reading it
- Python 3.11+
- A free API key from Google AI Studio
# 1. Clone the repository
git clone https://github.com/Ishan0121/WaterAI.git
cd WaterAI
# 2. Create virtual environment
python -m venv .venv
source .venv/bin/activate # For Windows: .venv\Scripts\activate.ps1
# 3. Install dependencies
pip install -r requirements.txt
# 4. Create .env file and add your Gemini API key
echo "GEMINI_API_KEY=your_google_gemini_api_key" > .env
# 5. Run the application
python app.pyVisit http://localhost:5000 in your browser.
- Push this repo to GitHub
- Create a Render Web Service
- Add your
GEMINI_API_KEYas an environment variable - Set build command:
pip install -r requirements.txt - Set start command:
python app.py
The backend sends structured water quality data to Gemini using a prompt that:
- Analyzes parameters against WHO standards
- Expects structured JSON in return
- Extracts key insights: quality, risks, solutions, SDG alignment
The Gemini response is parsed and visualized in a well-designed UI.
{
"quality_assessment": "Fair",
"risk_level": "Medium",
"key_issues": ["High turbidity", "Low pH level"],
"short_term_solutions": ["Install local filtration units"],
"long_term_solutions": ["Build community water treatment plant"],
...
}Create a .env file in the root directory:
GEMINI_API_KEY=your_google_gemini_api_keyPull requests are welcome. If you'd like to add a feature, create an issue first.
WaterAI is built to support:
- 6.1 β Safe and affordable drinking water
- 6.3 β Improve water quality, reduce pollution
- 6.B β Community participation in water management
- Support for CSV batch analysis
- Multilingual support
- Mobile PWA support
- LLM fallback using Ollama or GPT-4
Built with Code by Me | 2025