# vatshayan/fake-news-detection-project architecture

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

- Interactive diagram: https://gitdiagram.com/vatshayan/fake-news-detection-project
- Repository: https://github.com/vatshayan/fake-news-detection-project

## Overview

##### Main Components
a. Data Sources:
- Four real-world news datasets (CSV/JSON files).
b. Data Ingestion & Storage:
- File system or a lightweight local database (e.g., SQLite) where raw datasets reside.
c. Data Preprocessing Module:
- Text cleaning (tokenization, stop-word removal, stemming/lemmatization).
- Handling missing values, normalization.
d. Feature Engineering Module:
- Extraction of textual properties (n-grams, TF-IDF, readability scores, sentiment features).
e. Machine Learning Models:
- Individual classifiers (e.g., Logistic Regression, SVM, Decision Tree).
f. Ensemble Learning Module:
- Combiner that takes individual model outputs and applies voting or stacking.
g. Model Evaluation Module:
- Cross-validation, performance metrics (accuracy, precision, recall, F1-score).
h. User Interface / Execution Layer:
- Jupyter Notebook (fake_news_code_d.ipynb) for interactive exploration.
- Python script (fake_news_code_d.py) for batch runs.
i. Output & Persistence:
- Trained model artifacts (pickle files).
- Evaluation reports and visualizations (plots, logs).

##### Call Out Key Architectural Patterns
- Pipeline Architecture: clearly show linear stages.
- Ensemble Pattern: group individual model components feeding into a central “Ensemble Combiner.”

##### Technologies & Frameworks
- Data modules: pandas, NumPy
- Text processing: NLTK/spaCy, scikit-learn’s feature‐extraction
- Models & ensemble: scikit-learn
- Notebook: Jupyter
- File-based persistence: model.pkl, metrics.csv in an “Artifacts” storage bucket.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Interface Entry Points
    UI_JN["Jupyter Notebook"]:::interface
    UI_CLI["CLI Script"]:::interface
    DOC["Project Documentation\n(README.md)"]:::interface

    %% Data Source
    DS(("News Datasets\n(CSV/JSON)")):::data

    %% Pipeline Stages
    ING["Data Ingestion & Storage\n(pandas, NumPy\nSQLite/Filesystem"]:::processing
    PRE["Data Preprocessing\n(tokenization, stop-word removal,\nstemming/lemmatization)"]:::processing
    ENG["Feature Engineering\n(n-grams, TF-IDF,\nreadability, sentiment)"]:::processing

    subgraph "Modeling"
        direction TB
        LR["Logistic Regression\n(scikit-learn)"]:::model
        SVM["Support Vector Machine\n(scikit-learn)"]:::model
        DT["Decision Tree\n(scikit-learn)"]:::model
        ENS["Ensemble Combiner\n(voting, stacking)"]:::model
    end

    EVAL["Model Evaluation\n(cross-validation,\naccuracy, precision, recall,\nF1-score)"]:::evaluation
    ART(("Artifacts\nmodel.pkl\nmetrics.csv")):::evaluation

    %% Data Flow
    UI_JN -->|starts pipeline| ING
    UI_CLI -->|starts pipeline| ING
    DOC -.->|configuration reference| ING

    DS -->|raw data| ING
    ING -->|raw text| PRE
    PRE -->|cleaned text| ENG
    ENG -->|features matrix| LR
    ENG -->|features matrix| SVM
    ENG -->|features matrix| DT

    LR -->|predictions| ENS
    SVM -->|predictions| ENS
    DT -->|predictions| ENS

    ENS -->|combined predictions| EVAL
    EVAL -->|evaluation metrics| ART

    %% Click Events
    click UI_JN "https://github.com/vatshayan/fake-news-detection-project/blob/main/fake_news_code_d.ipynb"
    click UI_CLI "https://github.com/vatshayan/fake-news-detection-project/blob/main/fake_news_code_d.py"
    click DOC "https://github.com/vatshayan/fake-news-detection-project/blob/main/README.md"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef processing fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef model fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef evaluation fill:#DDA0DD,stroke:#333,stroke-width:1px;
    classDef interface fill:#D3D3D3,stroke:#333,stroke-width:1px;
```
