# himanshu-kushwaha0/srilanka_landslide_prediction architecture

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

- Interactive diagram: https://gitdiagram.com/himanshu-kushwaha0/srilanka_landslide_prediction
- Repository: https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction

## Overview

This is a Sri Lanka landslide susceptibility and risk-analysis toolkit with a Flask exploration app. The documented workflow processes spatial data, derives susceptibility, combines it with rainfall and historical events for risk estimates, then produces maps and charts for users to explore. The app also provides chatbot-based risk interpretation, with local and cloud LLM options. The README documents the main `Scripts/` stages, but those sources were not sampled; links for that pipeline reflect documentation, while model and app connections are limited to the supplied excerpts.

Main entry points: [`APP/landslide_app/app.py`](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/app.py) (Flask application), [`Scripts/preprocessing.py`](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/Scripts/preprocessing.py) (Preprocessing), [`APP/Prediction Script/landslide_model_v2_filtered.py`](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/Prediction%20Script/landslide_model_v2_filtered.py) (Risk modeling), [`Scripts/phase1_susceptibility.py`](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/Scripts/phase1_susceptibility.py) (Susceptibility analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Spatial Analysis"]
  node_spatialdata[("District GIS data")]
  node_preprocess["Preprocessing<br/>[preprocessing.py]"]
  node_susceptibility["Susceptibility analysis"]
end

subgraph group_risk["Risk Modeling"]
  node_suscout[("Susceptibility layers")]
  node_riskmodel["Risk modeling"]
  node_riskout[("Year-wise risk outputs")]
  node_riskmaps["Risk map rendering<br/>[visualise_risk.py]"]
end

subgraph group_web["Web Exploration"]
  node_webapp["Flask application<br/>[app.py]"]
  node_ui["Web interface<br/>[index.html]"]
  node_mapassets["Map assets"]
end

subgraph group_chat["Chatbot"]
  node_chatui["Chat widget"]
  node_chatintegration["Chat integration"]
  node_rag["Risk-aware RAG"]
  node_chatengine["Chat engine<br/>[chatbot_engine.py]"]
  node_llm{{"LLM providers"}}
end

node_user(("Analyst"))
node_ollama{{"Ollama"}}
node_cloudllm{{"Cloud LLM APIs"}}

node_user -->|"runs analysis"| node_preprocess
node_spatialdata -->|"reads layers"| node_preprocess
node_preprocess -->|"creates features"| node_susceptibility
node_susceptibility -->|"writes layers"| node_suscout
node_suscout -->|"reads susceptibility"| node_riskmodel
node_riskmodel -->|"writes risk"| node_riskout
node_riskout -->|"renders maps"| node_riskmaps
node_user -->|"requests views"| node_webapp
node_webapp -->|"serves page"| node_ui
node_webapp -->|"reads layers"| node_suscout
node_webapp -->|"reads results"| node_riskout
node_webapp -->|"launches model"| node_riskmodel
node_webapp -->|"serves maps"| node_mapassets
node_user -->|"asks questions"| node_chatui
node_chatui -->|"submits query"| node_chatintegration
node_chatintegration -->|"dispatches query"| node_rag
node_rag -->|"uses engine"| node_chatengine
node_chatengine -->|"requests response"| node_llm
node_llm -.->|"calls provider"| node_ollama
node_llm -.->|"calls provider"| node_cloudllm

click node_spatialdata "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/tree/main/Preprocess_Data/Vector_Output"
click node_preprocess "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/Scripts/preprocessing.py"
click node_susceptibility "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/Scripts/phase1_susceptibility.py"
click node_riskmodel "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/Prediction%20Script/landslide_model_v2_filtered.py"
click node_riskmaps "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/Prediction%20Script/visualise_risk.py"
click node_webapp "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/app.py"
click node_ui "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/templates/index.html"
click node_mapassets "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/tree/main/APP/landslide_app/static/maps"
click node_chatui "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/templates/chatbot_advanced_widget.html"
click node_chatintegration "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/chatbot_flask_integration.py"
click node_rag "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/chatbot_advanced.py"
click node_chatengine "https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/chatbot_engine.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_spatialdata,node_preprocess,node_susceptibility toneBlue
class node_suscout,node_riskmodel,node_riskout,node_riskmaps toneAmber
class node_webapp,node_ui,node_mapassets,node_cloudllm toneMint
class node_chatui,node_chatintegration,node_rag,node_chatengine,node_llm toneRose
class node_user,node_ollama toneIndigo
```

## Components

### Spatial Analysis

- [District GIS data](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/tree/main/Preprocess_Data/Vector_Output): `Preprocess_Data/Vector_Output`
- [Preprocessing](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/Scripts/preprocessing.py): `Scripts/preprocessing.py`
- [Susceptibility analysis](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/Scripts/phase1_susceptibility.py): `Scripts/phase1_susceptibility.py`

### Risk Modeling

- **Susceptibility layers**
- [Risk modeling](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/Prediction%20Script/landslide_model_v2_filtered.py): `APP/Prediction Script/landslide_model_v2_filtered.py`
- **Year-wise risk outputs**
- [Risk map rendering](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/Prediction%20Script/visualise_risk.py): `APP/Prediction Script/visualise_risk.py`

### Web Exploration

- [Flask application](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/app.py): `APP/landslide_app/app.py`
- [Web interface](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/templates/index.html): `APP/landslide_app/templates/index.html`
- [Map assets](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/tree/main/APP/landslide_app/static/maps): `APP/landslide_app/static/maps`

### Chatbot

- [Chat widget](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/templates/chatbot_advanced_widget.html): `APP/landslide_app/templates/chatbot_advanced_widget.html`
- [Chat integration](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/chatbot_flask_integration.py): `APP/landslide_app/chatbot_flask_integration.py`
- [Risk-aware RAG](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/chatbot_advanced.py): `APP/landslide_app/chatbot_advanced.py`
- [Chat engine](https://github.com/himanshu-kushwaha0/srilanka_landslide_prediction/blob/main/APP/landslide_app/chatbot_engine.py): `APP/landslide_app/chatbot_engine.py`
- **LLM providers**

### Other components

- **Analyst**
- **Ollama**
- **Cloud LLM APIs**

## Connections

- Analyst → Preprocessing: runs analysis
- District GIS data → Preprocessing: reads layers
- Preprocessing → Susceptibility analysis: creates features
- Susceptibility analysis → Susceptibility layers: writes layers
- Susceptibility layers → Risk modeling: reads susceptibility
- Risk modeling → Year-wise risk outputs: writes risk
- Year-wise risk outputs → Risk map rendering: renders maps
- Analyst → Flask application: requests views
- Flask application → Web interface: serves page
- Flask application → Susceptibility layers: reads layers
- Flask application → Year-wise risk outputs: reads results
- Flask application → Risk modeling: launches model
- Flask application → Map assets: serves maps
- Analyst → Chat widget: asks questions
- Chat widget → Chat integration: submits query
- Chat integration → Risk-aware RAG: dispatches query
- Risk-aware RAG → Chat engine: uses engine
- Chat engine → LLM providers: requests response
- LLM providers → Ollama: calls provider
- LLM providers → Cloud LLM APIs: calls provider
