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.
Quick Links
| Document | Description |
|---|---|
| Architecture | System design, data flow, and design patterns |
| Project Structure | Complete folder and file organization |
| Features | Detailed feature documentation |
| Components | UI components reference |
| Hooks | Custom React hooks documentation |
| Services | Backend services and API clients |
| Configuration | Environment setup and constants |
| Accuracy & Efficiency | Model accuracy and system efficiency metrics |
| Real World Benefits | Real-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
- Frontend: http://localhost:3000
- ML API: http://localhost:8000
- API Docs: http://localhost:8000/docs (Swagger UI)
Environment Variables
See Configuration for complete environment setup.
Required Variables
| Variable | Description | Required |
|---|---|---|
NEXT_PUBLIC_ML_API_URL | ML API endpoint URL | Yes |
NEXT_PUBLIC_FIREBASE_API_KEY | Firebase Web API key | Yes |
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN | Firebase Auth domain | Yes |
NEXT_PUBLIC_FIREBASE_PROJECT_ID | Firebase project ID | Yes |
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID | Firebase messaging sender ID | Yes |
NEXT_PUBLIC_FIREBASE_APP_ID | Firebase app ID | Yes |
BLOCKCHAIN_PRIVATE_KEY | Server wallet private key (server-side) | Optional |
BLOCKCHAIN_RPC_URL | Polygon RPC URL | Optional |
BLOCKCHAIN_CONTRACT_ADDRESS | Deployed contract address | Optional |
RESEND_API_KEY | Resend email API key | Optional |
RESEND_FROM_EMAIL | Email sender address | Optional |
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:
- Feature Overview - High-level description
- Technical Details - Implementation specifics
- File References - Source code locations
- API/Props - Interface documentation
When making changes, update the relevant document section and timestamp.
Last Updated: December 2024