# mohsinalijoo/fake-news-classifier architecture

> Architecture diagram of the GitHub repository mohsinalijoo/fake-news-classifier, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohsinalijoo/fake-news-classifier
- Repository: https://github.com/mohsinalijoo/fake-news-classifier

## Overview

This Flask application classifies manually entered news and fetched live articles, returning a label and confidence score. Its separate training script prepares text, fits and evaluates a TF-IDF/XGBoost model, and saves artifacts that the web application loads. The source confirms these flows; the referenced model files and dataset files are not present in the supplied tree.

Main entry points: [`app.py`](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/app.py) (Flask application), [`train_model.py`](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/train_model.py) (Training workflow), [`templates/index.html`](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/templates/index.html) (Web interface), [`data_preparation.py`](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/data_preparation.py) (Text cleaning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_page["Web interface<br/>[index.html]"]
  node_webapp["Flask application<br/>[app.py]"]
end

subgraph group_inference["Classification"]
  node_cleaning["Text cleaning"]
  node_vectorizer["TF-IDF vectorizer<br/>[app.py]"]
  node_classifier["XGBoost classifier<br/>[app.py]"]
end

subgraph group_training["Model training"]
  node_training["Training workflow<br/>[train_model.py]"]
  node_artifacts[("Model artifacts<br/>[train_model.py]")]
end

node_visitor(("News reader"))
node_newsapi["NewsAPI"]
node_datasets[("Training datasets")]

node_visitor -->|"uses"| node_page
node_page -->|"submits input"| node_webapp
node_webapp -->|"cleans text"| node_cleaning
node_webapp -->|"transforms text"| node_vectorizer
node_webapp -->|"predicts label"| node_classifier
node_webapp -.->|"fetches articles"| node_newsapi
node_webapp -->|"renders results"| node_page
node_datasets -->|"provides data"| node_training
node_training -->|"cleans text"| node_cleaning
node_training -->|"fits features"| node_vectorizer
node_training -->|"fits and evaluates"| node_classifier
node_training -->|"saves model"| node_artifacts
node_artifacts -->|"loaded at startup"| node_webapp

click node_page "https://github.com/mohsinalijoo/fake-news-classifier/blob/main/templates/index.html"
click node_webapp "https://github.com/mohsinalijoo/fake-news-classifier/blob/main/app.py"
click node_cleaning "https://github.com/mohsinalijoo/fake-news-classifier/blob/main/data_preparation.py"
click node_vectorizer "https://github.com/mohsinalijoo/fake-news-classifier/blob/main/app.py"
click node_classifier "https://github.com/mohsinalijoo/fake-news-classifier/blob/main/app.py"
click node_training "https://github.com/mohsinalijoo/fake-news-classifier/blob/main/train_model.py"
click node_artifacts "https://github.com/mohsinalijoo/fake-news-classifier/blob/main/train_model.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_page,node_webapp toneBlue
class node_cleaning,node_vectorizer,node_classifier,node_datasets toneAmber
class node_training,node_artifacts,node_newsapi toneMint
class node_visitor toneIndigo
```

## Components

### Web experience

- [Web interface](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/templates/index.html): `templates/index.html`
- [Flask application](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/app.py): `app.py`

### Classification

- [Text cleaning](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/data_preparation.py): `data_preparation.py`
- [TF-IDF vectorizer](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/app.py): `app.py`
- [XGBoost classifier](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/app.py): `app.py`

### Model training

- [Training workflow](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/train_model.py): `train_model.py`
- [Model artifacts](https://github.com/mohsinalijoo/fake-news-classifier/blob/main/train_model.py): `train_model.py`

### Other components

- **News reader**
- **NewsAPI**
- **Training datasets**

## Connections

- News reader → Web interface: uses
- Web interface → Flask application: submits input
- Flask application → Text cleaning: cleans text
- Flask application → TF-IDF vectorizer: transforms text
- Flask application → XGBoost classifier: predicts label
- Flask application → NewsAPI: fetches articles
- Flask application → Web interface: renders results
- Training datasets → Training workflow: provides data
- Training workflow → Text cleaning: cleans text
- Training workflow → TF-IDF vectorizer: fits features
- Training workflow → XGBoost classifier: fits and evaluates
- Training workflow → Model artifacts: saves model
- Model artifacts → Flask application: loaded at startup
