# ammar8065/earthquake-disaster-predictions architecture

> Architecture diagram of the GitHub repository ammar8065/earthquake-disaster-predictions, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ammar8065/earthquake-disaster-predictions
- Repository: https://github.com/ammar8065/earthquake-disaster-predictions

## Overview

##### Project Type and Purpose
- This is a data-driven, machine-learning based prediction system.
- Its primary purposes are earthquake magnitude prediction (via an LSTM model), impact assessment (using a Random Forest classifier), and resource allocation (via a greedy algorithm). Visualizations help interpret the results.
- The execution environment is a Jupyter Notebook that integrates data processing, model training, and real-time visualizations.

##### Analyzing the File Structure
- Key files:
- Earthquake Disaster Prediction.ipynb: Contains the main code for data ingestion, preprocessing, model implementation, and visualization.
- earthquake_map.html and magnitude_plot.html: Standalone interactive visualizations generated by Folium and Plotly.
- README.md: Provides a complete system description, algorithm details, and instructions.
- The lean structure indicates that the system is built as a prototype or educational/portfolio project rather than a multi-tier microservices system.

##### Main Components and Their Relationships
- Data Input & Ingestion:
- Represents loading datasets (e.g., usgs_main.csv and usgs_current.csv from Kaggle, as mentioned in the README).
- Preprocessing and data cleaning operations.

- Machine Learning Modules:
- Magnitude Prediction Module: This module uses the LSTM model to forecast future earthquake magnitudes.
- Impact Assessment Module: Uses a Random Forest Classifier to classify earthquake events by impact into Low, Moderate, and Severe.

- Resource Allocation Module:
- Implements a greedy algorithm that assigns resources (rescue teams, food, water, etc.) based on the impact severity from the classification.

- Visualization Components:
- Time-series Plot: Generated via Plotly to show earthquake magnitudes over time.
- Interactive Map: Generated via Folium to display the geographical locations of events and their severity.

- Execution Environment:
- The Jupyter Notebook acts as an integrator that orchestrates all the above modules. It may also serve as the interface to view the outputs such as visualizations.

##### Architectural Patterns/Design Principles
- Although not strictly layered as in a full-stack application, the notebook organizes the workflow in a sequential pipeline:
Data ingestion → Preprocessing → Model training/evaluation → Resource allocation → Visualization.
- This separation of concerns can be visually represented as distinct blocks or modules connected in sequence.

- Annotations regarding technologies or frameworks used (e.g., Python 3.11, TensorFlow, scikit-learn, Plotly, Folium).

## Diagram (Mermaid)

```mermaid
flowchart TD
    DS["Data Sources (CSV): usgs_main.csv, usgs_current.csv"]:::source
    DIP["Data Ingestion & Preprocessing: Loads and cleans USGS data"]:::ingestion
    JE["Execution Environment (Jupyter Notebook): Orchestrates processes"]:::orchestrator

    subgraph "Machine Learning Modules"
        LSTM["LSTM Magnitude Prediction Module: Predicts earthquake magnitudes"]:::ml
        RF["Random Forest Impact Assessment Module: Classifies impact severity"]:::ml
    end

    RA["Resource Allocation Module: Greedy algorithm for resource assignment"]:::resource

    subgraph "Visualization Components"
        TS["Time-series Visualization (Plotly): Displays magnitude trends"]:::visualization
        IM["Interactive Map Visualization (Folium): Shows event locations"]:::visualization
    end

    DS -->|"provides data"| DIP
    DIP -->|"cleans data"| JE
    JE -->|"triggers"| LSTM
    JE -->|"triggers"| RF
    LSTM -->|"feeds predictions"| RA
    RF -->|"feeds classifications"| RA
    RA -->|"renders"| TS
    RA -->|"renders"| IM

    click DIP "https://github.com/ammar8065/earthquake-disaster-predictions/blob/main/Earthquake Disaster Prediction.ipynb"
    click JE "https://github.com/ammar8065/earthquake-disaster-predictions/blob/main/Earthquake Disaster Prediction.ipynb"
    click LSTM "https://github.com/ammar8065/earthquake-disaster-predictions/blob/main/Earthquake Disaster Prediction.ipynb"
    click RF "https://github.com/ammar8065/earthquake-disaster-predictions/blob/main/Earthquake Disaster Prediction.ipynb"
    click RA "https://github.com/ammar8065/earthquake-disaster-predictions/blob/main/Earthquake Disaster Prediction.ipynb"
    click TS "https://github.com/ammar8065/earthquake-disaster-predictions/blob/main/magnitude_plot.html"
    click IM "https://github.com/ammar8065/earthquake-disaster-predictions/blob/main/earthquake_map.html"

    classDef source fill:#cff,stroke:#333,stroke-width:2px;
    classDef ingestion fill:#f9f,stroke:#333,stroke-width:2px;
    classDef orchestrator fill:#fc9,stroke:#333,stroke-width:2px;
    classDef ml fill:#ff9,stroke:#333,stroke-width:2px;
    classDef resource fill:#9f9,stroke:#333,stroke-width:2px;
    classDef visualization fill:#9ff,stroke:#333,stroke-width:2px;
```
