# bijen-maharjan56/fake_news_detection_system architecture

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

- Interactive diagram: https://gitdiagram.com/bijen-maharjan56/fake_news_detection_system
- Repository: https://github.com/bijen-maharjan56/fake_news_detection_system

## Overview

This Flask application accepts political headlines or articles, classifies them as REAL or FAKE, and returns a confidence score and influential words. The main workflow runs from the browser through the prediction API into text cleaning, political-news validation, TF-IDF feature generation, and the saved classifier. A separate retraining workflow builds artifacts from the CSV dataset. The README also documents rejecting non-political input and displaying results; unsampled templates and dataset details are represented only at their supported paths.

Main entry points: [`model.py`](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py) (Training workflow), [`static/js/script.js`](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/static/js/script.js) (Prediction interface), [`app.py`](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/app.py) (Flask routes), [`templates`](https://github.com/bijen-maharjan56/fake_news_detection_system/tree/main/templates) (Web pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_pages["Web pages"]
  node_browser["Prediction interface<br/>[script.js]"]
  node_flask["Flask routes<br/>[app.py]"]
  node_api["Prediction endpoint<br/>[app.py]"]
end

subgraph group_inference["Prediction"]
  node_cleaning["Text cleaning<br/>[model.py]"]
  node_political["Political filter<br/>[model.py]"]
  node_features["TF-IDF features<br/>[model.py]"]
  node_classifier["News classifier<br/>[model.py]"]
  node_explanations["Prediction details<br/>[model.py]"]
end

subgraph group_training["Model training"]
  node_train_entry["Training command<br/>[train_model.py]"]
  node_training_logic["Training workflow<br/>[model.py]"]
  node_dataset["Labeled dataset<br/>[final_dataset.csv]"]
end

subgraph group_artifacts["Model artifacts"]
  node_saved_model["Classifier artifact<br/>[model.pkl]"]
  node_saved_vectorizer["Word vectorizer"]
end

node_user(("News reader"))

node_user -->|"opens"| node_pages
node_flask -->|"renders"| node_pages
node_user -->|"enters news"| node_browser
node_browser -->|"posts news"| node_api
node_api -->|"calls prediction"| node_cleaning
node_cleaning -->|"checks text"| node_political
node_political -->|"accepts political text"| node_features
node_features -->|"supplies features"| node_classifier
node_classifier -->|"provides prediction"| node_explanations
node_api -->|"returns JSON"| node_browser
node_browser -->|"shows results"| node_user
node_train_entry -->|"calls training"| node_training_logic
node_training_logic -->|"reads"| node_dataset
node_training_logic -->|"writes"| node_saved_model
node_training_logic -->|"writes"| node_saved_vectorizer
node_flask -->|"loads"| node_saved_model
node_flask -->|"loads"| node_saved_vectorizer

click node_pages "https://github.com/bijen-maharjan56/fake_news_detection_system/tree/main/templates"
click node_browser "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/static/js/script.js"
click node_flask "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/app.py"
click node_api "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/app.py"
click node_cleaning "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py"
click node_political "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py"
click node_features "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py"
click node_classifier "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py"
click node_explanations "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py"
click node_train_entry "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/train_model.py"
click node_training_logic "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py"
click node_dataset "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/datasets/final_dataset.csv"
click node_saved_model "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.pkl"
click node_saved_vectorizer "https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/word_vectorizer.pkl"

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_pages,node_browser,node_flask,node_api toneBlue
class node_cleaning,node_political,node_features,node_classifier,node_explanations toneAmber
class node_train_entry,node_training_logic,node_dataset toneMint
class node_saved_model,node_saved_vectorizer toneRose
class node_user toneIndigo
```

## Components

### Web interface

- [Web pages](https://github.com/bijen-maharjan56/fake_news_detection_system/tree/main/templates): `templates`
- [Prediction interface](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/static/js/script.js): `static/js/script.js`
- [Flask routes](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/app.py): `app.py`
- [Prediction endpoint](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/app.py): `app.py`

### Prediction

- [Text cleaning](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py): `model.py`
- [Political filter](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py): `model.py`
- [TF-IDF features](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py): `model.py`
- [News classifier](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py): `model.py`
- [Prediction details](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py): `model.py`

### Model training

- [Training command](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/train_model.py): `train_model.py`
- [Training workflow](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.py): `model.py`
- [Labeled dataset](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/datasets/final_dataset.csv): `datasets/final_dataset.csv`

### Model artifacts

- [Classifier artifact](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/model.pkl): `model.pkl`
- [Word vectorizer](https://github.com/bijen-maharjan56/fake_news_detection_system/blob/main/word_vectorizer.pkl): `word_vectorizer.pkl`

### Other components

- **News reader**

## Connections

- News reader → Web pages: opens (evidence: `README.md`)
- Flask routes → Web pages: renders (evidence: `app.py`)
- News reader → Prediction interface: enters news (evidence: `README.md`)
- Prediction interface → Prediction endpoint: posts news (evidence: `static/js/script.js`)
- Prediction endpoint → Text cleaning: calls prediction (evidence: `app.py`)
- Text cleaning → Political filter: checks text (evidence: `model.py`)
- Political filter → TF-IDF features: accepts political text (evidence: `model.py`)
- TF-IDF features → News classifier: supplies features (evidence: `model.py`)
- News classifier → Prediction details: provides prediction (evidence: `model.py`)
- Prediction endpoint → Prediction interface: returns JSON (evidence: `app.py`)
- Prediction interface → News reader: shows results (evidence: `static/js/script.js`)
- Training command → Training workflow: calls training (evidence: `train_model.py`)
- Training workflow → Labeled dataset: reads (evidence: `model.py`)
- Training workflow → Classifier artifact: writes (evidence: `model.py`)
- Training workflow → Word vectorizer: writes (evidence: `model.py`)
- Flask routes → Classifier artifact: loads (evidence: `app.py`)
- Flask routes → Word vectorizer: loads (evidence: `app.py`)
