GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com โ€” GitHub - JosephJonathanFernandes/CrowdSense: Intelligent disaster detection platform analyzing tweets in real-time using anomaly detection, spaCy NER, and Leaflet visualization with Twilio SMS integration.

BranchesTags
Open more actions menu

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
core
core
 
 
docs
docs
 
 
simulation
simulation
 
 
tests
tests
 
 
utils
utils
 
 
web
web
 
 
.env.example
.env.example
 
 
.flake8
.flake8
 
 
.gitignore
.gitignore
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
.python-version
.python-version
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
PROJECT_STRUCTURE.md
PROJECT_STRUCTURE.md
 
 
README.md
README.md
 
 
SECURITY_CHECKLIST.md
SECURITY_CHECKLIST.md
 
 
ai_crowdsense_v2.py
ai_crowdsense_v2.py
 
 
crowdsense.db
crowdsense.db
 
 
crowdsense.log
crowdsense.log
 
 
crowdsense.py
crowdsense.py
 
 
main.py
main.py
 
 
pyproject.toml
pyproject.toml
 
 
requirements.txt
requirements.txt
 
 
run.py
run.py
 
 
setup.cfg
setup.cfg
 
 
simulate.py
simulate.py
 
 
test.py
test.py
 
 
uv.lock
uv.lock
 
 

Repository files navigation

๐ŸŒ CrowdSense Enhanced โ€“ AI-Powered Real-Time Disaster Detection System

CrowdSense Enhanced is an AI-powered early warning system that detects potential disasters in real time by analyzing live tweets, news feeds, and sensor data. It uses machine learning, anomaly detection, and NLP to identify unusual spikes in disaster-related chatter and sends instant alerts to users and authorities.

This enhanced version includes realistic disaster simulation, advanced anomaly detection, database-backed metrics, and a full-featured web dashboard.


โœจ Features

๐Ÿ”น Core Capabilities

  • Real-time Twitter keyword monitoring (via Tweepy API)
  • NLP-based classification of disaster-related tweets (NLTK, spaCy, scikit-learn)
  • NewsAPI verification to reduce false positives
  • Threshold-based and anomaly-based alerting
  • Optional SMS notifications via Twilio

๐Ÿ”น New Enhancements

  1. Live Data Integration

    • Web dashboard connected to backend (/api/data, /api/map-data)
    • Auto-refresh every 5 minutes & manual refresh button
  2. SQLite Database Storage

    • Tables for alerts, tweets, metrics, and logs
    • Historical data storage & trend analysis
    • Automated cleanup of old data
  3. Smart Anomaly Detection

    • Z-score + EWMA-based detection
    • Historical data learning (past 24โ€“48 hrs)
    • Adaptive thresholds
  4. Location Extraction & Map Visualization

    • spaCy NER + OpenStreetMap geocoding
    • Interactive map (Leaflet.js) with tweet markers
    • Location-based filtering
  5. Background Task Scheduler

    • Proper scheduling with schedule library
    • Multi-task execution & monitoring
    • Graceful shutdown + retry logic
  6. Structured Logging & Metrics

    • Real-time metrics (tweets processed, alerts sent, errors)
    • Performance monitoring (API latency, execution times)
    • Structured contextual logging
  7. Disaster Simulation System (๐Ÿ†•)

    • Trigger realistic disaster scenarios (earthquake, flood, fire, storm, tsunami)
    • Severity levels: moderate, major, severe
    • Realistic tweet generation + SMS alerts
    • Interactive simulation controls on web dashboard

โš™๏ธ Tech Stack

  • Backend: Python (Flask)
  • APIs: Tweepy (Twitter API), Twilio (SMS), NewsAPI, OpenStreetMap (geocoding)
  • ML/NLP: scikit-learn, NLTK, spaCy
  • Database: SQLite (default) / PostgreSQL (optional)
  • Frontend: HTML, CSS, JavaScript, Leaflet.js / Google Maps

๐Ÿš€ Quick Start

1. Install Dependencies

pip install -r requirements.txt
python -m spacy download en_core_web_sm

2. Setup Environment Variables

Create a .env file:

TWITTER_BEARER_TOKEN=your_twitter_token  # Optional in simulation mode
NEWS_API_KEY=your_news_api_key           # Optional in simulation mode
TWILIO_SID=your_twilio_sid               # Required for SMS alerts
TWILIO_AUTH_TOKEN=your_twilio_token      # Required for SMS alerts
TWILIO_PHONE=your_twilio_phone           # Required for SMS alerts
MY_PHONE=your_phone_number               # Required for SMS alerts

3. Run the System

๐Ÿงช Simulation Mode (Recommended)

python simulate.py earthquake
python simulate.py flood --severity severe
python simulate.py -i   # Interactive
python main.py simulation
  • Dashboard: http://localhost:5000
  • Click disaster buttons to trigger scenarios
  • Receive real SMS alerts!

๐ŸŒ Production Mode (Live APIs)

python crowdsense.py
python main.py web
  • Dashboard: http://localhost:5000

Background Monitoring

python main.py background

Single Analysis (Testing)

python main.py single

Component Testing

python main.py test

๐Ÿ“Š Dashboard Features

  • Real-time status indicator (SAFE / ALERT / ERROR)
  • Live tweet feed with location badges
  • Interactive global map with disaster markers
  • System metrics: processed tweets, alerts, errors
  • Recent alerts + verified news integration
  • Sentiment analysis charts

๐Ÿ”ง Configuration

Anomaly Detection (in anomaly_detection.py)

detector = AnomalyDetector(
    window_size=15,
    ewma_alpha=0.3,
    z_threshold=2.5
)

Scheduler (in scheduler.py)

scheduler.add_task(
    name="fetch_tweets",
    func=fetch_and_analyze_tweets,
    interval_minutes=1,
    run_immediately=True
)

Database

  • Default: crowdsense.db (SQLite)
  • Auto-cleanup: Tweets >7 days, Logs >30 days

๐Ÿ“ˆ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Web Dashboard โ”‚    โ”‚  Background      โ”‚    โ”‚    Database     โ”‚
โ”‚  - Live Data    โ”‚โ—„โ”€โ”€โ”€โ”ค  Scheduler       โ”œโ”€โ”€โ”€โ–บโ”‚  - Alerts       โ”‚
โ”‚  - Map Visual   โ”‚    โ”‚  - Tweet Fetch   โ”‚    โ”‚  - Tweets       โ”‚
โ”‚  - Analytics    โ”‚    โ”‚  - Anomaly Det   โ”‚    โ”‚  - Metrics      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚  - Logging       โ”‚    โ”‚  - Logs         โ”‚
                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                โ”‚
                                โ–ผ
                       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                       โ”‚  External APIs   โ”‚
                       โ”‚  - Twitter API   โ”‚
                       โ”‚  - News API      โ”‚
                       โ”‚  - Geocoding     โ”‚
                       โ”‚  - Twilio SMS    โ”‚
                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿงช Testing

python location_extraction.py   # Test NER + geocoding
python anomaly_detection.py     # Test anomaly detection
python database.py              # Test DB operations
python scheduler.py             # Test scheduler

๐Ÿ“‹ Monitoring & Maintenance

  • Logs: crowdsense.log + DB logs (system_logs table)
  • Auto-cleanup of old tweets/logs
  • Metrics available via /api/stats
  • Backup: Copy crowdsense.db

๐Ÿ”’ Security

  • All secrets in .env
  • API rate limiting + retry logic
  • Sanitized tweet input before DB storage
  • Structured error handling and logging

๐Ÿค Contributing

  1. Add new disaster keywords in DISASTER_KEYWORDS (in crowdsense_enhanced.py)
  2. Extend anomaly detection by creating new detectors
  3. Add new API endpoints in hackathon_app/app.py
  4. Update database schema (database.py) for new features

๐Ÿ“ License

This enhanced version maintains the same license as the original CrowdSense project.


โœ… Production-ready system with full monitoring, logging, simulation, and anomaly detection.

About

Intelligent disaster detection platform analyzing tweets in real-time using anomaly detection, spaCy NER, and Leaflet visualization with Twilio SMS integration.

Topics

anomaly-detectionewmaleafletjsmlnerpython3spacy-nlpzscore

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

3 stars

Watchers

0 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.