# nadia-alsalem/financialnews architecture

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

- Interactive diagram: https://gitdiagram.com/nadia-alsalem/financialnews
- Repository: https://github.com/nadia-alsalem/financialnews

## Overview

##### Project type and purpose
- This is a full-stack machine-learning web application for **Financial News Sentiment Classification**.
- It provides a **Streamlit** front-end UI for user interaction and a **FastAPI** back-end (in `src/FastAPI/api.py`) that performs model inference using a pre-trained **Logistic Regression** model and **TF-IDF** vectorizer stored in `save model/`.

##### File structure
- Top-level files:
- `Dockerfile`, `requirements.txt` → containerization and dependencies
- `data/news.csv` → raw dataset
- `save model/…` → persisted model artifacts
- `README.md` → project overview
- `src/` directory:
- `src/data_processing.py/` → data cleaning and feature extraction logic
- `src/data_analysis.py/` → EDA and reporting scripts
- `src/model_training/` → model building and training workflows
- `src/FastAPI/api.py` → back-end service exposing a `/predict` endpoint
- No dedicated front-end folder in the tree, but the README describes a Streamlit app (presumably in a top-level or under `src/`).

##### README for additional insights
- The Streamlit UI: text input area, “Classify” button, visual effects (balloons or snow).
- Inference flow: input text → TF-IDF transform → Logistic Regression prediction → UI feedback.
- Key technologies: **Python**, **Streamlit**, **FastAPI**, **scikit-learn**, **Docker**.

##### Essential elements
- Component names (e.g., Streamlit App, FastAPI `/predict`).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Training Pipeline (Offline)
    subgraph "Training Pipeline"
        direction TB
        DataCSV["Raw Data (news.csv)"]:::data
        DataProcessing["Data Processing Module"]:::data
        DataAnalysis["Exploratory Data Analysis Module"]:::data
        ModelTraining["Model Training Module"]:::data
        DataCSV -->|"load CSV"| DataProcessing
        DataProcessing -->|"clean & extract features"| DataAnalysis
        DataAnalysis -->|"generate reports"| ModelTraining
        ModelTraining -->|"train & serialize"| TFIDF["TF-IDF Vectorizer"]:::data
        ModelTraining -->|"train & serialize"| LR["Logistic Regression Model"]:::data
    end

    %% Inference Service (Online)
    subgraph "Inference Service"
        direction TB
        User["User Browser"]:::ui
        Streamlit["Streamlit Front-end"]:::ui
        FastAPI["FastAPI Back-end Service"]:::service
        TFIDF
        LR
        User -->|"HTTP request"| Streamlit
        Streamlit -->|"REST POST /predict"| FastAPI
        FastAPI -->|"load artifacts"| TFIDF
        FastAPI -->|"load artifacts"| LR
        FastAPI -->|"JSON prediction"| Streamlit
        Streamlit -->|"display result"| User
    end

    %% Infrastructure
    subgraph "Docker Container"
        direction TB
        Streamlit
        FastAPI
        requirements["Project Dependencies (requirements.txt)"]:::infra
    end

    %% Documentation
    README["Project Overview (README.md)"]:::infra

    %% Click Events
    click FastAPI "https://github.com/nadia-alsalem/financialnews/blob/main/src/FastAPI/api.py"
    click TFIDF "https://github.com/nadia-alsalem/financialnews/blob/main/save model/tfidf_vectorizer.pkl"
    click LR "https://github.com/nadia-alsalem/financialnews/blob/main/save model/logistic_regression_model.pkl"
    click DataCSV "https://github.com/nadia-alsalem/financialnews/blob/main/data/news.csv"
    click DataProcessing "https://github.com/nadia-alsalem/financialnews/blob/main/src/data_processing.py/data_processing.py"
    click DataAnalysis "https://github.com/nadia-alsalem/financialnews/blob/main/src/data_analysis.py/data_analysis.py"
    click ModelTraining "https://github.com/nadia-alsalem/financialnews/blob/main/src/model_training/model_training.py"
    click requirements "https://github.com/nadia-alsalem/financialnews/blob/main/requirements.txt"
    click README "https://github.com/nadia-alsalem/financialnews/blob/main/README.md"

    %% Styles
    classDef ui fill:#B3DDF2,stroke:#333,stroke-width:1px
    classDef service fill:#A8E6CF,stroke:#333,stroke-width:1px
    classDef data fill:#FFD3B5,stroke:#333,stroke-width:1px
    classDef infra fill:#E0E0E0,stroke:#333,stroke-width:1px
```
