# darksoul36/fake-news-detection architecture

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

- Interactive diagram: https://gitdiagram.com/darksoul36/fake-news-detection
- Repository: https://github.com/darksoul36/fake-news-detection

## Overview

This is a full-stack fake-news classification application. A user types or dictates an article, selects a model, and submits it through the web interface; the API classifies it and generates an explanation before returning label and confidence for display. Users can also submit feedback. The graph includes the documented speech, theme, and accessibility capabilities, plus API health and feedback storage. Source excerpts establish most backend calls; frontend/API and some UI wiring are documented in the README, so those links use that evidence.

Main entry points: [`API/ROUTER/PREDICTION_ROUTER.py`](https://github.com/darksoul36/fake-news-detection/blob/main/API/ROUTER/PREDICTION_ROUTER.py) (Prediction endpoint), [`API/MAIN.py`](https://github.com/darksoul36/fake-news-detection/blob/main/API/MAIN.py) (FastAPI application), [`FRONTEND/JS/EXPLANATION_AREA.js`](https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/EXPLANATION_AREA.js) (Results and explanation UI), [`API/UTILS/SETTINGS.py`](https://github.com/darksoul36/fake-news-detection/blob/main/API/UTILS/SETTINGS.py) (Model configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Web interface<br/>[INDEX.html]"]
  node_voice["Voice input<br/>[VOICE_INPUT.js]"]
  node_analysis_ui["Analysis request UI"]
  node_results["Results and explanation UI"]
  node_speech["Speech synthesis"]
  node_feedback_ui["Feedback dialog<br/>[FEEDBACK_MODAL.js]"]
  node_theme["Theme preference<br/>[THEME_MANAGER.js]"]
end

subgraph group_api["API orchestration"]
  node_api_app["FastAPI application<br/>[MAIN.py]"]
  node_prediction_route["Prediction endpoint"]
  node_health_route["Health endpoint<br/>[HEALTH_ROUTER.py]"]
end

subgraph group_analysis["Classification and explanation"]
  node_model_loader["Model loader<br/>[MODEL_LOADER.py]"]
  node_model_config["Model configuration<br/>[SETTINGS.py]"]
  node_model_assets["Trained models"]
  node_vectorizer["TF-IDF vectorizer"]
  node_classifier["News classifier<br/>[PREDICTION.py]"]
  node_explainer["LLM explainer<br/>[LLM_EXPLAINER.py]"]
end

subgraph group_feedback["Feedback and status"]
  node_feedback_route["Feedback endpoint<br/>[FEEDBACK_ROUTER.py]"]
  node_feedback_service["Feedback service"]
  node_supabase[("Supabase")]
end

node_user(("Article submitter"))
node_speech_api["Web Speech API"]
node_health_user(("Health monitor"))

node_user -->|"enters article"| node_webapp
node_user -->|"dictates article"| node_voice
node_speech_api -.->|"recognizes speech"| node_voice
node_voice -.->|"supplies text"| node_analysis_ui
node_webapp -.->|"hosts analysis"| node_analysis_ui
node_analysis_ui -->|"posts article"| node_prediction_route
node_api_app -->|"mounts route"| node_prediction_route
node_api_app -->|"mounts route"| node_health_route
node_api_app -->|"mounts route"| node_feedback_route
node_prediction_route -->|"loads models"| node_model_loader
node_model_loader -->|"reads paths"| node_model_config
node_model_config -->|"names model files"| node_model_assets
node_model_config -->|"names vectorizer"| node_vectorizer
node_prediction_route -->|"classifies article"| node_classifier
node_classifier -.->|"predicts with model"| node_model_assets
node_classifier -.->|"transforms text"| node_vectorizer
node_prediction_route -->|"requests explanation"| node_explainer
node_prediction_route -->|"returns prediction"| node_results
node_results -->|"shows result"| node_user
node_results -->|"offers spoken result"| node_speech
node_speech -.->|"speaks result"| node_speech_api
node_user -->|"rates result"| node_feedback_ui
node_feedback_ui -->|"submits feedback"| node_feedback_route
node_feedback_route -->|"submits feedback"| node_feedback_service
node_feedback_service -->|"inserts feedback"| node_supabase
node_health_user -.->|"checks status"| node_health_route
node_user -.->|"toggles theme"| node_theme

click node_webapp "https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/INDEX.html"
click node_voice "https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/VOICE_INPUT.js"
click node_analysis_ui "https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/ANALYSIS_HANDLER.js"
click node_results "https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/EXPLANATION_AREA.js"
click node_speech "https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/SPEECH_SYNTHESIS.js"
click node_feedback_ui "https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/FEEDBACK_MODAL.js"
click node_theme "https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/THEME_MANAGER.js"
click node_api_app "https://github.com/darksoul36/fake-news-detection/blob/main/API/MAIN.py"
click node_prediction_route "https://github.com/darksoul36/fake-news-detection/blob/main/API/ROUTER/PREDICTION_ROUTER.py"
click node_health_route "https://github.com/darksoul36/fake-news-detection/blob/main/API/ROUTER/HEALTH_ROUTER.py"
click node_model_loader "https://github.com/darksoul36/fake-news-detection/blob/main/API/MODELS/MODEL_LOADER.py"
click node_model_config "https://github.com/darksoul36/fake-news-detection/blob/main/API/UTILS/SETTINGS.py"
click node_model_assets "https://github.com/darksoul36/fake-news-detection/tree/main/MODEL/MODELS"
click node_vectorizer "https://github.com/darksoul36/fake-news-detection/tree/main/MODEL/VECTORIZER"
click node_classifier "https://github.com/darksoul36/fake-news-detection/blob/main/API/MODELS/PREDICTION.py"
click node_explainer "https://github.com/darksoul36/fake-news-detection/blob/main/API/SERVICES/LLM_EXPLAINER.py"
click node_feedback_route "https://github.com/darksoul36/fake-news-detection/blob/main/API/ROUTER/FEEDBACK_ROUTER.py"
click node_feedback_service "https://github.com/darksoul36/fake-news-detection/blob/main/API/SERVICES/FEEDBACK_SERVICE.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_webapp,node_voice,node_analysis_ui,node_results,node_speech,node_feedback_ui,node_theme toneBlue
class node_api_app,node_prediction_route,node_health_route toneAmber
class node_model_loader,node_model_config,node_model_assets,node_vectorizer,node_classifier,node_explainer,node_speech_api toneMint
class node_feedback_route,node_feedback_service,node_supabase toneRose
class node_user,node_health_user toneIndigo
```

## Components

### Web experience

- [Web interface](https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/INDEX.html): `FRONTEND/INDEX.html`
- [Voice input](https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/VOICE_INPUT.js): `FRONTEND/JS/VOICE_INPUT.js`
- [Analysis request UI](https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/ANALYSIS_HANDLER.js): `FRONTEND/JS/ANALYSIS_HANDLER.js`
- [Results and explanation UI](https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/EXPLANATION_AREA.js): `FRONTEND/JS/EXPLANATION_AREA.js`
- [Speech synthesis](https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/SPEECH_SYNTHESIS.js): `FRONTEND/JS/SPEECH_SYNTHESIS.js`
- [Feedback dialog](https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/FEEDBACK_MODAL.js): `FRONTEND/JS/FEEDBACK_MODAL.js`
- [Theme preference](https://github.com/darksoul36/fake-news-detection/blob/main/FRONTEND/JS/THEME_MANAGER.js): `FRONTEND/JS/THEME_MANAGER.js`

### API orchestration

- [FastAPI application](https://github.com/darksoul36/fake-news-detection/blob/main/API/MAIN.py): `API/MAIN.py`
- [Prediction endpoint](https://github.com/darksoul36/fake-news-detection/blob/main/API/ROUTER/PREDICTION_ROUTER.py): `API/ROUTER/PREDICTION_ROUTER.py`
- [Health endpoint](https://github.com/darksoul36/fake-news-detection/blob/main/API/ROUTER/HEALTH_ROUTER.py): `API/ROUTER/HEALTH_ROUTER.py`

### Classification and explanation

- [Model loader](https://github.com/darksoul36/fake-news-detection/blob/main/API/MODELS/MODEL_LOADER.py): `API/MODELS/MODEL_LOADER.py`
- [Model configuration](https://github.com/darksoul36/fake-news-detection/blob/main/API/UTILS/SETTINGS.py): `API/UTILS/SETTINGS.py`
- [Trained models](https://github.com/darksoul36/fake-news-detection/tree/main/MODEL/MODELS): `MODEL/MODELS`
- [TF-IDF vectorizer](https://github.com/darksoul36/fake-news-detection/tree/main/MODEL/VECTORIZER): `MODEL/VECTORIZER`
- [News classifier](https://github.com/darksoul36/fake-news-detection/blob/main/API/MODELS/PREDICTION.py): `API/MODELS/PREDICTION.py`
- [LLM explainer](https://github.com/darksoul36/fake-news-detection/blob/main/API/SERVICES/LLM_EXPLAINER.py): `API/SERVICES/LLM_EXPLAINER.py`

### Feedback and status

- [Feedback endpoint](https://github.com/darksoul36/fake-news-detection/blob/main/API/ROUTER/FEEDBACK_ROUTER.py): `API/ROUTER/FEEDBACK_ROUTER.py`
- [Feedback service](https://github.com/darksoul36/fake-news-detection/blob/main/API/SERVICES/FEEDBACK_SERVICE.py): `API/SERVICES/FEEDBACK_SERVICE.py`
- **Supabase**

### Other components

- **Article submitter**
- **Web Speech API**
- **Health monitor**

## Connections

- Article submitter → Web interface: enters article (evidence: `README.md`)
- Article submitter → Voice input: dictates article (evidence: `README.md`)
- Web Speech API → Voice input: recognizes speech
- Voice input → Analysis request UI: supplies text
- Web interface → Analysis request UI: hosts analysis
- Analysis request UI → Prediction endpoint: posts article (evidence: `README.md`)
- FastAPI application → Prediction endpoint: mounts route (evidence: `API/MAIN.py`)
- FastAPI application → Health endpoint: mounts route (evidence: `API/MAIN.py`)
- FastAPI application → Feedback endpoint: mounts route (evidence: `API/MAIN.py`)
- Prediction endpoint → Model loader: loads models (evidence: `API/ROUTER/PREDICTION_ROUTER.py`)
- Model loader → Model configuration: reads paths (evidence: `API/MODELS/MODEL_LOADER.py`)
- Model configuration → Trained models: names model files (evidence: `API/UTILS/SETTINGS.py`)
- Model configuration → TF-IDF vectorizer: names vectorizer (evidence: `API/UTILS/SETTINGS.py`)
- Prediction endpoint → News classifier: classifies article (evidence: `API/ROUTER/PREDICTION_ROUTER.py`)
- News classifier → Trained models: predicts with model
- News classifier → TF-IDF vectorizer: transforms text
- Prediction endpoint → LLM explainer: requests explanation (evidence: `API/ROUTER/PREDICTION_ROUTER.py`)
- Prediction endpoint → Results and explanation UI: returns prediction (evidence: `README.md`)
- Results and explanation UI → Article submitter: shows result (evidence: `README.md`)
- Results and explanation UI → Speech synthesis: offers spoken result (evidence: `README.md`)
- Speech synthesis → Web Speech API: speaks result
- Article submitter → Feedback dialog: rates result (evidence: `README.md`)
- Feedback dialog → Feedback endpoint: submits feedback (evidence: `README.md`)
- Feedback endpoint → Feedback service: submits feedback (evidence: `API/ROUTER/FEEDBACK_ROUTER.py`)
- Feedback service → Supabase: inserts feedback (evidence: `API/SERVICES/FEEDBACK_SERVICE.py`)
- Health monitor → Health endpoint: checks status
- Article submitter → Theme preference: toggles theme
