niru-nny/urgency-checker
ποΈ Civic Issue Urgency Classifier
<div align="center">
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
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
Python 3.8+
pip (Python package manager)
GitInstallation
1οΈβ£ Clone the Repository
git clone https://github.com/nitish-niraj/urgency-checker.git
cd urgency-checker2οΈβ£ Install Dependencies
pip install -r requirements.txt3οΈβ£ Start the Application
python start_ui.py4οΈβ£ Open Your Browser
http://localhost:8001That's it! π The system is now running!
π» Usage
Web Interface (Recommended)
- Navigate to http://localhost:8001
- Enter your civic issue description
- Add location details (optional)
- Click "Classify Urgency"
- View instant AI analysis with recommendations
API Usage
Example 1: Single Classification
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 ServicesExample 2: Batch Processing
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
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:8001Endpoints
π Home Page
GET /Returns interactive web interface.
π Classify Civic Issue
POST /classify-urgency
Content-Type: application/json
{
"text_description": "Issue description",
"location_address": "Location (optional)",
"category": "Category (optional)"
}Response:
{
"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
GET /statsResponse:
{
"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
GET /healthResponse:
{
"status": "healthy",
"version": "1.0.0",
"timestamp": "2025-10-14T10:30:00"
}π§ͺ Demo Classification
GET /demoReturns 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
π Performance Metrics
Classification Model
System Performance
- β‘ Response Time: Fast (< 3 seconds)
- π Throughput: Multiple concurrent requests
- πΎ Memory Usage: Lightweight (~200MB)
- π Analysis: Text-only classification
π§ͺ Testing
Run Unit Tests
pytest tests/Test API Endpoint
python final_api_test.pyLoad Testing
# Install locust
pip install locust
# Run load test
locust -f tests/load_test.pyπ Deployment
Local Development
python start_ui.pyProduction (Docker)
docker build -t civic-classifier .
docker run -p 8001:8001 civic-classifierCloud Deployment (AWS/Azure/GCP)
See docs/DEPLOYMENT.md for detailed cloud deployment guides.
π€ Contributing
We welcome contributions! Here's how:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - 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
- GitHub: @nitish-niraj
- Repository: urgency-checker
π 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?
- π§ Email: nitish.niraj@example.com
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
πΊοΈ 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>
