CoolFace
Apppublic

niru-nny/urgency-checker

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
App README

πŸ›οΈ Civic Issue Urgency Classifier

<div align="center">

Version Python License Status

AI-Powered Text Analysis System for Government Civic Issue Prioritization

Features β€’ Demo β€’ Installation β€’ Usage β€’ API Docs β€’ Architecture

</div>


πŸ“– Overview

The Civic Issue Urgency Classifier is an AI-powered text analysis system that analyzes citizen-submitted civic issue descriptions and automatically assigns urgency scores (Low/Medium/High) for efficient government response prioritization.

🎯 Problem Statement

Government agencies receive thousands of civic issue reports daily. Manual triage is:

  • —⏰ Time-consuming - Hours wasted sorting reports
  • β€”βŒ Inconsistent - Different staff = different priorities
  • β€”πŸš¨ Risky - Critical issues may be delayed
  • β€”πŸ’° Expensive - Requires dedicated staff

✨ Our Solution

Automated AI-powered text classification system that:

  • β€”πŸ€– Analyzes text descriptions using NLP sentiment analysis and TF-IDF
  • β€”οΏ½ Scores urgency levels with confidence metrics
  • β€”πŸ’ Routes issues to appropriate departments automatically
  • β€”βš‘ Responds instantly with actionable recommendations
Note: Image analysis is currently unavailable. The system performs text-only classification.

🌟 Features

Core Capabilities

FeatureDescriptionStatus
πŸ”€ Text AnalysisNLP-based sentiment analysis + TF-IDF vectorizationβœ… Active
πŸ€– AI ClassificationRandomForest model for urgency predictionβœ… Active
🎯 Smart RoutingAutomatic department assignmentβœ… Active
⏱️ Response EstimationAI-predicted resolution timeβœ… Active
πŸ–ΌοΈ Image AnalysisComputer vision for damage detection⚠️ Coming Soon

Technical Features

  • β€”βœ… Production-Ready API - FastAPI with async support
  • β€”βœ… Real-time Processing - 2-3 second response time
  • β€”βœ… Batch Processing - Handle multiple issues simultaneously
  • β€”βœ… Health Monitoring - Built-in health checks and stats
  • β€”βœ… Interactive UI - Modern iOS 26-inspired liquid design
  • β€”βœ… Comprehensive Logging - Full audit trail
  • β€”βœ… Scalable Architecture - Cloud-ready deployment

πŸš€ Quick Start

Prerequisites

bash
Python 3.8+
pip (Python package manager)
Git

Installation

1️⃣ Clone the Repository

bash
git clone https://github.com/nitish-niraj/urgency-checker.git
cd urgency-checker

2️⃣ Install Dependencies

bash
pip install -r requirements.txt

3️⃣ Start the Application

bash
python start_ui.py

4️⃣ Open Your Browser

http://localhost:8001

That's it! πŸŽ‰ The system is now running!


πŸ’» Usage

Web Interface (Recommended)

  1. 1.Navigate to http://localhost:8001
  2. 2.Enter your civic issue description
  3. 3.Add location details (optional)
  4. 4.Click "Classify Urgency"
  5. 5.View instant AI analysis with recommendations

API Usage

Example 1: Single Classification
python
import requests

# Prepare civic issue data
data = {
    "text_description": "Dangerous cracks in road near hospital. Fix ASAP!",
    "location_address": "Near University Hospital",
    "category": "Infrastructure"
}

# Send classification request
response = requests.post(
    "http://localhost:8001/classify-urgency",
    json=data
)

result = response.json()
print(f"Urgency: {result['urgency_level']}")  # HIGH
print(f"Score: {result['urgency_score']}/10")  # 8.5/10
print(f"Department: {result['recommended_department']}")  # Emergency Services
Example 2: Batch Processing
python
import requests

# Multiple civic issues
issues = [
    {"text_description": "Fire hazard in building!", "location_address": "Downtown"},
    {"text_description": "Minor graffiti on bench", "location_address": "City Park"}
]

# Batch classification
response = requests.post(
    "http://localhost:8001/batch-classify",
    json={"issues": issues}
)

results = response.json()
for i, result in enumerate(results['results']):
    print(f"Issue {i+1}: {result['urgency_level']}")
Example 3: System Health Check
python
import requests

response = requests.get("http://localhost:8001/health")
health = response.json()

print(f"Status: {health['status']}")  # healthy
print(f"Version: {health['version']}")  # 1.0.0

πŸ“Š API Documentation

Base URL

http://localhost:8001

Endpoints

🏠 Home Page
http
GET /

Returns interactive web interface.

πŸ” Classify Civic Issue
http
POST /classify-urgency
Content-Type: application/json

{
  "text_description": "Issue description",
  "location_address": "Location (optional)",
  "category": "Category (optional)"
}

Response:

json
{
  "urgency_level": "HIGH",
  "urgency_score": 8.5,
  "confidence": 0.92,
  "recommended_department": "Emergency Services",
  "estimated_response_time": "Within 1 hour",
  "reasoning": "AI detected high urgency based on keywords: 'dangerous', 'cracks', 'hospital', 'ambulance'. Immediate action required for public safety.",
  "location_context": "Hospital",
  "safety_context": "Emergency"
}
πŸ“Š System Statistics
http
GET /stats

Response:

json
{
  "service_name": "Civic Issue Urgency Classifier",
  "status": "operational",
  "model_info": {
    "text_classifier": "TextBlob + TF-IDF",
    "ai_model": "RandomForest Ensemble",
    "analysis_type": "Text-based NLP"
  },
  "performance_metrics": {
    "avg_response_time": "< 3 seconds",
    "total_requests": 247,
    "status": "Active"
  }
}
πŸ’š Health Check
http
GET /health

Response:

json
{
  "status": "healthy",
  "version": "1.0.0",
  "timestamp": "2025-10-14T10:30:00"
}
πŸ§ͺ Demo Classification
http
GET /demo

Returns sample classification for testing.


πŸ—οΈ Architecture

System Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     Web Interface (UI)                      β”‚
β”‚              iOS 26-inspired Liquid Design                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   FastAPI REST API                          β”‚
β”‚            (Request Handling & Routing)                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  AI Classification Engine                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                        β”‚
β”‚  β”‚ Text Analysisβ”‚  β”‚ AI Classifierβ”‚                        β”‚
β”‚  β”‚  (NLP + TF- β”‚  β”‚ (RandomForestβ”‚                        β”‚
β”‚  β”‚     IDF)     β”‚  β”‚   Ensemble)  β”‚                        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β”‚
                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                Classification Output                        β”‚
β”‚  β€’ Urgency Level (HIGH/MEDIUM/LOW)                         β”‚
β”‚  β€’ Department Routing                                       β”‚
β”‚  β€’ Response Time Estimation                                 β”‚
β”‚  β€’ Action Recommendations                                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Technology Stack

Backend:

  • β€”πŸ Python 3.8+
  • β€”βš‘ FastAPI (Modern async web framework)
  • β€”πŸ€– scikit-learn (Machine Learning)
  • β€”πŸ“ TextBlob (NLP & Sentiment Analysis)
  • β€”πŸ”’ NumPy & Pandas (Data Processing)

Frontend:

  • β€”πŸŽ¨ HTML5 + CSS3 (Liquid Design)
  • β€”βš‘ Vanilla JavaScript (No frameworks needed)
  • β€”πŸŽ­ Glassmorphism UI
  • β€”πŸ“± Responsive Design

AI Models:

  • β€”πŸ“Š RandomForest Classifier (Ensemble)
  • β€”πŸ“ TF-IDF Vectorizer (Text Features)
  • β€”οΏ½ TextBlob (Sentiment Analysis)
  • β€”πŸŽ― Custom Feature Engineering

πŸ“ Project Structure

urgency-checker/
β”œβ”€β”€ πŸ“„ README.md                        # This file
β”œβ”€β”€ πŸ“„ requirements.txt                 # Python dependencies
β”œβ”€β”€ πŸ“„ start_ui.py                      # Easy startup script
β”‚
β”œβ”€β”€ πŸ“ src/                             # Source code
β”‚   β”œβ”€β”€ demo_api_browser.py             # Main API server
β”‚   β”œβ”€β”€ step5_advanced_fusion.py        # AI fusion model
β”‚   β”œβ”€β”€ text_preprocessing.py           # Text analysis
β”‚   β”œβ”€β”€ integrate_fire_dataset.py       # Fire dataset integration
β”‚   └── update_enhanced_metadata.py     # Dataset management
β”‚
β”œβ”€β”€ πŸ“ static/                          # UI assets
β”‚   β”œβ”€β”€ πŸ“ css/
β”‚   β”‚   β”œβ”€β”€ styles.css                  # Main liquid design CSS
β”‚   β”‚   └── animations.css              # Animation effects
β”‚   β”œβ”€β”€ πŸ“ js/
β”‚   β”‚   β”œβ”€β”€ main.js                     # Main interactions
β”‚   β”‚   └── animations.js               # UI animations
β”‚   └── πŸ“ images/                      # Icons & backgrounds
β”‚
β”œβ”€β”€ πŸ“ templates/                       # HTML templates
β”‚   β”œβ”€β”€ index.html                      # Landing page
β”‚   β”œβ”€β”€ classify.html                   # Classification UI
β”‚   └── dashboard.html                  # Stats dashboard
β”‚
β”œβ”€β”€ πŸ“ data/                            # Training data
β”‚   β”œβ”€β”€ πŸ“ images_enhanced/             # Image dataset
β”‚   β”‚   β”œβ”€β”€ HIGH/ (30 fire images)
β”‚   β”‚   β”œβ”€β”€ MEDIUM/ (30 images)
β”‚   β”‚   └── LOW/ (30 images)
β”‚   └── civic_issues.csv                # Text dataset
β”‚
β”œβ”€β”€ πŸ“ models/                          # Trained models
β”‚   β”œβ”€β”€ text_classifier.pkl
β”‚   β”œβ”€β”€ image_classifier.pkl
β”‚   └── fusion_model.pkl
β”‚
β”œβ”€β”€ πŸ“ logs/                            # Application logs
β”‚   └── api.log
β”‚
└── πŸ“ docs/                            # Documentation
    β”œβ”€β”€ AI_MODELS_EXPLANATION.md
    β”œβ”€β”€ TEXT_SENTIMENT_ANALYSIS.md
    └── IMAGE_SAMPLES_EXPLANATION.md

🎨 UI Design Philosophy

Our interface follows Apple's iOS 26 Liquid Design principles:

Design Elements

ElementDescription
GlassmorphismFrosted glass effects with backdrop blur
Fluid AnimationsSmooth 60fps transitions
Gradient BackgroundsDynamic multi-color gradients
Soft ShadowsElevated UI components
Rounded CornersOrganic, friendly shapes
Interactive FeedbackHover, focus, and click animations
ResponsiveMobile, tablet, and desktop optimized

πŸ“ˆ Performance Metrics

Classification Model

ComponentStatusDescription
Text Classifierβœ… ActiveNLP-based urgency analysis
AI Ensembleβœ… ActiveRandomForest classification
Image Analysis⚠️ Coming SoonComputer vision integration planned

System Performance

  • β€”βš‘ Response Time: Fast (< 3 seconds)
  • β€”πŸ”„ Throughput: Multiple concurrent requests
  • β€”πŸ’Ύ Memory Usage: Lightweight (~200MB)
  • β€”πŸ“Š Analysis: Text-only classification

πŸ§ͺ Testing

Run Unit Tests

bash
pytest tests/

Test API Endpoint

bash
python final_api_test.py

Load Testing

bash
# Install locust
pip install locust

# Run load test
locust -f tests/load_test.py

πŸš€ Deployment

Local Development

bash
python start_ui.py

Production (Docker)

bash
docker build -t civic-classifier .
docker run -p 8001:8001 civic-classifier

Cloud Deployment (AWS/Azure/GCP)

See docs/DEPLOYMENT.md for detailed cloud deployment guides.


🀝 Contributing

We welcome contributions! Here's how:

  1. 1.Fork the repository
  2. 2.Create a feature branch (git checkout -b feature/AmazingFeature)
  3. 3.Commit your changes (git commit -m 'Add AmazingFeature')
  4. 4.Push to the branch (git push origin feature/AmazingFeature)
  5. 5.Open a Pull Request

Development Guidelines

  • β€”βœ… Follow PEP 8 style guide
  • β€”βœ… Add unit tests for new features
  • β€”βœ… Update documentation
  • β€”βœ… Ensure all tests pass

πŸ“ Use Cases

Government Agencies

  • β€”πŸ›οΈ Municipal governments
  • β€”πŸš“ Public safety departments
  • β€”πŸ—οΈ Infrastructure maintenance
  • β€”πŸŒ³ Parks & recreation

Smart Cities

  • β€”πŸ“± Citizen reporting apps
  • β€”πŸ—ΊοΈ Urban planning systems
  • β€”πŸš¦ Traffic management
  • β€”πŸŒ IoT integration

Private Sector

  • β€”πŸ’ Property management
  • β€”πŸ¨ Facility management
  • β€”πŸš— Fleet operations
  • β€”πŸ“ž Customer service

πŸŽ“ Research & References

This project implements techniques from:

  • β€”NLP: TextBlob sentiment analysis, TF-IDF vectorization
  • β€”Machine Learning: RandomForest ensemble classification
  • β€”UI/UX: Apple Human Interface Guidelines, iOS 26 design system
  • β€”API Design: RESTful architecture with FastAPI

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘₯ Authors

Nitish Niraj


πŸ™ Acknowledgments

  • β€”TextBlob - Natural language processing library
  • β€”FastAPI - Modern web framework for building APIs
  • β€”FastAPI - Modern Python web framework
  • β€”scikit-learn - Machine learning library
  • β€”Apple Design Team - iOS 26 design inspiration

πŸ“ž Support

Need help? Have questions?


πŸ—ΊοΈ Roadmap

Version 1.1 (Coming Soon)

  • β€”[ ] Mobile app (iOS & Android)
  • β€”[ ] Real-time notifications
  • β€”[ ] Multi-language support
  • β€”[ ] Advanced analytics dashboard
  • β€”[ ] Integration with 311 systems

Version 2.0 (Future)

  • β€”[ ] Deep learning models (YOLO, ResNet)
  • β€”[ ] Video analysis support
  • β€”[ ] Predictive maintenance
  • β€”[ ] Blockchain audit trail
  • β€”[ ] GraphQL API

<div align="center">

⭐ Star this repository if you find it helpful!

Made with ❀️ for smarter government services

Report Bug β€’ Request Feature

</div>