Skip to content

TSKVenkat/subterra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

89 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌊 Subterra

India's First Real-Time Groundwater Intelligence Platform

Empowering farmers, policymakers, and researchers with AI-powered water predictions and actionable insights.

Subterra Banner


What is Subterra?

Subterra is a mobile-first, AI-powered groundwater management platform designed for India. It connects to 5,260+ DWLR (Digital Water Level Recorder) stations across the country and uses machine learning to predict water levels up to 30 days ahead.

Key Features

Feature Description
30-Day Predictions ML-powered water level forecasting using Temporal Fusion Transformer
Real-Time Monitoring Live data from India-WRIS DWLR network
Crop Planner AI-optimized irrigation schedules based on predicted water availability
Water Budget Tool Calculate sustainable usage limits with ML predictions
Community View See nearby wells and collective water usage trends
Multilingual Support for 10+ Indian languages
Offline Mode Works without internet, syncs when connected
SMS Alerts Low-connectivity users get critical updates via SMS

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          CLIENT LAYER                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   Flutter App       β”‚    React PWA        β”‚    Research Portal      β”‚
β”‚   (Android/iOS)     β”‚    (Web Frontend)   β”‚    (Researchers)        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                     β”‚                     β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                         β”‚   GraphQL API   β”‚
                         β–Ό                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         BACKEND (Node.js)                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Controllers  β”‚  Services  β”‚  GraphQL Resolvers  β”‚  Middleware      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚             β”‚                  β”‚                  β”‚
        β–Ό             β–Ό                  β–Ό                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Firestore  β”‚ β”‚    Redis    β”‚ β”‚  India-WRIS β”‚ β”‚    ML Service       β”‚
β”‚  (Storage)  β”‚ β”‚   (Cache)   β”‚ β”‚    API      β”‚ β”‚  (TFT Inference)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                          β”‚
                                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                               β”‚   Gemini API        β”‚
                                               β”‚   (AI Insights)     β”‚
                                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The ML Model: Temporal Fusion Transformer (TFT)

We chose TFT because groundwater prediction isn't just about looking at past water levels. It's about understanding complex relationships between:

  • Historical water levels
  • Rainfall patterns
  • Temperature and humidity
  • Seasonal cycles
  • Geographic location

TFT handles all of this beautifully. See docs/ML_MODEL.md for full details.

Quick Summary

Aspect Details
Lookback Window 90 days of history
Forecast Horizon 30 days ahead
Output Quantile predictions (10th, 50th, 90th percentile)
Features Water level, rainfall, temperature, location, well depth
Model Size ~2MB

Project Structure

subterra/
β”œβ”€β”€ backend/                 # Node.js + Express + GraphQL API
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/          # Firebase, Redis configuration
β”‚   β”‚   β”œβ”€β”€ controllers/     # Business logic controllers
β”‚   β”‚   β”œβ”€β”€ services/        # External API integrations
β”‚   β”‚   β”œβ”€β”€ graphql/         # Schema and resolvers
β”‚   β”‚   └── middleware/      # Auth, logging, error handling
β”‚   └── ml/                  # Python ML components
β”‚       β”œβ”€β”€ train_tft.py     # TFT training script
β”‚       β”œβ”€β”€ inference/       # FastAPI inference service
β”‚       β”œβ”€β”€ checkpoints/     # Trained model weights
β”‚       └── data/            # Training dataset
β”‚
β”œβ”€β”€ frontend/                # React PWA (Web interface)
β”‚   └── src/
β”‚       β”œβ”€β”€ pages/           # Page components
β”‚       β”œβ”€β”€ components/      # Reusable UI components
β”‚       └── lib/             # GraphQL queries, utilities
β”‚
β”œβ”€β”€ lib/                     # Flutter app (Mobile)
β”‚   β”œβ”€β”€ core/                # App core (theme, routes)
β”‚   β”œβ”€β”€ data/                # Data layer (APIs, models)
β”‚   └── features/            # Feature modules
β”‚
└── docs/                    # Documentation
    β”œβ”€β”€ ML_MODEL.md          # TFT model documentation
    β”œβ”€β”€ DATA_PIPELINE.md     # How we collect and process data
    β”œβ”€β”€ API_REFERENCE.md     # GraphQL API documentation
    └── ARCHITECTURE.md      # System architecture

Quick Start

Prerequisites

  • Node.js 18+
  • Python 3.10+
  • Docker (optional)
  • Firebase project (for Firestore)
  • Redis (for caching)

1. Clone and Setup

git clone https://github.com/your-repo/subterra.git
cd subterra

2. Backend Setup

cd backend
npm install
cp .env.example .env
# Edit .env with your API keys
npm run dev

3. ML Service Setup

cd backend/ml
pip install -r requirements_train.txt
python inference/service.py
# Runs on http://localhost:8000

4. Frontend Setup

cd frontend
npm install
npm run dev
# Runs on http://localhost:5173

Docker (Alternative)

docker-compose up --build

Environment Variables

# API Keys
GEMINI_API_KEY=your_gemini_api_key
MSG91_AUTH_KEY=your_msg91_key
MSG91_SENDER_ID=SBTRRA

# Firebase
FIREBASE_PROJECT_ID=your_project_id
FIREBASE_CLIENT_EMAIL=your_client_email
FIREBASE_PRIVATE_KEY=your_private_key

# Redis
REDIS_URL=redis://localhost:6379

# ML Service
ML_SERVICE_URL=http://localhost:8000

Data Sources

Source Data Type Update Frequency
India-WRIS DWLR water levels Every 6 hours
NASA POWER Rainfall, temperature Daily
Firestore User data, alerts Real-time

Screenshots

Home Map Crop Planner Water Budget
Home Map Crop Budget

Documentation


Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.


Acknowledgments

  • India-WRIS for providing open access to DWLR data
  • NASA POWER for weather data
  • All the farmers and communities who inspired this project

About

man loves water...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors