Skip to content

adix57/AlertNest

Repository files navigation

🛡️ AlertNest: Integrated Emergency Response MVP

A robust, hackathon-ready emergency notification and response system. Features an AI-driven Django backend and a Real-time Flutter Dashboard with WebSocket synchronization.


🏗️ Architecture

  • Backend (/backend): Python Django + Django Channels server.
    • AI Engine: TensorFlow/Keras Dense Neural Network for intent and severity classification.
    • Database: Django ORM with SQLite for local persistence.
    • Real-time: WebSockets (via Daphne) for instant incident broadcasting and live chat.
  • Frontend (/frontend): Flutter Cross-Platform App.
    • Dashboard: Live feed of active incidents categorized by severity.
    • Triage: Detail view with live team chat and incident resolution.

🚀 Getting Started

1. Backend Setup (Python / Django)

Ensure you have Python 3.8+ installed (3.12 recommended).

# Navigate to backend
cd backend

# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Environment Variables

Create a .env file in the backend/ directory by copying the example:

cp .env.example .env

Ensure you fill out any required settings inside backend/.env.

Database Setup

Run the initial Django migrations to set up the SQLite database:

python manage.py migrate

🧠 AI Models & Priority Engine

AlertNest utilizes a dual-model AI architecture:

  1. NLP Classifier (nlp_model.keras): Categorizes text intents (FIRE, MEDICAL, SECURITY).
  2. Emergency Priority Engine (epe_model.keras): A dual-input regression model that ranks incidents by severity, risk, and urgency.

The repository includes pre-trained weights for both models. You do not need to re-train them unless you modify the training datasets.

🚀 Direct Usage (No Training Required)

Since pre-trained weights are included, you can start the system immediately:

  1. Start the Backend: python manage.py runserver (The models load into memory automatically).
  2. Test Inference: Run python demo_epe.py to see the AI prioritize emergencies without any setup.

Note: You only need to run the scripts in the "Optional Training" section below if you want to rebuild the AI logic from scratch.

(Optional) Training the Models

If you wish to update or re-train the models with new data:

1. Base NLP Classifier:

# GPU (Recommended)
python train_model.py
# CPU Fallback
python train_model_cpu.py

2. Emergency Priority Engine (EPE):

# Generate synthetic priority data first
python generate_epe_data.py
# Train the EPE regression model
python train_epe.py

Run the Server

Start the Django ASGI development server (so WebSockets and HTTP requests work simultaneously):

python manage.py runserver 0.0.0.0:8000
  • API Base: http://127.0.0.1:8000/
  • Websocket: ws://127.0.0.1:8000/ws/
  • Tandem Model Demo: Run python demo_epe.py to see the NLP Classifer and Priority Engine work in tandem—the output will show both the incident type and its priority score in a single ranked JSON payload.

2. Frontend Setup (Flutter)

In a new terminal, ensure you have the Flutter SDK installed.

# Navigate to frontend
cd frontend

# Fetch dependencies
flutter pub get

# (Linux Users Only) Enable Desktop Support if testing natively
flutter config --enable-linux-desktop
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev

Launch the UI

You can run the app on your connected device, emulator, or as a native desktop/web app:

flutter run

(If testing web compatibility, you can serve using flutter run -d web-server or flutter run -d chrome)


🛠️ Key Hackathon Features

  1. Smart AI Classification: Text input like "Smoke in the lobby" ➔ Categorized as [FIRE] - HIGH SEVERITY instantly via TensorFlow.
  2. Live Desk: The dashboard updates instantly via WebSockets without refreshing.
  3. One-Click Resolve: Responding to an incident clears it from all connected responder screens in real-time.

📁 Repository Structure

  • backend/: Django project (alertnest), Channels WebSocket routing (core), models, and TensorFlow model scripts.
  • frontend/: Flutter source code, UI components, and platform runners.
  • backend/tokenizer.json: Word index mapping for the AI engine.
  • backend/nlp_model.keras: Base classifier weights.
  • backend/epe_model.keras: Emergency Priority Engine weights (fully trained).

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors