# sushil3710/btpinit architecture

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

- Interactive diagram: https://gitdiagram.com/sushil3710/btpinit
- Repository: https://github.com/sushil3710/btpinit

## Overview

##### Project type and purpose
- This is a full-stack stock-forecasting application with three main tiers:
a. A React-based frontend (“client”) for interactive charts and controls.
b. A Node.js/Express backend API (“server”) handling HTTP requests and orchestrating data.
c. A Python data-science/ML layer (“python” folder) that fetches historical stock data, trains/predicts with ARIMA/LSTM/GCN models, and persists results.
- The README confirms use of yfinance/yahoo_fin for data ingestion, Flask/plotly for visualizations in Python (e.g., notebooks), and MongoDB (pymongo) for storage.

##### File structure
- Top-level:
– client/ (React app with components under src/components)
– server/ (Node.js Express endpoints in index.js, getStock.js, getDate.js)
– python/ (data-fetch and modeling scripts, subfolder gcn for custom Graph Convolutional Network library)
– requirements.txt / package.json for dependency management
– btp2.ipynb for exploratory analysis or reporting
- Patterns:
– MVC-like separation: frontend views → backend controllers → python “model” logic → database
– python/gcn is a standalone library that can be imported by other Python scripts

##### README for additional insights
- Dependencies including Flask and plotly suggest some Python scripts (or a small Flask app) may expose a secondary API or serve dashboards.
- Instructions for dropping “predicted” collections in MongoDB imply that ML outputs are saved back into the database for retrieval.

a. Main components (containers):
1. Frontend (React SPA)
2. Backend API (Node.js/Express)
3. ML/Processing Services (Python scripts & Flask if used)
4. Data Store (MongoDB)
5. External Services (Yahoo Finance via yfinance/yahoo_fin APIs)
6. Development/Notebook Environment (Jupyter btp2.ipynb)
b. Relationships & data flows:
- React → HTTP(S) calls → Express endpoints (getStock, getDate)
- Express → Queries/updates → MongoDB
- Express → Spawns or forwards to → Python ML services (e.g., via REST/CLI invocation or message queue)
- Python ML → Fetches historical data → External Yahoo API
- Python ML → Trains models (ARIMA, LSTM, GCN) → Persists predictions → MongoDB
- React ← Receives JSON data ← Express ← Reads predictions from MongoDB
- Notebook (btp2.ipynb) ← Directly queries MongoDB or runs Python scripts for ad-hoc analysis
c. Architectural patterns & design principles:
– Separation of concerns: UI vs business logic vs data processing
– Modular ML library (python/gcn) packaged for reuse
– RESTful API between layers
– Asynchronous data pipelines (data pull & model training can be scheduled or triggered)
d. Key technologies & frameworks:
– Frontend: React, React-Router, Tailwind CSS, lightweight-charts
– Backend: Node.js, Express.js, yfinance/yahoo_fin (via Python), pymongo
– ML: pandas, openpyxl (for Excel), numpy, scipy, TensorFlow/PyTorch (as needed), custom GCN library
– Database: MongoDB

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        ReactSPA["React SPA"]:::service
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        ExpressAPI["Express API"]:::service
    end

    %% Data Science Layer
    subgraph "Data Science Layer"
        direction TB
        MLService["Python ML Service"]:::service
        subgraph "Models & Scripts"
            direction TB
            ARIMA["ARIMA & Box-Jenkins"]:::service
            LSTM["LSTM Model"]:::service
            Store["Data Ingestion & Storage"]:::service
            StocksScript["stocks.py"]:::service
            GCN["Custom GCN Library"]:::service
            FlaskAPI["Flask API (optional)"]:::service
        end
    end

    %% Persistence and External
    MongoDB[(MongoDB)]:::database
    Yahoo((Yahoo Finance API)):::external
    Notebook["Jupyter Notebook"]:::notebook

    %% Connections
    ReactSPA -->|"HTTP/JSON"| ExpressAPI
    ExpressAPI -->|"MongoDB Query"| MongoDB
    ExpressAPI -->|"REST/CLI or HTTP"| MLService
    MLService -->|"MongoDB Insert"| MongoDB
    MLService -->|"HTTP Request"| Yahoo
    Notebook -->|"Direct Query"| MongoDB
    Notebook -->|"Runs Python scripts"| MLService

    %% Click Events
    click ReactSPA "https://github.com/sushil3710/btpinit/tree/master/client/"
    click ExpressAPI "https://github.com/sushil3710/btpinit/tree/master/server/"
    click ARIMA "https://github.com/sushil3710/btpinit/tree/master/python/"
    click LSTM "https://github.com/sushil3710/btpinit/tree/master/python/ClassBased/"
    click Store "https://github.com/sushil3710/btpinit/blob/master/python/ClassBased/StoreStocks.py"
    click StocksScript "https://github.com/sushil3710/btpinit/blob/master/python/stocks.py"
    click GCN "https://github.com/sushil3710/btpinit/tree/master/python/gcn/"
    click Notebook "https://github.com/sushil3710/btpinit/blob/master/btp2.ipynb"

    %% Styles
    classDef service fill:#D0E6FF,stroke:#0366d6,stroke-width:2px
    classDef database fill:#DFFFE0,stroke:#22863a,stroke-width:2px
    classDef external fill:#F0F0F0,stroke:#6a737d,stroke-width:2px
    classDef notebook fill:none,stroke-dasharray: 5 5,stroke:#BF6,stroke-width:2px
```
