# aakanksha-2025/fake_news_detector architecture

> Architecture diagram of the GitHub repository aakanksha-2025/fake_news_detector, 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/aakanksha-2025/fake_news_detector
- Repository: https://github.com/aakanksha-2025/fake_news_detector

## Overview

This is a fake-news classification project with two prediction interfaces: a Flask JSON API and a Streamlit app. Its data workflow combines labeled fake/real news, cleans it, then trains and evaluates a TF-IDF/Logistic Regression model and saves the model and vectorizer. At prediction time, each interface uses those artifacts to classify user text. The README describes the capabilities, but the data files and test implementation are not in the supplied tree; the graph shows only documented data stages and sampled runtime wiring.

Main entry points: [`train_model.py`](https://github.com/aakanksha-2025/fake_news_detector/blob/main/train_model.py) (Train and evaluate), [`api.py`](https://github.com/aakanksha-2025/fake_news_detector/blob/main/api.py) (Flask prediction API), [`app.py`](https://github.com/aakanksha-2025/fake_news_detector/blob/main/app.py) (Streamlit app), [`model.pkl`](https://github.com/aakanksha-2025/fake_news_detector/blob/main/model.pkl) (Classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_prepare["Combine and label<br/>[prepare_data.py]"]
  node_raw_csv["news.csv"]
  node_preprocess["Clean text<br/>[preprocess.py]"]
  node_clean_csv["news_cleaned.csv"]
end

subgraph group_training["Model training"]
  node_train["Train and evaluate<br/>[train_model.py]"]
  node_model["Classifier<br/>[model.pkl]"]
  node_vectorizer["TF-IDF vectorizer<br/>[vectorizer.pkl]"]
end

subgraph group_serving["Prediction interfaces"]
  node_api["Flask prediction API<br/>[api.py]"]
  node_streamlit["Streamlit app<br/>[app.py]"]
end

node_dataset_source(("Kaggle news data"))
node_api_user(("API caller"))
node_streamlit_user(("Streamlit user"))

node_dataset_source -.->|"provides CSVs"| node_prepare
node_prepare -->|"writes"| node_raw_csv
node_preprocess -->|"reads"| node_raw_csv
node_preprocess -->|"writes"| node_clean_csv
node_train -->|"reads"| node_clean_csv
node_train -->|"saves"| node_model
node_train -->|"saves"| node_vectorizer
node_api_user -->|"posts text"| node_api
node_api -->|"loads and predicts"| node_model
node_api -->|"loads and transforms"| node_vectorizer
node_streamlit_user -->|"enters text"| node_streamlit
node_streamlit -->|"loads and predicts"| node_model
node_streamlit -->|"loads and transforms"| node_vectorizer

click node_prepare "https://github.com/aakanksha-2025/fake_news_detector/blob/main/prepare_data.py"
click node_preprocess "https://github.com/aakanksha-2025/fake_news_detector/blob/main/preprocess.py"
click node_train "https://github.com/aakanksha-2025/fake_news_detector/blob/main/train_model.py"
click node_model "https://github.com/aakanksha-2025/fake_news_detector/blob/main/model.pkl"
click node_vectorizer "https://github.com/aakanksha-2025/fake_news_detector/blob/main/vectorizer.pkl"
click node_api "https://github.com/aakanksha-2025/fake_news_detector/blob/main/api.py"
click node_streamlit "https://github.com/aakanksha-2025/fake_news_detector/blob/main/app.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_prepare,node_raw_csv,node_preprocess,node_clean_csv,node_streamlit_user toneBlue
class node_train,node_model,node_vectorizer toneAmber
class node_api,node_streamlit,node_api_user toneMint
class node_dataset_source toneIndigo
```

## Components

### Data preparation

- [Combine and label](https://github.com/aakanksha-2025/fake_news_detector/blob/main/prepare_data.py): `prepare_data.py`
- **news.csv**
- [Clean text](https://github.com/aakanksha-2025/fake_news_detector/blob/main/preprocess.py): `preprocess.py`
- **news_cleaned.csv**

### Model training

- [Train and evaluate](https://github.com/aakanksha-2025/fake_news_detector/blob/main/train_model.py): `train_model.py`
- [Classifier](https://github.com/aakanksha-2025/fake_news_detector/blob/main/model.pkl): `model.pkl`
- [TF-IDF vectorizer](https://github.com/aakanksha-2025/fake_news_detector/blob/main/vectorizer.pkl): `vectorizer.pkl`

### Prediction interfaces

- [Flask prediction API](https://github.com/aakanksha-2025/fake_news_detector/blob/main/api.py): `api.py`
- [Streamlit app](https://github.com/aakanksha-2025/fake_news_detector/blob/main/app.py): `app.py`

### Other components

- **Kaggle news data**
- **API caller**
- **Streamlit user**

## Connections

- Kaggle news data → Combine and label: provides CSVs
- Combine and label → news.csv: writes
- Clean text → news.csv: reads
- Clean text → news_cleaned.csv: writes
- Train and evaluate → news_cleaned.csv: reads
- Train and evaluate → Classifier: saves
- Train and evaluate → TF-IDF vectorizer: saves
- API caller → Flask prediction API: posts text
- Flask prediction API → Classifier: loads and predicts
- Flask prediction API → TF-IDF vectorizer: loads and transforms
- Streamlit user → Streamlit app: enters text
- Streamlit app → Classifier: loads and predicts
- Streamlit app → TF-IDF vectorizer: loads and transforms
