# osamarazzak/cryptocurrency-decision-support-system architecture

> Architecture diagram of the GitHub repository osamarazzak/cryptocurrency-decision-support-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/osamarazzak/cryptocurrency-decision-support-system
- Repository: https://github.com/osamarazzak/cryptocurrency-decision-support-system

## Overview

##### Project type and purpose
- This is a data-driven, single-page web application built with Streamlit.
- Purpose: provide investors with an interactive dashboard for fetching, preprocessing, clustering, correlation analysis, and forecasting of cryptocurrency price data.

##### File structure
- Top level:
- app.py         → Streamlit entry point, ties UI widgets to backend logic
- requirements.txt/.gitignore/README.md
- src/ subfolders:
- src/data       → data_fetcher.py (API calls), data_preprocessing.py, correlation.py, pca_kmean.py
- src/models     → forecasting_models.py (ARIMA, Prophet, LSTM, XGBoost)
- src/utils      → helper.py (common functions), visualization.py (chart building)

##### README for additional insights
- Confirms the data pipeline: fetch historical data → clean/transform → PCA+KMeans clustering → correlation heatmap → forecasting via multiple ML models → Streamlit visualization.

##### Main components and relationships
a. Components
1. User Interface (UI)
– Streamlit front end defined in app.py
2. Data Layer
– DataFetcher (external API)
– Preprocessor (clean, fill missing, feature engineering)
3. Analytics Layer
– Clustering (PCA + KMeans)
– Correlation analysis
4. Forecasting Layer
– ARIMA, Prophet, LSTM, XGBoost implementations
5. Visualization Layer
– Streamlit charts (time-series plots, heatmaps, cluster scatter)
6. Utilities
– Helper functions (caching, logging)

b. Relationships & Data flow
– User interacts with UI → UI triggers backend functions in app.py
– app.py → calls DataFetcher → returns raw price series
– raw data → DataPreprocessor → returns cleaned DataFrame
– cleaned data → split into two parallel flows:
(i) → PCA/KMeans (clustering) → cluster results
(ii) → correlation.py → correlation matrix
– cleaned data + user timeframe → forecasting_models.py → predictions
– All results → visualization.py → chart objects → Streamlit UI

c. Architectural patterns
– “Separation of concerns”: UI, data access, analytics, forecasting, and visualization each in its own module.
– Pipeline pattern: sequential data transformations feeding into analytics/forecasting.
– Modular design: swap in/out forecasting algorithms with minimal UI changes.

d. Key technologies & libraries
– Python 3.x, Streamlit
– Data science: pandas, numpy, scikit-learn (PCA, KMeans), pmdarima/ARIMA, fbprophet, tensorflow/keras (LSTM), xgboost
– Visualization: matplotlib, seaborn, Plotly (via Streamlit)

##### Essential elements
- Clear labels for each module/component
- Data modules (green)
- Analytics/Forecasting (orange)
- Utils & external services (gray)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        UI["Streamlit App (app.py)"]:::frontend
    end

    %% Data Layer
    subgraph "Data Layer"
        DF["DataFetcher"]:::data
        DP["Data Preprocessor"]:::data
    end

    %% Analytics Layer
    subgraph "Analytics Layer"
        CL["Clustering Module (PCA+KMeans)"]:::analytics
        CR["Correlation Analysis"]:::analytics
    end

    %% Forecasting Layer
    subgraph "Forecasting Layer"
        FE["Forecasting Engine"]:::forecast
        subgraph "Algorithms"
            AR["ARIMA"]:::forecast
            PR["Prophet"]:::forecast
            LS["LSTM"]:::forecast
            XG["XGBoost"]:::forecast
        end
    end

    %% Visualization Layer
    subgraph "Visualization Layer"
        VH["Visualization Helpers"]:::utils
    end

    %% Utility Layer
    subgraph "Utility Layer"
        UH["Utility Helpers"]:::utils
    end

    %% External Dependencies
    API["Crypto API Service"]:::external
    LIB["Python Libraries"]:::external

    %% Data Flow
    UI -->|"fetch request"| DF
    API -->|"price data"| DF
    DF -->|"raw data"| DP
    DP -->|"clean DataFrame"| CL
    DP -->|"clean DataFrame"| CR
    DP -->|"clean DataFrame + timeframe"| FE
    FE --> AR
    FE --> PR
    FE --> LS
    FE --> XG
    CL -->|"clusters"| VH
    CR -->|"correlation matrix"| VH
    FE -->|"predictions"| VH
    VH -->|"charts"| UI

    %% Utility & Libraries
    LIB -.-> DP
    LIB -.-> CL
    LIB -.-> CR
    LIB -.-> FE
    LIB -.-> VH
    UH -.-> UI
    UH -.-> DF
    UH -.-> DP
    UH -.-> CL
    UH -.-> CR
    UH -.-> FE
    UH -.-> VH

    %% Click Events
    click UI "https://github.com/osamarazzak/cryptocurrency-decision-support-system/blob/main/app.py"
    click DF "https://github.com/osamarazzak/cryptocurrency-decision-support-system/blob/main/src/data/data_fetcher.py"
    click DP "https://github.com/osamarazzak/cryptocurrency-decision-support-system/blob/main/src/data/data_preprocessing.py"
    click CL "https://github.com/osamarazzak/cryptocurrency-decision-support-system/blob/main/src/data/pca_kmean.py"
    click CR "https://github.com/osamarazzak/cryptocurrency-decision-support-system/blob/main/src/data/correlation.py"
    click FE "https://github.com/osamarazzak/cryptocurrency-decision-support-system/blob/main/src/models/forcasting_models.py"
    click UH "https://github.com/osamarazzak/cryptocurrency-decision-support-system/blob/main/src/utils/helper.py"
    click VH "https://github.com/osamarazzak/cryptocurrency-decision-support-system/blob/main/src/utils/visualization.py"

    %% Styles
    classDef frontend fill:#D0E6F5,stroke:#0366D6,stroke-width:1px
    classDef data fill:#DFF2DD,stroke:#228B22,stroke-width:1px
    classDef analytics fill:#FFE4B5,stroke:#FF8C00,stroke-width:1px
    classDef forecast fill:#FFDAB9,stroke:#FF8C00,stroke-width:1px
    classDef utils fill:#F0F0F0,stroke:#888888,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#666666,stroke-width:1px
```
