π§ WaterAudit
A comprehensive web platform for conducting water balance audits of urban water utilities. WaterAudit helps auditors evaluate water distribution systems by computing Data Validity Scores (DVS), Key Performance Indicators (KPIs), Service Level Benchmarks, and Carbon Footprint Analysis β all following internationally recognized IWA/AWWA standards.
- User Authentication β Secure JWT-based registration, login, and profile management
- Project Management β Create, organize, and track multiple audit projects with metadata (scope, location, population, lead auditor)
- Guided Data Input β Structured, category-wise data entry with built-in validation modals for every input parameter
- Data Validity Score (DVS) β Weighted scoring engine across four categories:
- Supply Data (40%)
- Customer Metering Data (30%)
- Authorized Consumption & Losses (15%)
- System Attributes (15%)
- KPI Calculations β Automated computation of key water audit indicators:
- Non-Revenue Water (NRW %)
- Revenue Water Ratio (RWR)
- Infrastructure Leakage Index (ILI)
- Current Annual Real Losses (CARL)
- Unavoidable Annual Real Losses (UARL)
- Economical Level of Leakage (ELL)
- Per Capita Water Supply
- Coverage of Water Supply Connections
- Carbon Footprint Analysis β EnergyβWaterβCarbon Nexus module covering Scope 1, 2, and 3 emissions
- PDF Report Generation β Export audit results as downloadable PDF reports
- Responsive Dashboard β Modern, dark-mode-ready UI with interactive charts and visualizations
- Theme Support β Light and dark mode toggle
| Technology | Purpose |
|---|---|
| Next.js 16 | React framework (App Router) |
| TypeScript | Type-safe JavaScript |
| Tailwind CSS 4 | Utility-first styling |
| Radix UI | Accessible component primitives |
| Recharts | Charting / data visualization |
| Framer Motion | Animations |
| Lucide React | Icon library |
| jsPDF | Client-side PDF generation |
| Zod + React Hook Form | Form validation |
| Technology | Purpose |
|---|---|
| FastAPI | Python REST API framework |
| SQLAlchemy | ORM & database toolkit |
| PostgreSQL (via Neon) | Cloud-hosted relational database |
| Pydantic | Data validation & serialization |
| python-jose | JWT token handling |
| bcrypt | Password hashing |
WaterAudit/
βββ backend/
β βββ main.py # FastAPI app & all API routes
β βββ models.py # SQLAlchemy models & Pydantic schemas
β βββ database.py # DB engine & session configuration
β βββ auth.py # JWT & password utilities
β βββ migrate.py # Database migration script
β βββ requirements.txt # Python dependencies
β βββ .env.example # Environment variable template
β
βββ frontend/
β βββ app/
β β βββ page.tsx # Landing page
β β βββ layout.tsx # Root layout
β β βββ globals.css # Global styles
β β βββ login/ # Login page
β β βββ register/ # Registration page
β β βββ dashboard/
β β βββ layout.tsx # Dashboard shell (sidebar, nav)
β β βββ page.tsx # Dashboard home
β β βββ create-project/ # New project form
β β βββ projects/ # Project listing
β β βββ data-input/ # Audit data entry
β β βββ results/ # KPI & DVS results
β β βββ profile/ # User profile
β β βββ settings/ # App settings
β βββ components/
β β βββ ui/ # Reusable UI components (shadcn/ui)
β β βββ auth/ # Auth-related components
β β βββ CustomIcons.tsx # Custom SVG icons
β βββ contexts/
β β βββ AuthContext.tsx # Authentication state provider
β β βββ AuditContext.tsx # Audit data state provider
β βββ hooks/ # Custom React hooks
β βββ lib/
β β βββ api.ts # API client (fetch wrapper)
β β βββ pdfGenerator.ts # PDF report builder
β β βββ dvs/ # DVS calculation engine
β β βββ index.ts # Input definitions & categories
β β βββ calculator.ts # DVS score & KPI computation
β β βββ types.ts # TypeScript interfaces
β β βββ [category].ts # Per-category validation logic
β βββ package.json
β βββ tsconfig.json
β
βββ .github/
β βββ ISSUE_TEMPLATE/ # GitHub issue templates
βββ CODE_OF_CONDUCT.md
βββ CONTRIBUTING.md
βββ SECURITY.md
βββ LICENSE # MIT License
βββ README.md
- Node.js β₯ 18
- Python β₯ 3.10
- PostgreSQL database (or use Neon for a free serverless instance)
git clone https://github.com/sumitmodanwal962/WaterAudit.git
cd WaterAuditcd backend
# Create and activate a virtual environment (recommended)
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env with your database URL and a secure secret key.env configuration:
DATABASE_URL=postgresql://username:password@hostname/dbname
SECRET_KEY=your_super_secret_key_here # Generate with: openssl rand -hex 32
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30# Start the backend server
uvicorn main:app --reloadThe API will be available at http://localhost:8000. Interactive docs at http://localhost:8000/docs.
cd frontend
# Install dependencies
npm install
# Start the development server
npm run devThe app will be available at http://localhost:3000.
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/register |
Register a new user |
POST |
/api/auth/login |
Login & receive JWT token |
GET |
/api/users/me |
Get current user profile |
PUT |
/api/users/me |
Update user profile |
POST |
/api/users/me/change-password |
Change password |
DELETE |
/api/users/me |
Delete user account |
GET |
/api/projects |
List all projects for current user |
POST |
/api/projects |
Create a new project |
GET |
/api/projects/{id} |
Get project details |
DELETE |
/api/projects/{id} |
Delete a project |
GET |
/api/projects/{id}/data-input |
Get audit data for a project |
POST |
/api/projects/{id}/data-input |
Save/update audit data for a project |
All endpoints (except register/login) require a Bearer token in the Authorization header.
The Data Validity Score quantifies the reliability of input data using the IWA Water Balance framework:
DVS = Ξ£(Wi Γ Gi) / Ξ£(Wi) Γ 100
Where:
- Wi = Category weight (Supply 40%, Metering 30%, Consumption 15%, System 15%)
- Gi = Grade per category (0β1), determined by validation questionnaire responses
Each data parameter is validated through guided modals with weighted scoring, ensuring the DVS accurately reflects data quality. Dynamic sub-weighting within categories accounts for volumetric significance (e.g., larger supply sources receive proportionally higher weight).
WaterAudit extends traditional water auditing with carbon footprint analysis based on the EnergyβWaterβCarbon Nexus framework:
| Scope | Source | Formula |
|---|---|---|
| Scope 2 | Grid electricity | (kWh - Renewables) Γ Grid Factor |
| Scope 1 | Diesel/fuel | Litres Γ 2.68 kgCOβ/L |
| Scope 3 | Treatment chemicals | Chlorine Γ 1.08 + Alum Γ 0.70 |
Normalized Metrics: Carbon per MLD, Carbon per Capita, Carbon cost of water losses.
We welcome contributions! Please read our Contributing Guide before getting started.
Quick summary:
- Create your own branch from
main - Pull latest
mainbefore working - Make changes with clear, descriptive commit messages
- Ensure the app runs before submitting a PR
- Push to your branch and open a pull request
For security concerns, please refer to our Security Policy.
This project is licensed under the MIT License β see the LICENSE file for details.
Copyright Β© 2026 theub002 and sumitmodanwal962