# xraptorgg/finbert-lstm architecture

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

- Interactive diagram: https://gitdiagram.com/xraptorgg/finbert-lstm
- Repository: https://github.com/xraptorgg/finbert-lstm

## Overview

##### Project type and purpose
- This is a data‐science pipeline for stock price prediction based on news sentiment.
- It implements steps from news and stock data collection, through cleaning and sentiment analysis (using FinBERT), to model training (MLP, LSTM, LSTM+BERT) and final analysis.

##### File structure
- Flat layout with numbered Python scripts indicating sequential stages:
1_news_collection.py
2_stock_data_collection.py
3_news_data_cleaning.py
4_news_sentiment_analysis.py
5_MLP_model.py
6_LSTM_model.py
7_lstm_model_bert.py
analysis.py
- Data artifacts (CSV files) store intermediate outputs: news.csv, news_data.csv, sentiment.csv, stock_price.csv
- No framework subfolders—this is a linear pipeline, not an MVC or microservice setup.

##### README for additional insights
- Purpose: replicate the paper “Deep Learning based stock price prediction using News Sentiment Analysis.”
- Key technologies: Python, FinBERT for sentiment, deep neural networks (MLP, LSTM variants).

##### Detailed guidance
- If desired, note compute resources (GPU, CPU) under model components.
- Stage’s input and output artifacts are shown explicitly.
- Keep the flow left‐to‐right (ingest → transform → train → evaluate).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Collection Layer
    subgraph "Data Collection"
        NewsAPI["News API"]:::external
        NewsCollector["News Collector"]:::process
        StockAPI["Stock Price API"]:::external
        StockCollector["Stock Price Collector"]:::process
    end

    %% Data Processing Layer
    subgraph "Data Processing"
        RawNews[(news.csv)]:::data
        Cleaning["News Cleaning Module"]:::process
        CleanNews[(news_data.csv)]:::data
    end

    %% Sentiment Analysis Layer
    subgraph "Sentiment Analysis"
        SentimentService["FinBERT Sentiment Service"]:::process
        SentimentStore[(sentiment.csv)]:::data
    end

    %% Modeling Layer
    subgraph "Modeling"
        MLP["MLP Model Trainer"]:::model
        LSTM["LSTM Model Trainer"]:::model
        LSTMBERT["LSTM+BERT Trainer"]:::model
    end

    %% Analysis & Evaluation
    Analysis["Analysis & Evaluation"]:::model
    README["README.md"]:::doc

    %% Data Store for stock prices
    StockPrice[(stock_price.csv)]:::data

    %% Connections
    NewsAPI -->|"REST"| NewsCollector -->|"CSV"| RawNews
    StockAPI -->|"REST"| StockCollector -->|"CSV"| StockPrice

    RawNews -->|"CSV"| Cleaning -->|"CSV"| CleanNews
    CleanNews -->|"CSV"| SentimentService -->|"CSV"| SentimentStore

    SentimentStore -->|"CSV"| MLP
    StockPrice -->|"CSV"| MLP

    SentimentStore -->|"CSV"| LSTM
    StockPrice -->|"CSV"| LSTM

    SentimentStore -->|"CSV"| LSTMBERT
    StockPrice -->|"CSV"| LSTMBERT

    MLP -->|"metrics"| Analysis
    LSTM -->|"metrics"| Analysis
    LSTMBERT -->|"metrics"| Analysis

    README -.-> Analysis

    %% Click Events
    click NewsCollector "https://github.com/xraptorgg/finbert-lstm/blob/main/1_news_collection.py"
    click StockCollector "https://github.com/xraptorgg/finbert-lstm/blob/main/2_stock_data_collection.py"
    click Cleaning "https://github.com/xraptorgg/finbert-lstm/blob/main/3_news_data_cleaning.py"
    click RawNews "https://github.com/xraptorgg/finbert-lstm/blob/main/news.csv"
    click CleanNews "https://github.com/xraptorgg/finbert-lstm/blob/main/news_data.csv"
    click StockPrice "https://github.com/xraptorgg/finbert-lstm/blob/main/stock_price.csv"
    click SentimentService "https://github.com/xraptorgg/finbert-lstm/blob/main/4_news_sentiment_analysis.py"
    click SentimentStore "https://github.com/xraptorgg/finbert-lstm/blob/main/sentiment.csv"
    click MLP "https://github.com/xraptorgg/finbert-lstm/blob/main/5_MLP_model.py"
    click LSTM "https://github.com/xraptorgg/finbert-lstm/blob/main/6_LSTM_model.py"
    click LSTMBERT "https://github.com/xraptorgg/finbert-lstm/blob/main/7_lstm_model_bert.py"
    click Analysis "https://github.com/xraptorgg/finbert-lstm/blob/main/analysis.py"
    click README "https://github.com/xraptorgg/finbert-lstm/blob/main/README.md"

    %% Styles
    classDef external fill:#F4A460,stroke:#333,stroke-width:1px
    classDef process fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px
    classDef model fill:#D8BFD8,stroke:#333,stroke-width:1px
    classDef doc fill:#F0E68C,stroke:#333,stroke-width:1px
```
