SevaSetu implements a multi-tier hierarchical system for civic issue management that combines administrative hierarchy, AI-powered analysis, and intelligent prioritization to ensure efficient issue resolution.
┌─────────────────────────────────────────────────────────────┐
│ STATE LEVEL │
│ • State Admin Dashboard │
│ • Cross-district analytics & escalation handling │
│ • Policy-level decisions │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ DEPARTMENT LEVEL │
│ • PWD, Sanitation, Electricity, Water, General │
│ • Department-wide resource allocation │
│ • Performance monitoring across districts │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ DISTRICT/OFFICE LEVEL │
│ • Local government offices │
│ • Direct issue assignment │
│ • Field worker management │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ FIELD WORKER LEVEL │
│ • On-ground issue resolution │
│ • Status updates & photo verification │
│ • Direct citizen communication │
└─────────────────────────────────────────────────────────────┘
- Citizen Reports Issue → Issue enters system with location, category, media
- AI Analysis → Automatic categorization, severity assessment, population impact
- Department Routing → Category maps to responsible department
- Office Assignment → Nearest office in district receives issue
- Worker Assignment → Office admin assigns to available field worker
- Escalation Path → Unresolved issues escalate up the hierarchy
| Issue Category | Assigned Department | Rationale |
|---|---|---|
| POTHOLE | PWD (Public Works) | Road infrastructure |
| DRAINAGE_PROBLEM | PWD (Public Works) | Civil infrastructure |
| GARBAGE | SANITATION | Waste management |
| SEWAGE_OVERFLOW | SANITATION | Sewage systems |
| STREETLIGHT | ELECTRICITY | Electrical infrastructure |
| POWER_CUT | ELECTRICITY | Power supply issues |
| WATER_LEAK | WATER | Water supply infrastructure |
| OTHER | GENERAL | Unclassified issues |
// Pseudocode for assignment flow
assignIssue(issue):
1. department = mapCategoryToDepartment(issue.category)
2. districtOffices = findOffices(department, issue.district)
3. if districtOffices.isNotEmpty:
nearestOffice = selectByDistance(districtOffices, issue.location)
return AssignmentResult(nearestOffice, escalated: false)
4. else:
stateOffices = findStateOffices(department, issue.state)
nearestOffice = selectByDistance(stateOffices, issue.location)
return AssignmentResult(nearestOffice, escalated: true)The system uses a multi-modal AI model (e.g., Google Gemini Vision, GPT-4 Vision) to analyze uploaded images and automatically:
- Identify Issue Type - Detect what civic problem is shown
- Assess Severity - Determine how critical the situation is
- Estimate Impact - Calculate affected population/area
- Extract Context - Identify location markers, time indicators
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Image │────▶│ Pre- │────▶│ AI Model │────▶│ Post- │
│ Upload │ │ Processing │ │ Inference │ │ Processing │
└──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ AI Analysis Output │
│ • detected_category: "POTHOLE" │
│ • confidence_score: 0.94 │
│ • severity_level: "HIGH" │
│ • affected_area_sqm: 15.5 │
│ • population_impact: "MEDIUM" │
│ • hazard_indicators: ["traffic_risk", "pedestrian"] │
│ • recommended_priority: 85 │
└─────────────────────────────────────────────────────────┘
SYSTEM PROMPT FOR CIVIC ISSUE IMAGE ANALYSIS:
You are an AI assistant specialized in analyzing civic infrastructure issues.
Analyze the provided image and return a JSON response with:
1. CATEGORY DETECTION:
- Identify the primary issue type from: POTHOLE, GARBAGE, STREETLIGHT,
WATER_LEAK, SEWAGE_OVERFLOW, DRAINAGE_PROBLEM, POWER_CUT, OTHER
- Provide confidence score (0.0 to 1.0)
2. SEVERITY ASSESSMENT:
- LOW: Minor inconvenience, no safety risk
- MEDIUM: Moderate impact, potential safety concern
- HIGH: Significant hazard, immediate attention needed
- CRITICAL: Emergency situation, public safety at risk
3. POPULATION IMPACT ESTIMATION:
- Analyze visible context (residential area, commercial zone, school nearby)
- Estimate affected population density
- Consider time-sensitive factors (rush hour traffic, school timings)
4. SITUATIONAL CONTEXT:
- Identify environmental hazards
- Detect infrastructure damage extent
- Note any visible safety risks
Return structured JSON only.
class AIAnalysis {
final String detectedCategory; // AI-detected issue type
final double confidenceScore; // 0.0 to 1.0
final String severityLevel; // LOW, MEDIUM, HIGH, CRITICAL
final double affectedAreaSqm; // Estimated affected area
final String populationImpact; // LOW, MEDIUM, HIGH, CRITICAL
final List<String> hazardIndicators; // Detected hazards
final int recommendedPriority; // 0-100 score
final String analysisNotes; // Additional AI observations
final DateTime analyzedAt; // Timestamp
}The priority score (0-100) is calculated using weighted factors:
PRIORITY_SCORE =
(SEVERITY_WEIGHT × Severity_Score) +
(POPULATION_WEIGHT × Population_Impact_Score) +
(CATEGORY_WEIGHT × Category_Urgency_Score) +
(UPVOTE_WEIGHT × Community_Support_Score) +
(AGE_WEIGHT × Time_Decay_Score) +
(AI_WEIGHT × AI_Confidence_Bonus)
| Factor | Weight | Max Points | Description |
|---|---|---|---|
| Severity | 30% | 30 | How dangerous/critical is the issue |
| Population Impact | 25% | 25 | How many people are affected |
| Category Urgency | 15% | 15 | Inherent urgency of issue type |
| Community Support | 15% | 15 | Upvotes from other citizens |
| Time Factor | 10% | 10 | How long issue has been pending |
| AI Confidence | 5% | 5 | Bonus for high-confidence AI analysis |
int calculateSeverityScore(String severityLevel) {
switch (severityLevel) {
case 'CRITICAL':
return 30; // Maximum severity - immediate danger
case 'HIGH':
return 24; // Significant hazard
case 'MEDIUM':
return 15; // Moderate concern
case 'LOW':
return 8; // Minor inconvenience
default:
return 10;
}
}The AI estimates population impact based on:
-
Location Type Analysis
- Residential area: Base multiplier 1.0x
- Commercial zone: Base multiplier 1.5x
- School/Hospital vicinity: Base multiplier 2.0x
- Main road/Highway: Base multiplier 1.8x
-
Density Estimation
int calculatePopulationScore(AIAnalysis analysis) { // Base score from AI population impact assessment int baseScore = switch (analysis.populationImpact) { 'CRITICAL' => 25, // Affects 1000+ people 'HIGH' => 20, // Affects 500-1000 people 'MEDIUM' => 12, // Affects 100-500 people 'LOW' => 5, // Affects <100 people _ => 8, }; // Location type multiplier double locationMultiplier = getLocationMultiplier(analysis); return (baseScore * locationMultiplier).clamp(0, 25).toInt(); }
-
Contextual Factors
- Time of day (rush hour = higher impact)
- Day of week (weekday vs weekend)
- Seasonal factors (monsoon = drainage issues more critical)
int getCategoryUrgencyScore(String category) {
// Categories ranked by inherent urgency
const categoryScores = {
'POWER_CUT': 15, // Affects daily life immediately
'WATER_LEAK': 14, // Resource wastage + damage
'SEWAGE_OVERFLOW': 14, // Health hazard
'POTHOLE': 12, // Safety risk
'DRAINAGE_PROBLEM': 11, // Flooding risk
'STREETLIGHT': 10, // Night safety
'GARBAGE': 8, // Health/aesthetic
'OTHER': 6,
};
return categoryScores[category] ?? 6;
}int calculateCommunityScore(int upvotes) {
// Logarithmic scaling to prevent gaming
if (upvotes <= 0) return 0;
if (upvotes <= 5) return upvotes;
if (upvotes <= 20) return 5 + ((upvotes - 5) * 0.5).toInt();
if (upvotes <= 100) return 12 + ((upvotes - 20) * 0.1).toInt();
return 15; // Cap at 15 points
}int calculateTimeScore(DateTime createdAt) {
final age = DateTime.now().difference(createdAt);
// Newer issues get slight priority, but old unresolved issues also prioritized
if (age.inHours < 24) return 10; // Fresh report
if (age.inDays < 3) return 8; // Recent
if (age.inDays < 7) return 6; // Week old
if (age.inDays < 14) return 7; // Getting stale - bump up
if (age.inDays < 30) return 8; // Overdue - higher priority
return 10; // Very old - needs attention
}The AI analyzes images for emergency/chaos indicators:
class ChaosIndicators {
final bool multipleHazardsDetected; // More than one issue type
final bool crowdPresent; // People gathered around issue
final bool vehicleInvolvement; // Vehicles affected/stuck
final bool waterAccumulation; // Flooding visible
final bool structuralDamage; // Building/road damage
final bool fireOrSmoke; // Fire hazard detected
final bool medicalEmergency; // Injured persons visible
final double chaosScore; // 0.0 to 1.0
}double calculateChaosScore(AIAnalysis analysis) {
double score = 0.0;
// Multiple hazards compound the chaos
score += analysis.hazardIndicators.length * 0.1;
// Severity amplifies chaos
if (analysis.severityLevel == 'CRITICAL') score += 0.3;
if (analysis.severityLevel == 'HIGH') score += 0.2;
// Population impact amplifies chaos
if (analysis.populationImpact == 'CRITICAL') score += 0.25;
if (analysis.populationImpact == 'HIGH') score += 0.15;
// Specific hazard indicators
if (analysis.hazardIndicators.contains('flooding')) score += 0.15;
if (analysis.hazardIndicators.contains('traffic_blocked')) score += 0.1;
if (analysis.hazardIndicators.contains('structural_damage')) score += 0.2;
if (analysis.hazardIndicators.contains('fire_hazard')) score += 0.3;
return score.clamp(0.0, 1.0);
}void handleEmergencyEscalation(CivicIssue issue, AIAnalysis analysis) {
final chaosScore = calculateChaosScore(analysis);
if (chaosScore >= 0.8) {
// CRITICAL EMERGENCY
// - Immediate notification to State Admin
// - Auto-assign to nearest available team
// - Alert emergency services if needed
// - Priority score = 100 (maximum)
triggerEmergencyProtocol(issue);
} else if (chaosScore >= 0.6) {
// HIGH PRIORITY SITUATION
// - Notify District Admin immediately
// - Fast-track assignment
// - Priority score = 90+
triggerHighPriorityProtocol(issue);
} else if (chaosScore >= 0.4) {
// ELEVATED CONCERN
// - Flag for supervisor review
// - Priority score boost +20
flagForReview(issue);
}
}The AI estimates affected population using:
-
Visual Context Analysis
Image Analysis Factors: ├── Building density visible ├── Road type (main road vs lane) ├── Presence of shops/businesses ├── School/hospital signage ├── Vehicle traffic density └── Pedestrian presence -
Location Data Enrichment
Future<PopulationData> enrichWithLocationData(GeoPoint location) async { // Query external APIs or local database for: // - Census data for the area // - Land use classification // - Points of interest nearby // - Historical foot traffic data }
-
Time-Based Adjustment
double getTimeBasedMultiplier(DateTime reportTime) { final hour = reportTime.hour; final isWeekend = reportTime.weekday >= 6; // Rush hours have higher population impact if (!isWeekend && (hour >= 8 && hour <= 10 || hour >= 17 && hour <= 20)) { return 1.5; // Rush hour multiplier } // Night time lower impact for most issues if (hour >= 23 || hour <= 5) { return 0.7; } return 1.0; }
enum PriorityZone {
criticalInfrastructure, // Hospitals, fire stations, police
educationalZone, // Schools, colleges
commercialHub, // Markets, business districts
residentialDense, // Apartment complexes
residentialSparse, // Individual houses
industrial, // Factories, warehouses
rural, // Village areas
}
int getZonePriorityBonus(PriorityZone zone) {
return switch (zone) {
PriorityZone.criticalInfrastructure => 20,
PriorityZone.educationalZone => 15,
PriorityZone.commercialHub => 12,
PriorityZone.residentialDense => 10,
PriorityZone.residentialSparse => 5,
PriorityZone.industrial => 8,
PriorityZone.rural => 3,
};
}class PriorityCalculator {
/// Calculate comprehensive priority score for an issue
int calculatePriorityScore(CivicIssue issue, AIAnalysis? aiAnalysis) {
int totalScore = 0;
// 1. SEVERITY COMPONENT (30% weight, max 30 points)
if (aiAnalysis != null) {
totalScore += calculateSeverityScore(aiAnalysis.severityLevel);
} else {
totalScore += getDefaultSeverityScore(issue.category);
}
// 2. POPULATION IMPACT COMPONENT (25% weight, max 25 points)
if (aiAnalysis != null) {
totalScore += calculatePopulationScore(aiAnalysis);
} else {
totalScore += 10; // Default medium impact
}
// 3. CATEGORY URGENCY COMPONENT (15% weight, max 15 points)
totalScore += getCategoryUrgencyScore(issue.category);
// 4. COMMUNITY SUPPORT COMPONENT (15% weight, max 15 points)
totalScore += calculateCommunityScore(issue.upvotes);
// 5. TIME FACTOR COMPONENT (10% weight, max 10 points)
totalScore += calculateTimeScore(issue.createdAt);
// 6. AI CONFIDENCE BONUS (5% weight, max 5 points)
if (aiAnalysis != null && aiAnalysis.confidenceScore > 0.8) {
totalScore += (aiAnalysis.confidenceScore * 5).toInt();
}
// 7. CHAOS/EMERGENCY MULTIPLIER
if (aiAnalysis != null) {
final chaosScore = calculateChaosScore(aiAnalysis);
if (chaosScore >= 0.6) {
totalScore = (totalScore * (1 + chaosScore * 0.5)).toInt();
}
}
// Ensure score is within bounds
return totalScore.clamp(0, 100);
}
/// Determine if issue should be marked as high priority
bool isHighPriority(int priorityScore, AIAnalysis? aiAnalysis) {
// High priority if score > 70 OR critical severity OR high chaos
if (priorityScore > 70) return true;
if (aiAnalysis?.severityLevel == 'CRITICAL') return true;
if (aiAnalysis != null && calculateChaosScore(aiAnalysis) >= 0.7) return true;
return false;
}
}INPUT:
- Image: Large pothole on busy road
- Time: 8:30 AM (Monday)
- Location: Near school zone
AI ANALYSIS:
- Category: POTHOLE (confidence: 0.95)
- Severity: HIGH (traffic hazard)
- Population Impact: HIGH (school children, commuters)
- Hazards: [traffic_risk, pedestrian_safety, vehicle_damage]
PRIORITY CALCULATION:
- Severity Score: 24/30
- Population Score: 20/25 (school zone + rush hour)
- Category Score: 12/15
- Community Score: 0/15 (new report)
- Time Score: 10/10 (fresh)
- AI Bonus: 4/5
TOTAL: 70/100 → HIGH PRIORITY
INPUT:
- Image: Sewage water on street
- Time: 2:00 PM (Wednesday)
- Location: Dense residential colony
AI ANALYSIS:
- Category: SEWAGE_OVERFLOW (confidence: 0.92)
- Severity: CRITICAL (health hazard)
- Population Impact: CRITICAL (500+ residents)
- Hazards: [health_hazard, water_contamination, disease_risk]
- Chaos Score: 0.65
PRIORITY CALCULATION:
- Severity Score: 30/30
- Population Score: 25/25
- Category Score: 14/15
- Community Score: 8/15 (20 upvotes)
- Time Score: 8/10
- AI Bonus: 4/5
- Chaos Multiplier: 1.32x
TOTAL: 89 × 1.32 = 100 (capped) → EMERGENCY
INPUT:
- Image: Dark street with non-functional light
- Time: 7:00 PM (Saturday)
- Location: Residential lane
AI ANALYSIS:
- Category: STREETLIGHT (confidence: 0.88)
- Severity: MEDIUM (night safety)
- Population Impact: LOW (single lane)
- Hazards: [night_safety]
PRIORITY CALCULATION:
- Severity Score: 15/30
- Population Score: 5/25
- Category Score: 10/15
- Community Score: 2/15 (2 upvotes)
- Time Score: 10/10
- AI Bonus: 4/5
TOTAL: 46/100 → NORMAL PRIORITY
┌─────────────────────────────────────────────────────────────────────────────┐
│ COMPLETE ISSUE LIFECYCLE │
└─────────────────────────────────────────────────────────────────────────────┘
CITIZEN REPORTS ISSUE
│
▼
┌───────────────────┐
│ Image Upload │
│ + Location │
│ + Description │
└───────────────────┘
│
▼
┌───────────────────┐ ┌───────────────────┐
│ AI ANALYSIS │────▶│ Category │
│ (Gemini/GPT-4V) │ │ Severity │
│ │ │ Population │
│ │ │ Chaos Score │
└───────────────────┘ └───────────────────┘
│
▼
┌───────────────────┐
│ PRIORITY │
│ CALCULATION │
│ (0-100 score) │
└───────────────────┘
│
▼
┌───────────────────┐ ┌───────────────────┐
│ DEPARTMENT │────▶│ PWD / SANITATION │
│ ROUTING │ │ ELECTRICITY / │
│ │ │ WATER / GENERAL │
└───────────────────┘ └───────────────────┘
│
▼
┌───────────────────┐
│ OFFICE │
│ ASSIGNMENT │
│ (Nearest office) │
└───────────────────┘
│
├──────────────────────────────────────┐
│ │
▼ ▼
┌───────────────────┐ ┌───────────────────┐
│ NORMAL FLOW │ │ EMERGENCY FLOW │
│ - Queue by │ │ - Immediate │
│ priority │ │ notification │
│ - Admin assigns │ │ - Auto-assign │
│ worker │ │ - State alert │
└───────────────────┘ └───────────────────┘
│ │
└──────────────────┬───────────────────┘
│
▼
┌───────────────────┐
│ FIELD WORKER │
│ RESOLUTION │
└───────────────────┘
│
▼
┌───────────────────┐
│ VERIFICATION │
│ & CLOSURE │
└───────────────────┘
// POST /api/analyze-image
Future<AIAnalysis> analyzeImage(String imageUrl) async {
final response = await http.post(
Uri.parse('$AI_SERVICE_URL/analyze'),
body: jsonEncode({
'image_url': imageUrl,
'analysis_type': 'civic_issue',
'return_format': 'structured_json',
}),
);
return AIAnalysis.fromJson(jsonDecode(response.body));
}// Called when:
// - New upvote received
// - Issue age crosses threshold
// - Related issues reported nearby
// - Manual admin override
Future<void> recalculatePriority(String issueId) async {
final issue = await getIssue(issueId);
final aiAnalysis = issue.aiAnalysis;
final newScore = priorityCalculator.calculatePriorityScore(issue, aiAnalysis);
await updateIssuePriority(issueId, newScore);
// Check if escalation needed
if (newScore > 80 && issue.status == IssueStatus.pending) {
await triggerEscalation(issue);
}
}The SevaSetu hierarchical system ensures:
- Intelligent Routing - Issues automatically reach the right department
- AI-Powered Analysis - Images analyzed for category, severity, and impact
- Fair Prioritization - Multi-factor scoring prevents gaming
- Population-Aware - Higher impact areas get faster response
- Emergency Handling - Chaos situations trigger immediate escalation
- Transparent Process - Citizens can track their issue through the hierarchy
This system balances automation with human oversight, ensuring efficient civic issue resolution while maintaining accountability at every level.