Skip to content

ishivatiwari/SafeSphere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšจ SafeSphere AI

Predictive Crowd Intelligence System for Large-Scale Events

SafeSphere AI is an AI-powered system designed to predict, prevent, and manage crowd risks in large-scale events like the Kumbh Mela. It enables real-time decision-making to avoid stampedes, optimize crowd movement, and improve public safety.


๐ŸŒ Problem Statement

Large gatherings often suffer from:

  • Sudden crowd surges
  • Poor real-time visibility
  • Lack of predictive intelligence
  • High risk of stampedes

Traditional systems are reactive, responding only after congestion occurs.


๐Ÿ’ก Solution

SafeSphere AI introduces a predictive AI command system that:

  • Monitors crowd density across zones
  • Detects high-risk and critical areas
  • Predicts crowd buildup trends
  • Suggests dynamic rerouting strategies
  • Generates real-time alerts

๐Ÿง  Key Features

  • ๐Ÿ“Š Crowd Density Analysis
  • โš ๏ธ Risk Detection (High / Critical / Stampede Risk)
  • ๐Ÿ”ฎ Predictive Intelligence (Trend Forecasting)
  • ๐Ÿ”€ Smart Crowd Rerouting
  • ๐Ÿ“ข Real-Time Alerts
  • ๐Ÿงฉ Structured JSON API for easy integration

๐Ÿ—๏ธ System Architecture

Simulated Data โ†’ AI Agent (Antigravity + Gemini) โ†’ Cloud Run API โ†’ JSON Response

๐Ÿ”— Google Cloud Integration

  • Deployed on Google Cloud Run (serverless, scalable)

  • Uses Gemini API for AI decision-making

  • Designed for integration with:

    • Google Firestore (real-time data storage)
    • Pub/Sub (event-driven updates)
    • Cloud Logging (monitoring & debugging)

โš™๏ธ Efficiency & Performance

  • Lightweight processing for low-latency responses
  • Optimized decision logic to minimize compute overhead
  • Designed for real-time scalability using serverless architecture
  • Supports future enhancements like caching and batch processing

๐Ÿ” Security

  • API keys managed via environment variables
  • Secure deployment using Google Cloud infrastructure
  • Designed with controlled access patterns

โ™ฟ Accessibility

  • Simple and intuitive REST API
  • Structured JSON responses for easy consumption
  • Clear error handling and validation
  • Designed for integration with dashboards and assistive systems

๐Ÿ“ก API Usage

Endpoint

POST /analyze

Request Example

{
  "zones": [
    {"zone_id": "A1", "density": 85, "movement_speed": 1.2},
    {"zone_id": "B2", "density": 95, "movement_speed": 0.4}
  ]
}

Response Example

{
  "zone_status": [
    {
      "zone_id": "B2",
      "density_level": "Critical",
      "risk_level": "Stampede Risk",
      "trend": "Increasing"
    }
  ],
  "actions": [
    "Redirect crowd from Zone B2 to Zone C1"
  ],
  "alerts": [
    "Avoid Zone B2 due to heavy congestion"
  ]
}

๐Ÿงช Testing

Basic test coverage is implemented to validate core functionality.

Example Test Case

def test_analyze_endpoint():
    response = client.post("/analyze", json={
        "zones": [{"zone_id": "A1", "density": 90, "movement_speed": 0.5}]
    })
    assert response.status_code == 200

Test Coverage Includes:

  • โœ… Normal scenarios
  • โš ๏ธ High-risk scenarios
  • โ— Edge cases (empty input / invalid data)

๐Ÿ› ๏ธ Setup & Deployment

1. Clone Repository

git clone https://github.com/YOUR_USERNAME/safesphere.git
cd safesphere

2. Install Dependencies

pip install -r requirements.txt

3. Configure Environment

GEMINI_API_KEY=your_api_key_here

4. Run Locally

python app.py

5. Deploy to Cloud Run

gcloud run deploy safesphere-api --source .

๐ŸŽฏ Use Cases

  • Religious gatherings (e.g., Kumbh Mela)
  • Sports stadiums
  • Concerts and festivals
  • Smart city crowd management

๐Ÿ“ˆ Future Enhancements

  • Real-time CCTV integration
  • IoT sensor-based tracking
  • Live dashboard with heatmaps
  • Automated emergency response system
  • Multi-agent orchestration

๐Ÿ“Œ Disclaimer

This is a prototype system using simulated data, designed for demonstration and scalability.


๐Ÿ‘จโ€๐Ÿ’ป Author

Developed by Shiva Tiwari


โญ Support

If you find this project useful, consider giving it a โญ on GitHub!

About

SafeSphere AI is a predictive crowd intelligence system that analyzes real-time crowd dynamics to prevent stampedes, optimize movement, and enhance safety at large-scale events.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors