# manishvgiri/ai-fake-news-detection architecture

> Architecture diagram of the GitHub repository manishvgiri/ai-fake-news-detection, 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/manishvgiri/ai-fake-news-detection
- Repository: https://github.com/manishvgiri/ai-fake-news-detection

## Overview

This repository is a command-line fake-news classification workflow: raw fake and real articles are prepared into a labeled dataset, used to train and evaluate a TF-IDF/Logistic Regression model, then classified with a prediction and confidence score. Dataset inspection and exploratory analysis are supporting capabilities. The processed dataset is documented and referenced by source, but is not present in the supplied file tree; its node uses the existing enclosing data directory. Evidence is limited to the README and sampled source files.

Main entry points: [`ml-service/src/predict.py`](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/predict.py) (Prediction CLI), [`ml-service/data`](https://github.com/manishvgiri/ai-fake-news-detection/tree/main/ml-service/data) (Prepared dataset), [`ml-service/src/train.py`](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/train.py) (Train and evaluate), [`ml-service/src/prepare_dataset.py`](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/prepare_dataset.py) (Dataset preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Dataset preparation"]
  node_fake_csv["Fake articles<br/>[Fake.csv]"]
  node_true_csv["Real articles<br/>[True.csv]"]
  node_prepare["Dataset preparation<br/>[prepare_dataset.py]"]
  node_processed["Prepared dataset"]
end

subgraph group_modeling["Model training"]
  node_train["Train and evaluate<br/>[train.py]"]
  node_vectorizer["TF-IDF vectorizer"]
  node_model["Logistic model"]
end

subgraph group_inference["News classification"]
  node_predict["Prediction CLI<br/>[predict.py]"]
  node_classification["Label and confidence"]
end

subgraph group_analysis["Data exploration"]
  node_inspect["Dataset inspection<br/>[inspect_dataset.py]"]
  node_eda["Exploratory analysis<br/>[eda.py]"]
end

node_user(("CLI user"))

node_fake_csv -->|"loads"| node_prepare
node_true_csv -->|"loads"| node_prepare
node_prepare -->|"writes"| node_processed
node_processed -->|"loads"| node_train
node_train -->|"saves"| node_vectorizer
node_train -->|"saves"| node_model
node_user -->|"enters article"| node_predict
node_predict -->|"loads and transforms"| node_vectorizer
node_predict -->|"loads and classifies"| node_model
node_predict -->|"prints"| node_classification
node_fake_csv -->|"reads"| node_inspect
node_true_csv -->|"reads"| node_inspect
node_processed -->|"loads"| node_eda

click node_fake_csv "https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/data/raw/Fake.csv"
click node_true_csv "https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/data/raw/True.csv"
click node_prepare "https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/prepare_dataset.py"
click node_processed "https://github.com/manishvgiri/ai-fake-news-detection/tree/main/ml-service/data"
click node_inspect "https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/inspect_dataset.py"
click node_eda "https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/eda.py"
click node_train "https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/train.py"
click node_vectorizer "https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/models/tfidf_vectorizer.joblib"
click node_model "https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/models/fake_news_model.joblib"
click node_predict "https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/predict.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_fake_csv,node_true_csv,node_prepare,node_processed,node_user toneBlue
class node_train,node_vectorizer,node_model toneAmber
class node_predict,node_classification toneMint
class node_inspect,node_eda toneRose
```

## Components

### Dataset preparation

- [Fake articles](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/data/raw/Fake.csv): `ml-service/data/raw/Fake.csv`
- [Real articles](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/data/raw/True.csv): `ml-service/data/raw/True.csv`
- [Dataset preparation](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/prepare_dataset.py): `ml-service/src/prepare_dataset.py`
- [Prepared dataset](https://github.com/manishvgiri/ai-fake-news-detection/tree/main/ml-service/data): `ml-service/data`

### Model training

- [Train and evaluate](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/train.py): `ml-service/src/train.py`
- [TF-IDF vectorizer](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/models/tfidf_vectorizer.joblib): `ml-service/models/tfidf_vectorizer.joblib`
- [Logistic model](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/models/fake_news_model.joblib): `ml-service/models/fake_news_model.joblib`

### News classification

- [Prediction CLI](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/predict.py): `ml-service/src/predict.py`
- **Label and confidence**

### Data exploration

- [Dataset inspection](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/inspect_dataset.py): `ml-service/src/inspect_dataset.py`
- [Exploratory analysis](https://github.com/manishvgiri/ai-fake-news-detection/blob/main/ml-service/src/eda.py): `ml-service/src/eda.py`

### Other components

- **CLI user**

## Connections

- Fake articles → Dataset preparation: loads
- Real articles → Dataset preparation: loads
- Dataset preparation → Prepared dataset: writes
- Prepared dataset → Train and evaluate: loads
- Train and evaluate → TF-IDF vectorizer: saves
- Train and evaluate → Logistic model: saves
- CLI user → Prediction CLI: enters article
- Prediction CLI → TF-IDF vectorizer: loads and transforms
- Prediction CLI → Logistic model: loads and classifies
- Prediction CLI → Label and confidence: prints
- Fake articles → Dataset inspection: reads
- Real articles → Dataset inspection: reads
- Prepared dataset → Exploratory analysis: loads
