# ventravs/fake-news-detector architecture

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

- Interactive diagram: https://gitdiagram.com/ventravs/fake-news-detector
- Repository: https://github.com/ventravs/fake-news-detector

## Overview

This repository implements a fake-news detector: article text is submitted to the FastAPI service, cleaned, vectorized, classified, and returned with confidence and influential words. The service also persists predictions and exposes recent history; its frontend is served from the repository’s frontend directory. A separate training script prepares labeled data, fits TF-IDF and logistic-regression components, evaluates them, and saves artifacts for inference. README-described Chrome extension support has no implementation file in the supplied tree. The graph reflects the active FastAPI code; the available excerpts do not show frontend or extension internals.

Main entry points: [`app.py`](https://github.com/ventravs/fake-news-detector/blob/main/app.py) (FastAPI routes), [`frontend/index.html`](https://github.com/ventravs/fake-news-detector/blob/main/frontend/index.html) (Web frontend), [`train_model.py`](https://github.com/ventravs/fake-news-detector/blob/main/train_model.py) (Training preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User clients"]
  node_web["Web frontend<br/>[index.html]"]
  node_extension["Chrome extension"]
end

subgraph group_inference["Detection service"]
  node_api["FastAPI routes<br/>[app.py]"]
  node_clean["Text cleaning<br/>[app.py]"]
  node_vector["TF-IDF vectorizer<br/>[app.py]"]
  node_classifier["Logistic classifier<br/>[app.py]"]
  node_verdict["Verdict adjustment<br/>[app.py]"]
  node_explain["Top-word analysis<br/>[app.py]"]
end

subgraph group_storage["Prediction records"]
  node_oracle[("Oracle database")]
  node_history["Prediction history<br/>[app.py]"]
end

subgraph group_training["Model training"]
  node_dataset["Labeled articles<br/>[train_model.py]"]
  node_prep["Training preparation<br/>[train_model.py]"]
  node_fit["TF-IDF and model fit<br/>[train_model.py]"]
  node_artifacts["Saved model artifacts<br/>[train_model.py]"]
end

node_user(("Article submitter"))

node_user -->|"submits article"| node_web
node_web -->|"calls detection"| node_api
node_api -->|"cleans text"| node_clean
node_api -->|"transforms text"| node_vector
node_api -->|"predicts probabilities"| node_classifier
node_api -->|"adjusts verdict"| node_verdict
node_api -->|"ranks words"| node_explain
node_api -->|"inserts prediction"| node_oracle
node_history -->|"reads recent records"| node_oracle
node_user -->|"requests history"| node_history
node_extension -.->|"uses detection"| node_api
node_dataset -->|"cleans and labels"| node_prep
node_prep -->|"trains on split"| node_fit
node_fit -->|"saves model"| node_artifacts

click node_web "https://github.com/ventravs/fake-news-detector/blob/main/frontend/index.html"
click node_api "https://github.com/ventravs/fake-news-detector/blob/main/app.py"
click node_clean "https://github.com/ventravs/fake-news-detector/blob/main/app.py"
click node_vector "https://github.com/ventravs/fake-news-detector/blob/main/app.py"
click node_classifier "https://github.com/ventravs/fake-news-detector/blob/main/app.py"
click node_verdict "https://github.com/ventravs/fake-news-detector/blob/main/app.py"
click node_explain "https://github.com/ventravs/fake-news-detector/blob/main/app.py"
click node_history "https://github.com/ventravs/fake-news-detector/blob/main/app.py"
click node_dataset "https://github.com/ventravs/fake-news-detector/blob/main/train_model.py"
click node_prep "https://github.com/ventravs/fake-news-detector/blob/main/train_model.py"
click node_fit "https://github.com/ventravs/fake-news-detector/blob/main/train_model.py"
click node_artifacts "https://github.com/ventravs/fake-news-detector/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_web,node_extension toneBlue
class node_api,node_clean,node_vector,node_classifier,node_verdict,node_explain toneAmber
class node_oracle,node_history toneMint
class node_dataset,node_prep,node_fit,node_artifacts toneRose
class node_user toneIndigo
```

## Components

### User clients

- [Web frontend](https://github.com/ventravs/fake-news-detector/blob/main/frontend/index.html): `frontend/index.html`
- **Chrome extension**

### Detection service

- [FastAPI routes](https://github.com/ventravs/fake-news-detector/blob/main/app.py): `app.py`
- [Text cleaning](https://github.com/ventravs/fake-news-detector/blob/main/app.py): `app.py`
- [TF-IDF vectorizer](https://github.com/ventravs/fake-news-detector/blob/main/app.py): `app.py`
- [Logistic classifier](https://github.com/ventravs/fake-news-detector/blob/main/app.py): `app.py`
- [Verdict adjustment](https://github.com/ventravs/fake-news-detector/blob/main/app.py): `app.py`
- [Top-word analysis](https://github.com/ventravs/fake-news-detector/blob/main/app.py): `app.py`

### Prediction records

- **Oracle database**
- [Prediction history](https://github.com/ventravs/fake-news-detector/blob/main/app.py): `app.py`

### Model training

- [Labeled articles](https://github.com/ventravs/fake-news-detector/blob/main/train_model.py): `train_model.py`
- [Training preparation](https://github.com/ventravs/fake-news-detector/blob/main/train_model.py): `train_model.py`
- [TF-IDF and model fit](https://github.com/ventravs/fake-news-detector/blob/main/train_model.py): `train_model.py`
- [Saved model artifacts](https://github.com/ventravs/fake-news-detector/blob/main/train_model.py): `train_model.py`

### Other components

- **Article submitter**

## Connections

- Article submitter → Web frontend: submits article (evidence: `README.md`)
- Web frontend → FastAPI routes: calls detection (evidence: `README.md`)
- FastAPI routes → Text cleaning: cleans text (evidence: `app.py`)
- FastAPI routes → TF-IDF vectorizer: transforms text (evidence: `app.py`)
- FastAPI routes → Logistic classifier: predicts probabilities (evidence: `app.py`)
- FastAPI routes → Verdict adjustment: adjusts verdict (evidence: `app.py`)
- FastAPI routes → Top-word analysis: ranks words (evidence: `app.py`)
- FastAPI routes → Oracle database: inserts prediction (evidence: `app.py`)
- Prediction history → Oracle database: reads recent records (evidence: `app.py`)
- Article submitter → Prediction history: requests history (evidence: `app.py`)
- Chrome extension → FastAPI routes: uses detection (evidence: `README.md`)
- Labeled articles → Training preparation: cleans and labels (evidence: `train_model.py`)
- Training preparation → TF-IDF and model fit: trains on split (evidence: `train_model.py`)
- TF-IDF and model fit → Saved model artifacts: saves model (evidence: `train_model.py`)
