# sidhanth-s/elec-predict architecture

> Architecture diagram of the GitHub repository sidhanth-s/elec-predict, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sidhanth-s/elec-predict
- Repository: https://github.com/sidhanth-s/elec-predict

## Overview

##### Project type and purpose
- This is a full-stack web application (“Forecastly”) for time-series forecasting of electricity demand and price.
- It consists of:
- A React/TailwindCSS frontend (TypeScript/JavaScript)
- A Flask/Python backend exposing JSON REST endpoints
- Pre-trained Prophet ML models + scalers
- Static dataset files for retraining

##### File structure
- Top level:
- app.py, train.py, model_*.pkl, scaler.pkl → Flask server + training scripts + serialized ML artifacts
- public/, index.html → static HTML entrypoint
- src/ → React application (pages, components, hooks, UI library wrappers, chart components)
- requirements.txt → Python deps for backend
- package.json, vite.config.ts, tsconfig.json → Frontend deps & build config
- Patterns:
- Single-page React app built with Vite
- Flask monolith exposing /forecast endpoint
- Chart.js embedded in React components
- Utility layers (src/lib, src/utils)

##### README for additional insights
- Sequence:
1. User picks date range in UI
2. Frontend calls Flask API
3. Flask loads Prophet models
4. Forecasts returned as JSON
5. Frontend renders tables & charts
- Tech stack clearly enumerated

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Web Browser"]:::uiLayer
        React["React Frontend App"]:::uiLayer
        UIlib["UI Component Library"]:::uiLayer
        ChartComponents["Chart Components"]:::uiLayer
    end

    %% API Layer
    subgraph "API Layer"
        JSONReq["JSON Request (POST /forecast)"]:::apiLayer
        Flask["Flask Backend (app.py)"]:::apiLayer
        JSONRes["JSON Response (dates[], demand[], price[])"]:::apiLayer
    end

    %% Data/ML Layer
    subgraph "Data/ML Layer"
        MD["model_demand.pkl"]:::dataLayer
        MR["model_rrp.pkl"]:::dataLayer
        SC["scaler.pkl"]:::dataLayer
        Dataset["cleaned_dataset.csv"]:::dataLayer
        Train["train.py"]:::dataLayer
    end

    %% Connections
    Browser --> React
    React -->|"send JSON request"| JSONReq
    JSONReq --> Flask
    Flask -->|"load demand model"| MD
    Flask -->|"load price model"| MR
    Flask -->|"load scaler"| SC
    Flask -->|"run forecast"| Flask
    Flask --> JSONRes
    JSONRes -->|"receive JSON response"| React
    React -->|"render charts & tables"| ChartComponents
    React --> UIlib

    %% Retraining pipeline
    Dataset -->|"read raw data"| Train
    Train -->|"generate new models"| MD
    Train --> MD
    Train --> MR
    Train --> SC

    %% Click Events
    click React "https://github.com/sidhanth-s/elec-predict/tree/main/src/"
    click Browser "https://github.com/sidhanth-s/elec-predict/blob/main/index.html"
    click UIlib "https://github.com/sidhanth-s/elec-predict/tree/main/src/components/ui/"
    click ChartComponents "https://github.com/sidhanth-s/elec-predict/tree/main/src/components/chart/"
    click Flask "https://github.com/sidhanth-s/elec-predict/blob/main/app.py"
    click MD "https://github.com/sidhanth-s/elec-predict/blob/main/model_demand.pkl"
    click MR "https://github.com/sidhanth-s/elec-predict/blob/main/model_rrp.pkl"
    click SC "https://github.com/sidhanth-s/elec-predict/blob/main/scaler.pkl"
    click Dataset "https://github.com/sidhanth-s/elec-predict/blob/main/cleaned_dataset.csv"
    click Train "https://github.com/sidhanth-s/elec-predict/blob/main/train.py"

    %% Styles
    classDef uiLayer fill:#D6E4FF,stroke:#4C6EF5,color:#000
    classDef apiLayer fill:#E6F4EA,stroke:#37B24D,color:#000
    classDef dataLayer fill:#FFF4E6,stroke:#F08C00,color:#000
```
