# harshithreddy973/misinfo-detector architecture

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

- Interactive diagram: https://gitdiagram.com/harshithreddy973/misinfo-detector
- Repository: https://github.com/harshithreddy973/misinfo-detector

## Overview

Misinformation Detector is a human-review decision-support application. Users submit one article or a CSV through the Streamlit interface; the API runs shared inference, returns prediction, confidence, priority, and available explanations, and stores results for reviewer follow-up. Batch results can be exported, while reviewers can confirm, dismiss, or relabel without overwriting the original prediction. The repository also includes dataset preparation stages. The README documents the major runtime capabilities; unsampled implementation details are represented only where that documentation supports them.

Main entry points: [`api/main.py`](https://github.com/harshithreddy973/misinfo-detector/blob/main/api/main.py) (FastAPI endpoints), [`data/merge_all.py`](https://github.com/harshithreddy973/misinfo-detector/blob/main/data/merge_all.py) (Dataset merger), [`model/inference.py`](https://github.com/harshithreddy973/misinfo-detector/blob/main/model/inference.py) (Inference and explanations), [`data/schema.py`](https://github.com/harshithreddy973/misinfo-detector/blob/main/data/schema.py) (Unified data schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_streamlit["Streamlit UI<br/>[app.py]"]
end

subgraph group_prediction["Prediction service"]
  node_api["FastAPI endpoints<br/>[main.py]"]
  node_contracts["API contracts<br/>[schemas.py]"]
  node_features["Feature generation<br/>[inference.py]"]
  node_inference["Inference and explanations<br/>[inference.py]"]
  node_model["Calibrated model"]
  node_shapdata["SHAP background data"]
end

subgraph group_review["Review and storage"]
  node_dbcode["Persistence operations<br/>[db.py]"]
  node_sqlite[("SQLite records<br/>[db.py]")]
end

subgraph group_preparation["Dataset preparation"]
  node_fakenewsnet["FakeNewsNet cleaner"]
  node_isot["ISOT cleaner<br/>[clean_isot.py]"]
  node_liar["LIAR cleaner<br/>[clean_liar.py]"]
  node_schema["Unified data schema<br/>[schema.py]"]
  node_merge["Dataset merger<br/>[merge_all.py]"]
  node_split["Dataset splitting<br/>[split_dataset.py]"]
end

node_user(("User / reviewer"))

node_user -->|"submits articles"| node_streamlit
node_streamlit -->|"sends HTTP requests"| node_api
node_api -->|"runs predictions"| node_inference
node_api -->|"stores and retrieves"| node_dbcode
node_api -->|"uses request models"| node_contracts
node_inference -->|"generates features"| node_features
node_inference -->|"predicts probabilities"| node_model
node_inference -->|"uses background data"| node_shapdata
node_dbcode -->|"persists records"| node_sqlite
node_api -->|"returns results"| node_streamlit
node_fakenewsnet -->|"validates against"| node_schema
node_isot -->|"validates against"| node_schema
node_liar -->|"validates against"| node_schema
node_merge -->|"validates against"| node_schema
node_merge -->|"reads cleaned output"| node_fakenewsnet
node_merge -->|"reads cleaned output"| node_isot
node_merge -->|"reads cleaned output"| node_liar
node_split -->|"reads combined corpus"| node_merge

click node_streamlit "https://github.com/harshithreddy973/misinfo-detector/blob/main/app/app.py"
click node_api "https://github.com/harshithreddy973/misinfo-detector/blob/main/api/main.py"
click node_contracts "https://github.com/harshithreddy973/misinfo-detector/blob/main/api/schemas.py"
click node_features "https://github.com/harshithreddy973/misinfo-detector/blob/main/model/inference.py"
click node_inference "https://github.com/harshithreddy973/misinfo-detector/blob/main/model/inference.py"
click node_model "https://github.com/harshithreddy973/misinfo-detector/blob/main/models/calibrated_model.joblib"
click node_shapdata "https://github.com/harshithreddy973/misinfo-detector/blob/main/data/processed/train_features.parquet"
click node_dbcode "https://github.com/harshithreddy973/misinfo-detector/blob/main/api/db.py"
click node_sqlite "https://github.com/harshithreddy973/misinfo-detector/blob/main/api/db.py"
click node_fakenewsnet "https://github.com/harshithreddy973/misinfo-detector/blob/main/data/clean_fakenewsnet_main.py"
click node_isot "https://github.com/harshithreddy973/misinfo-detector/blob/main/data/clean_isot.py"
click node_liar "https://github.com/harshithreddy973/misinfo-detector/blob/main/data/clean_liar.py"
click node_schema "https://github.com/harshithreddy973/misinfo-detector/blob/main/data/schema.py"
click node_merge "https://github.com/harshithreddy973/misinfo-detector/blob/main/data/merge_all.py"
click node_split "https://github.com/harshithreddy973/misinfo-detector/blob/main/data/split_dataset.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_streamlit,node_user toneBlue
class node_api,node_contracts,node_features,node_inference,node_model,node_shapdata toneAmber
class node_dbcode,node_sqlite toneMint
class node_fakenewsnet,node_isot,node_liar,node_schema,node_merge,node_split toneRose
```

## Components

### User interface

- [Streamlit UI](https://github.com/harshithreddy973/misinfo-detector/blob/main/app/app.py): `app/app.py`

### Prediction service

- [FastAPI endpoints](https://github.com/harshithreddy973/misinfo-detector/blob/main/api/main.py): `api/main.py`
- [API contracts](https://github.com/harshithreddy973/misinfo-detector/blob/main/api/schemas.py): `api/schemas.py`
- [Feature generation](https://github.com/harshithreddy973/misinfo-detector/blob/main/model/inference.py): `model/inference.py`
- [Inference and explanations](https://github.com/harshithreddy973/misinfo-detector/blob/main/model/inference.py): `model/inference.py`
- [Calibrated model](https://github.com/harshithreddy973/misinfo-detector/blob/main/models/calibrated_model.joblib): `models/calibrated_model.joblib`
- [SHAP background data](https://github.com/harshithreddy973/misinfo-detector/blob/main/data/processed/train_features.parquet): `data/processed/train_features.parquet`

### Review and storage

- [Persistence operations](https://github.com/harshithreddy973/misinfo-detector/blob/main/api/db.py): `api/db.py`
- [SQLite records](https://github.com/harshithreddy973/misinfo-detector/blob/main/api/db.py): `api/db.py`

### Dataset preparation

- [FakeNewsNet cleaner](https://github.com/harshithreddy973/misinfo-detector/blob/main/data/clean_fakenewsnet_main.py): `data/clean_fakenewsnet_main.py`
- [ISOT cleaner](https://github.com/harshithreddy973/misinfo-detector/blob/main/data/clean_isot.py): `data/clean_isot.py`
- [LIAR cleaner](https://github.com/harshithreddy973/misinfo-detector/blob/main/data/clean_liar.py): `data/clean_liar.py`
- [Unified data schema](https://github.com/harshithreddy973/misinfo-detector/blob/main/data/schema.py): `data/schema.py`
- [Dataset merger](https://github.com/harshithreddy973/misinfo-detector/blob/main/data/merge_all.py): `data/merge_all.py`
- [Dataset splitting](https://github.com/harshithreddy973/misinfo-detector/blob/main/data/split_dataset.py): `data/split_dataset.py`

### Other components

- **User / reviewer**

## Connections

- User / reviewer → Streamlit UI: submits articles (evidence: `README.md`)
- Streamlit UI → FastAPI endpoints: sends HTTP requests (evidence: `README.md`)
- FastAPI endpoints → Inference and explanations: runs predictions (evidence: `README.md`)
- FastAPI endpoints → Persistence operations: stores and retrieves (evidence: `api/main.py`)
- FastAPI endpoints → API contracts: uses request models (evidence: `api/main.py`)
- Inference and explanations → Feature generation: generates features (evidence: `README.md`)
- Inference and explanations → Calibrated model: predicts probabilities (evidence: `README.md`)
- Inference and explanations → SHAP background data: uses background data (evidence: `README.md`)
- Persistence operations → SQLite records: persists records (evidence: `api/db.py`)
- FastAPI endpoints → Streamlit UI: returns results (evidence: `README.md`)
- FakeNewsNet cleaner → Unified data schema: validates against (evidence: `data/clean_fakenewsnet_main.py`)
- ISOT cleaner → Unified data schema: validates against (evidence: `data/clean_isot.py`)
- LIAR cleaner → Unified data schema: validates against (evidence: `data/clean_liar.py`)
- Dataset merger → Unified data schema: validates against (evidence: `data/merge_all.py`)
- Dataset merger → FakeNewsNet cleaner: reads cleaned output (evidence: `data/merge_all.py`)
- Dataset merger → ISOT cleaner: reads cleaned output (evidence: `data/merge_all.py`)
- Dataset merger → LIAR cleaner: reads cleaned output (evidence: `data/merge_all.py`)
- Dataset splitting → Dataset merger: reads combined corpus (evidence: `data/split_dataset.py`)
