# laxmigs24/forest-fire-risk-project architecture

> Architecture diagram of the GitHub repository laxmigs24/forest-fire-risk-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/laxmigs24/forest-fire-risk-project
- Repository: https://github.com/laxmigs24/forest-fire-risk-project

## Overview

1. **Repository purpose**
   This is a local, end-to-end wildfire severity prediction system. It combines offline data preparation and model training with a small interactive decision-support app for inference.

2. **Primary subsystems**
   The repo has four main parts:
   - `data/`: raw dataset source
   - `notebooks/`: cleaning, EDA, and model development
   - `database/`: local SQLite storage
   - `app/`: Streamlit-based prediction interface

3. **Data layer**
   The core dataset is the UCI Forest Fires dataset, stored in `data/forestfires.names` and analyzed from within notebooks. The data contains meteorological, environmental, and fire-spread variables used to predict wildfire severity risk.

4. **Offline analytics and training workflow**
   The notebooks form the offline ML pipeline:
   - `1_data_cleaning.ipynb` prepares and transforms the dataset
   - `2_eda.ipynb` explores risk patterns and feature relationships
   - `3_modeling.ipynb` trains and evaluates classification models
   This is the main development path before deployment.

5. **Feature engineering boundary**
   The project explicitly transforms raw environmental inputs into model-ready features, including cyclical month/day encoding and wind log transformation. This feature engineering sits between raw data handling and model training.

6. **Modeling subsystem**
   Multiple classifiers were explored, but the final operational model is a threshold-tuned XGBoost classifier. The architectural emphasis is not just prediction accuracy, but improved recall for severe wildfire events.

7. **Decision threshold logic**
   A key design choice is threshold tuning away from the default 0.5 cutoff. This makes the system more sensitive to dangerous conditions and reduces false negatives, which is critical for operational wildfire risk assessment.

8. **Persistence and local storage**
   The repository includes `database/forestfireanalysis.db` for structured local data storage and analysis workflows. The README also references a persisted model artifact (`best_model.pkl`), indicating model serialization for reuse by the app.

9. **Deployment layer**
   `app/streamlit_app.py` is the runtime interface. It likely loads the trained model artifact, accepts environmental inputs, and returns a severity prediction, probability, and risk label. This is the only user-facing component in the repo.

10. **User-facing workflow**
   The app acts as a thin inference layer over the trained model. Users provide environmental conditions such as temperature, humidity, wind, drought indicators, and spread metrics; the system responds with wildfire risk assessment and alerts.

11. **Technology boundaries**
   The stack is all local and Python-based:
   - pandas/NumPy for data handling
   - scikit-learn and XGBoost for modeling
   - SQLite for persistence
   - Streamlit for UI
   - Joblib for model storage
   There is no evidence of a separate web backend or cloud service.

12. **How the pieces connect**
   The architecture flows from dataset ingestion to notebook-based preprocessing/training, then into persisted artifacts in local storage, and finally into the Streamlit app for interactive inference. In diagram terms, the main boundary is between offline model development and online prediction.

Main entry points: [`notebooks/3_modeling.ipynb`](https://github.com/laxmigs24/forest-fire-risk-project/blob/main/notebooks/3_modeling.ipynb) (Modeling), [`notebooks/1_data_cleaning.ipynb`](https://github.com/laxmigs24/forest-fire-risk-project/blob/main/notebooks/1_data_cleaning.ipynb) (Cleaning), [`app/streamlit_app.py`](https://github.com/laxmigs24/forest-fire-risk-project/blob/main/app/streamlit_app.py) (Risk App), [`notebooks/2_eda.ipynb`](https://github.com/laxmigs24/forest-fire-risk-project/blob/main/notebooks/2_eda.ipynb) (EDA)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_data["Data"]
  node_data_source["Forest Fires<br/>dataset source<br/>[forestfires.names]"]
  node_raw_inputs["Field Inputs<br/>environmental variables"]
end

subgraph group_group_offline["Offline ML"]
  node_cleaning["Cleaning<br/>notebook stage"]
  node_feature_engineering["Features<br/>feature engineering"]
  node_eda["EDA<br/>analysis notebook<br/>[2_eda.ipynb]"]
  node_modeling["Modeling<br/>training notebook<br/>[3_modeling.ipynb]"]
  node_xgboost{{"XGBoost<br/>classifier"}}
  node_threshold["Threshold<br/>decision logic"]
  node_evaluation["Recall Focus<br/>evaluation"]
end

subgraph group_group_storage["Local Storage"]
  node_model_artifact[("Best Model<br/>serialized artifact")]
  node_sqlite_db[("SQLite DB<br/>local database")]
end

subgraph group_group_app["Inference App"]
  node_streamlit_app["Risk App<br/>streamlit ui<br/>[streamlit_app.py]"]
  node_app_inputs["User Inputs<br/>form inputs"]
  node_inference["Inference<br/>prediction pipeline"]
  node_risk_output["Risk Result<br/>prediction output"]
  node_alerts["Alerts<br/>decision support"]
end

node_data_source -->|"source data"| node_cleaning
node_raw_inputs -->|"prepare"| node_cleaning
node_cleaning -->|"transform"| node_feature_engineering
node_feature_engineering -->|"analyze"| node_eda
node_feature_engineering -->|"train set"| node_modeling
node_eda -->|"insights"| node_modeling
node_modeling -->|"select"| node_xgboost
node_xgboost -->|"tune"| node_threshold
node_threshold -->|"optimize for"| node_evaluation
node_xgboost -->|"serialize"| node_model_artifact
node_modeling -->|"store results"| node_sqlite_db
node_model_artifact -->|"load model"| node_inference
node_sqlite_db -->|"local data"| node_inference
node_streamlit_app -->|"collect"| node_app_inputs
node_app_inputs -->|"predict"| node_inference
node_inference -->|"return"| node_risk_output
node_risk_output -->|"inform"| node_alerts
node_streamlit_app -->|"orchestrate"| node_inference

click node_data_source "https://github.com/laxmigs24/forest-fire-risk-project/blob/main/data/forestfires.names"
click node_cleaning "https://github.com/laxmigs24/forest-fire-risk-project/blob/main/notebooks/1_data_cleaning.ipynb"
click node_eda "https://github.com/laxmigs24/forest-fire-risk-project/blob/main/notebooks/2_eda.ipynb"
click node_modeling "https://github.com/laxmigs24/forest-fire-risk-project/blob/main/notebooks/3_modeling.ipynb"
click node_sqlite_db "https://github.com/laxmigs24/forest-fire-risk-project/blob/main/database/forestfireanalysis.db"
click node_streamlit_app "https://github.com/laxmigs24/forest-fire-risk-project/blob/main/app/streamlit_app.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_data_source,node_raw_inputs toneBlue
class node_cleaning,node_feature_engineering,node_eda,node_modeling,node_xgboost,node_threshold,node_evaluation toneAmber
class node_model_artifact,node_sqlite_db toneMint
class node_streamlit_app,node_app_inputs,node_inference,node_risk_output,node_alerts toneRose
```

## Components

### Data

Raw dataset and source metadata.

- [Forest Fires](https://github.com/laxmigs24/forest-fire-risk-project/blob/main/data/forestfires.names): dataset source · UCI Forest Fires dataset metadata and raw data basis. · `data/forestfires.names`
- **Field Inputs**: environmental variables · Temperature, humidity, wind, drought, and fire-spread variables.

### Offline ML

Notebook-driven preparation, analysis, and training.

- [Cleaning](https://github.com/laxmigs24/forest-fire-risk-project/blob/main/notebooks/1_data_cleaning.ipynb): notebook stage · Transforms and prepares the raw dataset for analysis. · `notebooks/1_data_cleaning.ipynb`
- **Features**: feature engineering · Creates model-ready inputs such as cyclical month/day encoding and wind log transforms.
- [EDA](https://github.com/laxmigs24/forest-fire-risk-project/blob/main/notebooks/2_eda.ipynb): analysis notebook · Explores risk patterns and feature relationships. · `notebooks/2_eda.ipynb`
- [Modeling](https://github.com/laxmigs24/forest-fire-risk-project/blob/main/notebooks/3_modeling.ipynb): training notebook · Trains and evaluates classification models for wildfire severity. · `notebooks/3_modeling.ipynb`
- **XGBoost**: classifier · Final operational model chosen for prediction performance and recall on severe events.
- **Threshold**: decision logic · Tuneable cutoff that shifts predictions away from the default 0.5 to reduce false negatives.
- **Recall Focus**: evaluation · Emphasizes sensitivity to dangerous wildfire conditions over raw accuracy.

### Local Storage

Persistent artifacts used across analysis and inference.

- **Best Model**: serialized artifact · Persisted trained model reused by the app.
- [SQLite DB](https://github.com/laxmigs24/forest-fire-risk-project/blob/main/database/forestfireanalysis.db): local database · Structured local storage for analysis workflows and persisted data. · `database/forestfireanalysis.db`

### Inference App

Streamlit decision-support interface for wildfire risk prediction.

- [Risk App](https://github.com/laxmigs24/forest-fire-risk-project/blob/main/app/streamlit_app.py): streamlit ui · Interactive inference interface for wildfire severity prediction. · `app/streamlit_app.py`
- **User Inputs**: form inputs · Environmental conditions entered by a user in the app.
- **Inference**: prediction pipeline · Loads the model artifact, prepares inputs, and generates predictions.
- **Risk Result**: prediction output · Returns severity prediction, probability, and risk label.
- **Alerts**: decision support · Operational guidance for dangerous wildfire conditions.

## Connections

- Forest Fires → Cleaning: source data · Raw dataset feeds notebook-based preparation.
- Field Inputs → Cleaning: prepare · Environmental variables are cleaned and normalized.
- Cleaning → Features: transform · Prepared data is converted into model-ready features.
- Features → EDA: analyze · Engineered variables are inspected for patterns and relationships.
- Features → Modeling: train set · Feature set is used for model development.
- EDA → Modeling: insights · Exploratory findings inform modeling choices.
- Modeling → XGBoost: select · Best-performing classifier becomes the final model.
- XGBoost → Threshold: tune · Decision cutoff is adjusted for higher recall on severe events.
- Threshold → Recall Focus: optimize for · Threshold choice is driven by recall and false-negative reduction.
- XGBoost → Best Model: serialize · Trained model is saved for reuse.
- Modeling → SQLite DB: store results · Analysis artifacts and structured data support local workflows.
- Best Model → Inference: load model · App runtime loads the persisted classifier.
- SQLite DB → Inference: local data · Local persistence can support app-side analysis or lookup.
- Risk App → User Inputs: collect · UI accepts user-supplied environmental conditions.
- User Inputs → Inference: predict · Inputs are prepared and passed to the model.
- Inference → Risk Result: return · Pipeline produces probability and severity label.
- Risk Result → Alerts: inform · Prediction is translated into operational wildfire guidance.
- Risk App → Inference: orchestrate · UI coordinates the end-to-end prediction flow.
