# ap1510/ai_based_disaster_relief_and_management_system architecture

> Architecture diagram of the GitHub repository ap1510/ai_based_disaster_relief_and_management_system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ap1510/ai_based_disaster_relief_and_management_system
- Repository: https://github.com/ap1510/ai_based_disaster_relief_and_management_system

## Overview

##### Project type and purpose
- This is a full-stack, AI-powered decision-support web application (DRAMS) built on Django.
- Purpose: end-to-end disaster management—real-time detection (fire, flood, social distancing), predictive analytics (evacuation zones), alerting/rescue coordination, and post-disaster relief planning.

##### File structure
- Top-level “DRAMS” directory contains a standard Django MVC:
- DRAMS/DRAMS (settings, URLs, ASGI/WGI) – project config
- DRAMS/uno (models, views, migrations) – application logic
- static/ & templates/ – UI assets and HTML
- Additional ML modules live alongside (firedetector, flooddetector, Social-Distance-Detector), each with config, model weights, and prediction scripts.
- Data folder “Mongo DB” contains CSVs for city, location, user data (ingested into the database).
- Training scripts (train.py), prediction scripts (predict_fire.py, predict_flood.py), and webstreaming.py support video ingestion.

##### README for architectural hints
- Describes three phases: Pre-Disaster (CNN detection + clustering), During Disaster (real-time alerts via external services & routing algorithms), Post-Disaster (connectivity restoration & relief-vehicle routing)
- Mentions Kubernetes & Django for scalable deployment.

##### Main components & their interactions
a. Frontend Layer
– Static assets (CSS/JS/HTML templates) served by Django’s view/template engine
– User interface for uploading CCTV streams, viewing alerts, feedback forms
b. Backend Layer (Django MVC)
– Request router (urls.py → uno/views/*.py)
– Controllers invoke:
- Detection services (fire/flood CNNs, social-distance YOLO)
- Clustering module (DBSCAN on geolocations)
- Routing engines (GRASP, VND algorithms)
– Data access via Django ORM (PostgreSQL or MongoDB) for: users, alerts, relief centers, road graphs
c. AI & Analytics Services (could be modeled as microservices)
– fire/flood detectors (firedetector, flooddetector packages)
– social-distance-detector module
– cluster & routing algorithm library
d. Data Storage
– Primary database (relational or MongoDB for geospatial queries)
– Flat-file CSV repository for initial ingestion
– Model artifacts folder (output/natural_disaster.model)
e. External Integrations
– Notification APIs (Aadhaar, PAN, Aarogya Setu)
– Kubernetes (deployment, scaling)
– Map/Routing APIs (if external road-network data is used)

##### Architectural patterns & design principles
- MVC pattern in Django
- Separation of concerns:
- Web tier (request handling & UI)
- AI/compute tier (disaster detection & route planning)
- Data tier (persistent storage & model artifacts)
- Modular ML microservices for each detection type
- Asynchronous task execution (could leverage Celery for long-running video analysis)
- Scalable orchestration via Kubernetes

##### Elements
- Clear labels for each component (e.g., “Django URL Router”, “Fire Detector Service”).
- Green for Django backend components
- Purple for ML/AI services
- Orange for databases & storage
- Red for external APIs

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        CSS["Static Assets (CSS/JS)"]:::frontend
        TEMPLATES["HTML Templates"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer (Django)"
        subgraph "Project Config"
            SETTINGS["settings.py"]:::backend
            URLCONF["urls.py"]:::backend
            ASGI["asgi.py"]:::backend
            WSGI["wsgi.py"]:::backend
        end
        URL["Django URL Router"]:::backend
        MODELS["Models & ORM"]:::backend
        MIGRATIONS["Migrations"]:::backend
        APPCONFIG["uno/apps.py"]:::backend
        subgraph "Controllers/Views"
            V_ALERT["alert.py"]:::backend
            V_DETECT["detect.py"]:::backend
            V_PREDICT["predictdisaster.py"]:::backend
            V_RELIEF["relief.py"]:::backend
        end
    end

    %% AI Services
    subgraph "AI Services"
        FIRE["Fire Detector Service"]:::ai
        FLOOD["Flood Detector Service"]:::ai
        SOCIAL["Social-Distance Detector"]:::ai
        CLUSTER["Clustering Module (DBSCAN)"]:::ai
        ROUTE["Routing Engines (GRASP/VND)"]:::ai
    end

    %% Data Storage
    subgraph "Data Storage"
        DB["Primary Database"]:::storage
        CSV["CSV Repository"]:::storage
        MODELS_ART["Model Artifacts"]:::storage
    end

    %% External Integrations
    subgraph "External Integrations"
        NOTIF["Notification APIs"]:::external
        K8S["Kubernetes Cluster"]:::external
        MAPAPI["Map/Routing APIs"]:::external
    end

    %% Connections
    CSS -->|serves| URL
    TEMPLATES -->|renders| URL
    URL -->|routes requests to| V_ALERT
    URL -->|routes requests to| V_DETECT
    URL -->|routes requests to| V_PREDICT
    URL -->|routes requests to| V_RELIEF
    V_ALERT -->|uses| MODELS
    V_DETECT -->|invokes| FIRE
    V_DETECT -->|invokes| FLOOD
    V_DETECT -->|invokes| SOCIAL
    V_PREDICT -->|runs| CLUSTER
    V_RELIEF -->|runs| ROUTE
    FIRE -->|stores results in| DB
    FLOOD -->|stores results in| DB
    SOCIAL -->|stores results in| DB
    CLUSTER -->|reads from| DB
    ROUTE -->|reads from| DB
    CSV -->|ingests data into| DB
    MODELS_ART -->|provides models to| FIRE
    MODELS_ART -->|provides models to| FLOOD
    MODELS_ART -->|provides models to| SOCIAL
    DB -->|query results to| V_ALERT
    V_ALERT -->|sends alerts via| NOTIF
    ROUTE -->|queries external maps| MAPAPI
    K8S -->|orchestrates| URL
    K8S -->|orchestrates| FIRE
    K8S -->|orchestrates| FLOOD
    K8S -->|orchestrates| SOCIAL

    %% Click Events
    click SETTINGS "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/blob/main/DRAMS/DRAMS/settings.py"
    click URLCONF "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/blob/main/DRAMS/DRAMS/urls.py"
    click ASGI "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/blob/main/DRAMS/DRAMS/asgi.py"
    click WSGI "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/blob/main/DRAMS/DRAMS/wsgi.py"
    click MODELS "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/blob/main/DRAMS/uno/models.py"
    click V_ALERT "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/blob/main/DRAMS/uno/views/alert.py"
    click V_DETECT "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/blob/main/DRAMS/uno/views/detect.py"
    click V_PREDICT "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/blob/main/DRAMS/uno/views/predictdisaster.py"
    click V_RELIEF "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/blob/main/DRAMS/uno/views/relief.py"
    click MIGRATIONS "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/tree/main/DRAMS/uno/migrations/"
    click APPCONFIG "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/blob/main/DRAMS/uno/apps.py"
    click CSS "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/tree/main/DRAMS/static/css/"
    click TEMPLATES "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/tree/main/DRAMS/templates/"
    click FIRE "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/tree/main/firedetector/"
    click FLOOD "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/tree/main/flooddetector/"
    click SOCIAL "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/tree/main/Social-Distance-Detector/"
    click CSV "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/tree/main/Mongo DB/"
    click MODELS_ART "https://github.com/ap1510/ai_based_disaster_relief_and_management_system/tree/main/output/natural_disaster.model/"

    %% Styles
    classDef frontend fill:#D0E6FA,stroke:#0B69A3,color:#0B69A3;
    classDef backend fill:#DFF5E1,stroke:#287233,color:#287233;
    classDef ai fill:#F0D9FF,stroke:#6A1B9A,color:#6A1B9A;
    classDef storage fill:#FFE5B4,stroke:#E57A00,color:#E57A00;
    classDef external fill:#FFE5E5,stroke:#D32F2F,color:#D32F2F;
```
