# basvapriyanka/ai-assisted-climate-change-mitigation-tool architecture

> Architecture diagram of the GitHub repository basvapriyanka/ai-assisted-climate-change-mitigation-tool, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool
- Repository: https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool

## Overview

##### Project type and purpose
- This is a full-stack, data-driven web application with an embedded ML model.
- Purpose: provide an AI-Assisted Climate Change Mitigation Tool that analyzes time-series climate data (CSV) using a pre-trained LSTM model, and exposes results via a web UI.

##### File structure
- Data & model artifacts:
- Beutenberg_2023_7-12.csv, Beutenberg_2024_1-11.csv (raw time-series inputs)
- model.h5 (pre-trained LSTM)
- scaler.pkl (data preprocessor)
- Notebook: LSTM_Climate.ipynb (exploration, training, experimentation)
- Backend: app.py (Flask/FastAPI server exposing model inference endpoints)
- Frontend:
- index.html, index (1).html
- index.js (AJAX calls to backend)
- reset.css, style.css (styling)
- README.md describes purpose; no service orchestration files (Docker, k8s).

##### Architecture components
a. Frontend (Browser)
- index.html + CSS for layout
- index.js implements HTTP requests to the backend for predictions and history charts.
b. Backend (Python App)
- app.py loads scaler.pkl and model.h5 on startup
- Exposes REST endpoints (e.g., /predict, /history)
- Reads raw CSV or incoming data, applies scaler, runs LSTM inference, returns JSON.
c. Data Store
- CSV files on disk act as data sources for historical inputs.
- Optionally swap in a database in future.
d. Machine Learning
- LSTM model (.h5) and scaler (.pkl) encapsulate the core ML logic.
e. User’s Browser & External Services
- Browser consumes REST API, renders results (charts, tables).
- No external cloud services currently.

##### Relationships & interactions
- User → Frontend: loads index.html, interacts with UI controls.
- Frontend → Backend: AJAX calls to app.py REST endpoints.
- Backend → ML Model: app.py loads and queries model and scaler for predictions.
- Backend → Data Files: reads CSV for historical data, writes logs as needed.
- Backend → Frontend: returns JSON payloads.

##### Architectural patterns & design principles
- MVC-lite:
- View: HTML/CSS/JS
- Controller: index.js triggering HTTP
- Model: Python LSTM and scaler
- Separation of concerns: data processing and business logic in backend; presentation in frontend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        IndexHTML["index.html"]:::frontend
        Index1HTML["index (1).html"]:::frontend
        IndexJS["index.js"]:::frontend
        ResetCSS["reset.css"]:::frontend
        StyleCSS["style.css"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        App["app.py (REST API)"]:::backend
    end

    %% ML Artifacts
    subgraph "Machine Learning Artifacts"
        Model["model.h5"]:::ml
        Scaler["scaler.pkl"]:::ml
    end

    %% Data Store
    subgraph "Data Store"
        CSV2023["Beutenberg_2023_7-12.csv"]:::data
        CSV2024["Beutenberg_2024_1-11.csv"]:::data
    end

    %% Development Notebook
    subgraph "Development"
        Notebook["LSTM_Climate.ipynb"]:::dev
    end

    %% Documentation
    subgraph "Documentation"
        Readme["README.md"]:::doc
    end

    %% User Interaction
    User["User"]:::frontend

    %% Relationships
    User -->|"loads UI"| IndexHTML
    User -->|"loads UI"| Index1HTML
    IndexHTML -->|"includes"| IndexJS
    Index1HTML -->|"includes"| IndexJS
    IndexJS -->|"POST /predict (JSON)"| App
    IndexJS -->|"GET /history (JSON)"| App
    App -->|"loads on startup"| Model
    App -->|"loads on startup"| Scaler
    App -->|"reads CSV (CSV)"| CSV2023
    App -->|"reads CSV (CSV)"| CSV2024
    App -->|"returns JSON"| IndexJS
    Notebook -->|"produced"| Model
    Notebook -->|"produced"| Scaler
    Readme -->|"describes purpose"| User

    %% Click Events
    click IndexHTML "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/index.html"
    click Index1HTML "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/index (1).html"
    click IndexJS "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/index.js"
    click ResetCSS "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/reset.css"
    click StyleCSS "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/style.css"
    click App "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/app.py"
    click CSV2023 "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/Beutenberg_2023_7-12.csv"
    click CSV2024 "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/Beutenberg_2024_1-11.csv"
    click Model "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/model.h5"
    click Scaler "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/scaler.pkl"
    click Notebook "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/LSTM_Climate.ipynb"
    click Readme "https://github.com/basvapriyanka/ai-assisted-climate-change-mitigation-tool/blob/main/README.md"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ml fill:#FFA500,stroke:#000,stroke-width:1px
    classDef data fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef dev fill:#FFE4B5,stroke:#000,stroke-width:1px
    classDef doc fill:#F5F5F5,stroke:#000,stroke-width:1px
```
