Detect defects. Generate reports. Predict failures. Before they happen.
Built as a deep-dive MVP inspired by ENRZY โ the infrastructure intelligence platform by BetterDrones India. GridWise mirrors their 5-step pipeline and adds failure risk forecasting โ predicting asset failures before they happen.
Features โข Architecture โข API Reference โข Quick Start โข Demo
India's power grid has 4.5 lakh+ transmission towers spanning hundreds of thousands of kilometres. Every tower needs regular inspection. Traditionally, this meant:
- ๐ท A human inspector physically climbing or visiting each tower
- ๐ Handwritten notes, manual reports, emailed PDFs
- ๐ Days between inspection and maintenance action
- ๐ด Zero prediction โ defects found only after they've developed
BetterDrones + ENRZY changed this โ drones now fly the lines, AI detects the defects, and reports are generated in minutes.
GridWise takes it further โ by analysing historical inspection data to predict which towers will fail in the next 30, 60, or 90 days. From reactive to proactive. From damage control to decision intelligence.
No bad data reaches the AI. Ever.
- Validates image resolution, format, and completeness before analysis
- Rejects substandard files and notifies the pilot to re-shoot
- Attaches geo-tags from EXIF or request metadata
- Every inspection gets a clean, verified data package
Claude vision analyses every image for infrastructure defects.
Detects across 7 defect categories:
| Defect | Severity Range |
|---|---|
| ๐ฅ Corrosion / rust | Critical โ Minor |
| ๐ฟ Vegetation encroachment | Critical โ Minor |
| ๐ฉ Missing components | Critical โ Major |
| Critical โ Major | |
| ๐ Cracks / fractures | Critical โ Minor |
| ๐ก๏ธ Thermal hotspots | Critical โ Major |
| Major โ Minor |
Returns structured JSON with defect type, severity, exact location on asset, confidence score, and AI reasoning โ all stored against the inspection.
From raw defects to a client-ready PDF in seconds.
- LLM writes executive summary, health score justification, and recommendations
- Health score (0โ100) calculated per inspection
- PDF rendered with asset info, defect table, severity colour coding, and annotated findings
- Ready to send directly to PGCIL or any utility client
Every defect becomes a work order. Automatically.
- One ticket auto-created per defect
- Priority set by severity: P1 (Critical, 7 days) โ P2 (Major, 21 days) โ P3 (Minor, 45 days)
- AI writes field-ready step-by-step instructions per ticket
- Before/after repair photo upload to verify and close tickets
- Status tracking:
openโin_progressโclosed
ENRZY detects defects. GridWise predicts failures.
This is what ENRZY doesn't have yet. GridWise feeds an asset's full inspection history into Claude and asks it to reason about the degradation trend:
- Failure probability at 30 / 60 / 90 days
- Degradation rate in health score points per month
- Which specific component is most at risk
- Recommended action: monitor / schedule maintenance / emergency intervention
- Full reasoning chain โ explainable AI, not a black box
A tower going from health score 88 โ 74 โ 61 โ 52 โ 41 over 12 months doesn't just need a ticket โ it needs a team on-site before next quarter.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Client Layer โ
โ React UI / Postman / curl / SDK โ
โโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP
โโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastAPI Backend โ
โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โ
โ โ DataGuard โ โ AI Detectionโ โ Report Engine โ โ
โ โ Validate โ โClaude Visionโ โ LLM โ PDF โ โ
โ โ Geo-tag โ โDefect โ JSONโ โ Health Score โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ FixTrack Ticket Engine โ โ
โ โ Defect โ Ticket โ Assign โ Verify โ Close โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Failure Risk Forecaster ๐ฎ โ โ
โ โ Inspection history โ Claude reasoning โ Risk โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Data + AI Layer โ
โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โ โ PostgreSQL โ โ File Storage โ โ Claude API โ โ
โ โ 4 tables โ โ Images/PDFs โ โ Vision+Text โ โ
โ โ + forecasts โ โ local / S3 โ โ Sonnet 4.5 โ โ
โ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
gridwise/
โโโ app/
โ โโโ main.py # FastAPI app entry point
โ โโโ config.py # Environment config
โ โโโ database.py # Async SQLAlchemy setup
โ โโโ models/ # ORM models
โ โ โโโ asset.py
โ โ โโโ inspection.py
โ โ โโโ defect.py
โ โ โโโ ticket.py
โ โ โโโ forecast.py
โ โโโ schemas/ # Pydantic v2 schemas
โ โโโ routers/ # FastAPI route handlers
โ โ โโโ assets.py
โ โ โโโ inspections.py
โ โ โโโ tickets.py
โ โ โโโ forecasts.py
โ โโโ services/ # Business logic
โ โ โโโ dataguard.py
โ โ โโโ ai_detection.py
โ โ โโโ report_engine.py
โ โ โโโ ticket_engine.py
โ โ โโโ forecaster.py
โ โโโ ai/
โ โ โโโ client.py # Anthropic client
โ โ โโโ prompts.py # All prompt templates
โ โ โโโ parsers.py # Safe JSON parsers
โ โโโ storage/
โ โโโ file_handler.py # File I/O (S3-ready)
โโโ alembic/ # DB migrations
โโโ tests/ # Pytest test suite
โโโ demo_seed.py # One-command demo setup
โโโ .env.example
โโโ requirements.txt
โโโ README.md
assets inspections
โโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
id UUID PK id UUID PK
name VARCHAR asset_id UUID FK โ assets
asset_type ENUM pilot_id VARCHAR
latitude FLOAT capture_date DATE
longitude FLOAT capture_types ARRAY
zone VARCHAR validation_status ENUM
installed_year INT health_score INT
created_at TIMESTAMP created_at TIMESTAMP
defects tickets
โโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
id UUID PK id UUID PK
inspection_id UUID FK defect_id UUID FK
defect_type ENUM asset_id UUID FK
severity ENUM priority ENUM P1/P2/P3
location_desc TEXT status ENUM
confidence FLOAT title VARCHAR
ai_reasoning TEXT instructions TEXT
created_at TIMESTAMP assigned_team VARCHAR
due_date DATE
before_photo VARCHAR
forecasts after_photo VARCHAR
โโโโโโโโโโโโโโโโโโโโโโโโโโ closed_at TIMESTAMP
id UUID PK
asset_id UUID FK
risk_30_days FLOAT
risk_60_days FLOAT
risk_90_days FLOAT
degradation_rate FLOAT
at_risk_component VARCHAR
recommended_action VARCHAR
reasoning TEXT
generated_at TIMESTAMP
- Python 3.11+
- PostgreSQL 16+
- An Anthropic API key
git clone https://github.com/0xvicky/gridwise.git
cd gridwise
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtcp .env.example .envEdit .env:
DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/gridwise
ANTHROPIC_API_KEY=sk-ant-...
CLAUDE_MODEL=claude-sonnet-4-5
STORAGE_PATH=./storage
MAX_IMAGE_SIZE_MB=50
MIN_IMAGE_WIDTH=4000
MIN_IMAGE_HEIGHT=3000alembic upgrade headpython demo_seed.pyThis creates 3 assets with 5 inspections each showing a realistic degradation curve โ ready for the forecaster to analyse.
uvicorn app.main:app --reloadAPI docs live at http://localhost:8000/docs โจ
| Method | Endpoint | Description |
|---|---|---|
POST |
/assets |
Register a new infrastructure asset |
GET |
/assets |
List all assets (filter by zone, health score) |
GET |
/assets/{asset_id} |
Asset detail + full inspection history |
| Method | Endpoint | Description |
|---|---|---|
POST |
/inspections/upload |
Upload drone images + metadata |
GET |
/inspections/{id}/validation |
Get per-file validation results |
POST |
/inspections/{id}/reupload |
Re-submit rejected images |
| Method | Endpoint | Description |
|---|---|---|
POST |
/inspections/{id}/analyze |
๐ค Run Claude vision defect detection |
GET |
/inspections/{id}/defects |
Get all detected defects |
| Method | Endpoint | Description |
|---|---|---|
POST |
/inspections/{id}/report |
๐ Generate PDF inspection report |
GET |
/inspections/{id}/report |
Download the generated PDF |
| Method | Endpoint | Description |
|---|---|---|
POST |
/inspections/{id}/tickets/generate |
๐ง Auto-create maintenance tickets |
GET |
/tickets |
List all tickets (filter by status/priority) |
GET |
/tickets/{ticket_id} |
Get single ticket detail |
PATCH |
/tickets/{ticket_id}/status |
Update ticket status |
POST |
/tickets/{ticket_id}/repair-photo |
Upload before/after repair photo |
| Method | Endpoint | Description |
|---|---|---|
POST |
/assets/{id}/forecast |
๐ฎ Run failure risk forecast |
GET |
/assets/{id}/forecast |
Get latest forecast |
GET |
/forecasts/high-risk |
Assets with >70% failure risk in 30 days |
After running demo_seed.py, walk through this story:
# 1. Check Tower T-482 โ health declining from 88 โ 41 over 5 inspections
GET /assets/tower-t482
# 2. Upload a new inspection image
POST /inspections/upload
โ inspection_id: abc-123
# 3. Validate passed โ all images clean
GET /inspections/abc-123/validation
โ status: passed, 12/12 images accepted
# 4. Run AI detection
POST /inspections/abc-123/analyze
โ defect: corrosion, severity: critical, confidence: 0.87
โ defect: vegetation_encroachment, severity: major, confidence: 0.91
# 5. Generate PDF report
POST /inspections/abc-123/report
โ health_score: 38/100
โ PDF downloaded with full defect analysis
# 6. Auto-create maintenance tickets
POST /inspections/abc-123/tickets/generate
โ TKT-001: P1 Corrosion repair โ due in 7 days
โ TKT-002: P2 Vegetation clearance โ due in 21 days
# 7. Close ticket with repair photo
POST /tickets/TKT-001/repair-photo (upload after.jpg)
PATCH /tickets/TKT-001/status { "status": "closed" }
# 8. Run failure risk forecast
POST /assets/tower-t482/forecast
โ risk_30_days: 0.84
โ recommended_action: "Emergency intervention required"
โ reasoning: "Asset degrading at 9.4 points/month..."
# 9. See the watchlist
GET /forecasts/high-risk
โ Tower T-482 at top โ 84% failure riskpytest tests/ -vtests/test_assets.py::test_create_asset PASSED โ
tests/test_inspections.py::test_upload_and_validate PASSED โ
tests/test_inspections.py::test_dataguard_rejects_blurry PASSED โ
tests/test_ai_detection.py::test_defect_detection PASSED โ
tests/test_tickets.py::test_auto_ticket_generation PASSED โ
tests/test_tickets.py::test_cannot_close_without_photo PASSED โ
tests/test_forecaster.py::test_forecast_output PASSED โ
tests/test_forecaster.py::test_forecast_needs_min_2_inspections PASSED โ
These are enforced at the API layer โ not just convention:
- ๐ซ DataGuard gate โ
/analyzereturnsHTTP 400if inspection is not validated - ๐ธ Repair photo required โ tickets cannot close without an after-photo uploaded
- ๐ Minimum history โ forecaster requires at least 2 inspections with health scores
- ๐ No hardcoded keys โ all secrets via
.envonly - ๐ Relative file paths โ storage is S3-ready, no absolute paths in DB
- WebSocket real-time ticket status updates
- Multi-tenant support (separate orgs per utility client)
- LiDAR point cloud ingestion + 3D model generation
- Mobile app for field crews (repair photo upload in the field)
- Scheduled re-forecast jobs โ auto-run forecaster weekly per asset
- Slack / WhatsApp alerts when a tower crosses 70% failure risk threshold
This MVP was built to demonstrate deep understanding of the infrastructure intelligence problem space being solved by
BetterDrones and their platform ENRZY
India's leading drone-powered infrastructure intelligence company.
MIT ยฉ 2025 GridWise
Built with โก by Vivek Tyagi
"Quality Data โ On Time โ Every Time"