# shdyt13/bitcoin-prediction-lstm-xgboost architecture

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

- Interactive diagram: https://gitdiagram.com/shdyt13/bitcoin-prediction-lstm-xgboost
- Repository: https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost

## Overview

This is a web-based BTC/IDR forecasting decision-support system comparing standalone LSTM, standalone XGBoost, and residual-correction Hybrid models at 1-, 3-, and 7-day horizons. The principal workflow uploads training and test CSVs through the React dashboard, sends them to the Flask prediction endpoint, cleans and scales the data, creates direct-horizon windows, runs the selected model, and returns forecast and evaluation data for visualization and Excel export. An offline training path is also documented. Some frontend and model internals are only partially excerpted; edges reflect visible calls or README-described behavior.

Main entry points: [`backend/api.py`](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/api.py) (Prediction endpoint), [`backend/train.py`](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/train.py) (Offline training), [`frontend/src/App.jsx`](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/frontend/src/App.jsx) (Forecast dashboard), [`backend/utils/windowing.py`](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/windowing.py) (Direct horizon windows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_dashboard["Forecast dashboard<br/>[App.jsx]"]
  node_visualization["Charts and comparison<br/>[App.jsx]"]
  node_report["Excel report export<br/>[App.jsx]"]
end

subgraph group_api["Prediction API"]
  node_predictapi["Prediction endpoint<br/>[api.py]"]
  node_offline["Offline training<br/>[train.py]"]
  node_result["Forecast response<br/>[api.py]"]
end

subgraph group_data["Forecast preparation"]
  node_clean["CSV cleaning<br/>[preprocessing.py]"]
  node_scale["Train-fit scaling<br/>[api.py]"]
  node_windowing["Direct horizon windows<br/>[windowing.py]"]
  node_testwindows["Test context windows<br/>[api.py]"]
end

subgraph group_models["Modeling and evaluation"]
  node_lstm["LSTM forecaster<br/>[model_utils.py]"]
  node_xgb["XGBoost forecaster<br/>[model_utils.py]"]
  node_hybrid["Residual hybrid<br/>[model_utils.py]"]
  node_evaluation["Forecast evaluation<br/>[model_utils.py]"]
end

node_user(("Dashboard user"))
node_traincsv["Training CSV"]
node_testcsv["Testing CSV"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"uploads and requests"| node_predictapi
node_traincsv -->|"uploaded as training data"| node_predictapi
node_testcsv -->|"uploaded as test data"| node_predictapi
node_predictapi -->|"cleans CSVs"| node_clean
node_offline -->|"cleans CSVs"| node_clean
node_predictapi -->|"fits on training data"| node_scale
node_predictapi -->|"creates training windows"| node_windowing
node_offline -->|"creates training windows"| node_windowing
node_predictapi -->|"prepares test windows"| node_testwindows
node_testwindows -->|"creates sequences"| node_windowing
node_predictapi -->|"dispatches selected model"| node_lstm
node_predictapi -->|"dispatches selected model"| node_xgb
node_predictapi -->|"dispatches selected model"| node_hybrid
node_offline -->|"dispatches training"| node_lstm
node_offline -->|"dispatches training"| node_xgb
node_offline -->|"dispatches training"| node_hybrid
node_predictapi -->|"evaluates predictions"| node_evaluation
node_predictapi -->|"returns forecasts and metrics"| node_result
node_result -->|"supplies results"| node_dashboard
node_dashboard -->|"renders results"| node_visualization
node_dashboard -->|"exports workbook"| node_report

click node_dashboard "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/frontend/src/App.jsx"
click node_visualization "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/frontend/src/App.jsx"
click node_report "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/frontend/src/App.jsx"
click node_traincsv "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/data/Data%20Training%202020%20-%202025.csv"
click node_testcsv "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/data/Data%20Testing%202026.csv"
click node_predictapi "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/api.py"
click node_offline "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/train.py"
click node_clean "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/preprocessing.py"
click node_scale "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/api.py"
click node_windowing "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/windowing.py"
click node_testwindows "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/api.py"
click node_lstm "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/model_utils.py"
click node_xgb "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/model_utils.py"
click node_hybrid "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/model_utils.py"
click node_evaluation "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/model_utils.py"
click node_result "https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/api.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_dashboard,node_visualization,node_report,node_user toneBlue
class node_predictapi,node_offline,node_result toneAmber
class node_clean,node_scale,node_windowing,node_testwindows toneMint
class node_lstm,node_xgb,node_hybrid,node_evaluation toneRose
class node_traincsv,node_testcsv toneTeal
```

## Components

### Dashboard

- [Forecast dashboard](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Charts and comparison](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Excel report export](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### Prediction API

- [Prediction endpoint](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/api.py): `backend/api.py`
- [Offline training](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/train.py): `backend/train.py`
- [Forecast response](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/api.py): `backend/api.py`

### Forecast preparation

- [CSV cleaning](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/preprocessing.py): `backend/utils/preprocessing.py`
- [Train-fit scaling](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/api.py): `backend/api.py`
- [Direct horizon windows](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/windowing.py): `backend/utils/windowing.py`
- [Test context windows](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/api.py): `backend/api.py`

### Modeling and evaluation

- [LSTM forecaster](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/model_utils.py): `backend/utils/model_utils.py`
- [XGBoost forecaster](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/model_utils.py): `backend/utils/model_utils.py`
- [Residual hybrid](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/model_utils.py): `backend/utils/model_utils.py`
- [Forecast evaluation](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/utils/model_utils.py): `backend/utils/model_utils.py`

### Other components

- **Dashboard user**
- [Training CSV](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/data/Data%20Training%202020%20-%202025.csv): `backend/data/Data Training 2020 - 2025.csv`
- [Testing CSV](https://github.com/shdyt13/bitcoin-prediction-lstm-xgboost/blob/main/backend/data/Data%20Testing%202026.csv): `backend/data/Data Testing 2026.csv`

## Connections

- Dashboard user → Forecast dashboard: uses (evidence: `README.md`)
- Forecast dashboard → Prediction endpoint: uploads and requests (evidence: `frontend/src/App.jsx`)
- Training CSV → Prediction endpoint: uploaded as training data (evidence: `backend/api.py`)
- Testing CSV → Prediction endpoint: uploaded as test data (evidence: `backend/api.py`)
- Prediction endpoint → CSV cleaning: cleans CSVs (evidence: `backend/api.py`)
- Offline training → CSV cleaning: cleans CSVs (evidence: `backend/train.py`)
- Prediction endpoint → Train-fit scaling: fits on training data (evidence: `backend/api.py`)
- Prediction endpoint → Direct horizon windows: creates training windows (evidence: `backend/api.py`)
- Offline training → Direct horizon windows: creates training windows (evidence: `backend/train.py`)
- Prediction endpoint → Test context windows: prepares test windows (evidence: `backend/api.py`)
- Test context windows → Direct horizon windows: creates sequences (evidence: `backend/api.py`)
- Prediction endpoint → LSTM forecaster: dispatches selected model (evidence: `backend/api.py`)
- Prediction endpoint → XGBoost forecaster: dispatches selected model (evidence: `backend/api.py`)
- Prediction endpoint → Residual hybrid: dispatches selected model (evidence: `backend/api.py`)
- Offline training → LSTM forecaster: dispatches training (evidence: `backend/train.py`)
- Offline training → XGBoost forecaster: dispatches training (evidence: `backend/train.py`)
- Offline training → Residual hybrid: dispatches training (evidence: `backend/train.py`)
- Prediction endpoint → Forecast evaluation: evaluates predictions (evidence: `backend/api.py`)
- Prediction endpoint → Forecast response: returns forecasts and metrics (evidence: `backend/api.py`)
- Forecast response → Forecast dashboard: supplies results (evidence: `frontend/src/App.jsx`)
- Forecast dashboard → Charts and comparison: renders results (evidence: `README.md`)
- Forecast dashboard → Excel report export: exports workbook (evidence: `frontend/src/App.jsx`)
