Skip to main content

ReWater Plus - Documentation

AI-Powered Water Quality Analysis Platform

A Next.js 15 application providing advanced water quality analysis with ML predictions, treatment recommendations, blockchain verification, and real-time monitoring capabilities.


DocumentDescription
ArchitectureSystem design, data flow, and design patterns
Project StructureComplete folder and file organization
FeaturesDetailed feature documentation
ComponentsUI components reference
HooksCustom React hooks documentation
ServicesBackend services and API clients
ConfigurationEnvironment setup and constants
Accuracy & EfficiencyModel accuracy and system efficiency metrics
Real World BenefitsReal-world application benefits

Technology Stack

Frontend

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript 5
  • Styling: TailwindCSS 4
  • UI Components: Radix UI + shadcn/ui
  • Icons: Lucide React, Tabler Icons
  • Charts: Recharts
  • Forms: React Hook Form + Zod
  • Animations: Motion (Framer Motion)
  • 3D/WebGL: Custom WebGL shaders, Three.js

Backend & Services

  • Authentication: Firebase Auth
  • Database: Firebase Firestore
  • ML API: Python FastAPI backend with WebSocket support
  • Blockchain: Polygon (ethers.js)
  • PDF Generation: jsPDF + jspdf-autotable
  • Email: Resend API

Core Features

1. Prediction Model

AI-powered water reusability prediction with CPCB compliance checks.

2. Treatment Model

Treatment stage recommendations based on water quality parameters.

3. Twin Engine

Combined analysis running both models in a unified workflow.

4. Adaptive Optimizers

Real-time simulation engine for water treatment scenarios.

5. CAD Integration

3D plant visualization and design tools for wastewater treatment facilities.

6. WebSocket Monitor

Real-time data streaming interface for SCADA system integration.

7. Blockchain Verification

Immutable report storage on Polygon blockchain.

8. Report History

Complete history with filtering, PDF export, and blockchain status.


Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Python 3.10+ (for ML API)
  • Firebase project
  • (Optional) Polygon wallet for blockchain features

Installation

# Clone the repository
git clone <repository-url>
cd edubotx

# Install frontend dependencies
cd core
npm install

# Set up environment variables
cp .env.example .env.local
# Edit .env.local with your configuration

# Run development server
npm run dev

Running the ML API

# Navigate to ML directory
cd ml

# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run the API server
uvicorn main:app --reload --port 8000

Accessing the Application


Environment Variables

See Configuration for complete environment setup.

Required Variables

VariableDescriptionRequired
NEXT_PUBLIC_ML_API_URLML API endpoint URLYes
NEXT_PUBLIC_FIREBASE_API_KEYFirebase Web API keyYes
NEXT_PUBLIC_FIREBASE_AUTH_DOMAINFirebase Auth domainYes
NEXT_PUBLIC_FIREBASE_PROJECT_IDFirebase project IDYes
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_IDFirebase messaging sender IDYes
NEXT_PUBLIC_FIREBASE_APP_IDFirebase app IDYes
BLOCKCHAIN_PRIVATE_KEYServer wallet private key (server-side)Optional
BLOCKCHAIN_RPC_URLPolygon RPC URLOptional
BLOCKCHAIN_CONTRACT_ADDRESSDeployed contract addressOptional
RESEND_API_KEYResend email API keyOptional
RESEND_FROM_EMAILEmail sender addressOptional

Project Structure Overview

edubotx/
├── core/ # Next.js frontend application
│ ├── src/
│ │ ├── app/ # App Router pages & API routes
│ │ ├── components/ # Reusable UI components
│ │ ├── config/ # Application configuration
│ │ ├── docs/ # Documentation (you are here)
│ │ ├── hooks/ # Custom React hooks
│ │ └── lib/ # Services and utilities
│ └── public/ # Static assets
├── ml/ # Python ML API
│ ├── models_v1/ # Reusability prediction models
│ ├── models_v2/ # Treatment recommendation models
│ └── docs/ # ML API documentation
├── blockchain/ # Smart contracts
│ └── contracts/ # Solidity contracts
└── docs-site/ # Docusaurus documentation site

Documentation Updates

This documentation is structured for easy updates. Each document follows a consistent format:

  1. Feature Overview - High-level description
  2. Technical Details - Implementation specifics
  3. File References - Source code locations
  4. API/Props - Interface documentation

When making changes, update the relevant document section and timestamp.


Last Updated: December 2024