# aliahmad552/fake_news_detection_and_summarization_genai_project architecture

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

- Interactive diagram: https://gitdiagram.com/aliahmad552/fake_news_detection_and_summarization_genai_project
- Repository: https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project

## Overview

This is a FastAPI news summarization and credibility-analysis app. A user submits a query through the served page to `/ask`; the handler retrieves articles, turns them into documents, builds a FAISS index, retrieves relevant context, and returns a generated summary plus classifier output. The graph separates these stages and their model integrations. README capabilities are included where documented, but the excerpts do not show the template’s interaction code or details of API errors and response handling.

Main entry points: [`app.py`](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/app.py) (FastAPI query handler), [`model/preprocessor.py`](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py) (Summary and analysis), [`templates/index.html`](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/templates/index.html) (Query page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User interface and API"]
  node_page["Query page<br/>[index.html]"]
  node_api["FastAPI query handler<br/>[app.py]"]
  node_response["Summary and credibility result<br/>[app.py]"]
end

subgraph group_retrieval["News retrieval and search"]
  node_article_fetch["Article retrieval<br/>[preprocessor.py]"]
  node_documents["Article documents<br/>[preprocessor.py]"]
  node_embeddings["Text embeddings<br/>[preprocessor.py]"]
  node_faiss[("FAISS index<br/>[preprocessor.py]")]
  node_retriever["Similarity retriever<br/>[app.py]"]
end

subgraph group_analysis["Summarization and detection"]
  node_summarize["Summary and analysis<br/>[preprocessor.py]"]
  node_prompt["Analysis prompt<br/>[preprocessor.py]"]
  node_parser["Output parser<br/>[preprocessor.py]"]
  node_detector["Fake-news classifier<br/>[preprocessor.py]"]
end

node_user(("News query user"))
node_newsapi["NewsAPI"]
node_llm["Llama 3 endpoint"]

node_user -->|"opens"| node_page
node_page -.->|"submits query"| node_api
node_api -->|"serves"| node_page
node_api -->|"calls"| node_article_fetch
node_article_fetch -->|"fetches articles"| node_newsapi
node_api -->|"builds"| node_documents
node_api -->|"builds index"| node_faiss
node_faiss -->|"embeds documents"| node_embeddings
node_api -->|"configures"| node_retriever
node_faiss -->|"provides search"| node_retriever
node_api -->|"calls"| node_summarize
node_summarize -->|"retrieves context"| node_retriever
node_summarize -->|"formats prompt"| node_prompt
node_summarize -->|"invokes model"| node_llm
node_summarize -->|"parses output"| node_parser
node_summarize -->|"classifies context"| node_detector
node_api -->|"returns result"| node_response
node_response -.->|"presents result"| node_user

click node_page "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/templates/index.html"
click node_api "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/app.py"
click node_article_fetch "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py"
click node_documents "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py"
click node_embeddings "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py"
click node_faiss "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py"
click node_retriever "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/app.py"
click node_summarize "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py"
click node_prompt "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py"
click node_parser "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py"
click node_detector "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py"
click node_response "https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/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_page,node_api,node_response,node_user toneBlue
class node_article_fetch,node_documents,node_embeddings,node_faiss,node_retriever toneAmber
class node_summarize,node_prompt,node_parser,node_detector,node_newsapi toneMint
class node_llm toneIndigo
```

## Components

### User interface and API

- [Query page](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/templates/index.html): `templates/index.html`
- [FastAPI query handler](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/app.py): `app.py`
- [Summary and credibility result](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/app.py): `app.py`

### News retrieval and search

- [Article retrieval](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py): `model/preprocessor.py`
- [Article documents](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py): `model/preprocessor.py`
- [Text embeddings](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py): `model/preprocessor.py`
- [FAISS index](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py): `model/preprocessor.py`
- [Similarity retriever](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/app.py): `app.py`

### Summarization and detection

- [Summary and analysis](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py): `model/preprocessor.py`
- [Analysis prompt](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py): `model/preprocessor.py`
- [Output parser](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py): `model/preprocessor.py`
- [Fake-news classifier](https://github.com/aliahmad552/fake_news_detection_and_summarization_genai_project/blob/main/model/preprocessor.py): `model/preprocessor.py`

### Other components

- **News query user**
- **NewsAPI**
- **Llama 3 endpoint**

## Connections

- News query user → Query page: opens (evidence: `README.md`)
- Query page → FastAPI query handler: submits query
- FastAPI query handler → Query page: serves (evidence: `app.py`)
- FastAPI query handler → Article retrieval: calls (evidence: `app.py`)
- Article retrieval → NewsAPI: fetches articles (evidence: `model/preprocessor.py`)
- FastAPI query handler → Article documents: builds (evidence: `app.py`)
- FastAPI query handler → FAISS index: builds index (evidence: `app.py`)
- FAISS index → Text embeddings: embeds documents (evidence: `model/preprocessor.py`)
- FastAPI query handler → Similarity retriever: configures (evidence: `app.py`)
- FAISS index → Similarity retriever: provides search (evidence: `app.py`)
- FastAPI query handler → Summary and analysis: calls (evidence: `app.py`)
- Summary and analysis → Similarity retriever: retrieves context (evidence: `model/preprocessor.py`)
- Summary and analysis → Analysis prompt: formats prompt (evidence: `model/preprocessor.py`)
- Summary and analysis → Llama 3 endpoint: invokes model (evidence: `model/preprocessor.py`)
- Summary and analysis → Output parser: parses output (evidence: `model/preprocessor.py`)
- Summary and analysis → Fake-news classifier: classifies context (evidence: `model/preprocessor.py`)
- FastAPI query handler → Summary and credibility result: returns result (evidence: `app.py`)
- Summary and credibility result → News query user: presents result
