# udit-tripathi07/newsrag architecture

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

- Interactive diagram: https://gitdiagram.com/udit-tripathi07/newsrag
- Repository: https://github.com/udit-tripathi07/newsrag

## Overview

NewsRAG is a Streamlit app for asking questions over three isolated source workspaces: newspaper coverage, cross-publisher topic searches, and uploaded PDFs. Users choose a workspace, load sources, and chat; follow-up questions are rewritten using that workspace’s history before retrieval, and answers are generated with Groq. The README documents session-only FAISS storage and the major capabilities, but app.py was not inspected, so the graph reflects documented behavior rather than verified internal call sites.

Main entry points: [`app.py`](https://github.com/udit-tripathi07/newsrag/blob/main/app.py) (Query Rewriting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspaces["Workspaces"]
  node_landing["Workspace Picker<br/>[app.py]"]
  node_newsroom["Newsroom<br/>[app.py]"]
  node_topic["Topic Radar<br/>[app.py]"]
  node_vault["Document Vault<br/>[app.py]"]
end

subgraph group_sources["Source Loading"]
  node_article_load["Article Loading<br/>[app.py]"]
  node_pdf_parse["PDF Parsing<br/>[app.py]"]
  node_chunking["Text Chunking<br/>[app.py]"]
  node_embeddings["Embeddings<br/>[app.py]"]
  node_faiss[("Session FAISS<br/>[app.py]")]
end

subgraph group_rag["Retrieval and Answers"]
  node_query_rewrite["Query Rewriting<br/>[app.py]"]
  node_retrieval["Scoped Retrieval<br/>[app.py]"]
  node_summary_context["Summary Context<br/>[app.py]"]
  node_chat_state[("Chat History<br/>[app.py]")]
  node_answer["Generated Answer<br/>[app.py]"]
end

node_user(("User"))
node_newsapi{{"NewsAPI"}}
node_groq{{"Groq LLM"}}

node_user -->|"opens"| node_landing
node_landing -->|"selects"| node_newsroom
node_landing -->|"selects"| node_topic
node_landing -->|"selects"| node_vault
node_newsroom -->|"loads coverage"| node_article_load
node_topic -->|"searches articles"| node_article_load
node_newsapi -->|"provides articles"| node_article_load
node_vault -->|"uploads PDFs"| node_pdf_parse
node_article_load -->|"indexes articles"| node_chunking
node_pdf_parse -->|"extracts pages"| node_chunking
node_chunking -->|"embeds chunks"| node_embeddings
node_embeddings -->|"stores vectors"| node_faiss
node_newsroom -->|"asks questions"| node_query_rewrite
node_topic -->|"asks questions"| node_query_rewrite
node_vault -->|"asks questions"| node_query_rewrite
node_query_rewrite -->|"contextualizes query"| node_retrieval
node_chat_state -->|"supplies history"| node_query_rewrite
node_retrieval -->|"searches scope"| node_faiss
node_retrieval -->|"uses full context"| node_summary_context
node_retrieval -->|"provides context"| node_groq
node_summary_context -->|"provides context"| node_groq
node_groq -->|"generates answer"| node_answer
node_answer -->|"updates history"| node_chat_state
node_answer -->|"returns answer"| node_user

click node_landing "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_newsroom "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_topic "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_vault "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_article_load "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_pdf_parse "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_chunking "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_embeddings "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_faiss "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_query_rewrite "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_retrieval "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_summary_context "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_chat_state "https://github.com/udit-tripathi07/newsrag/blob/main/app.py"
click node_answer "https://github.com/udit-tripathi07/newsrag/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_landing,node_newsroom,node_topic,node_vault,node_user toneBlue
class node_article_load,node_pdf_parse,node_chunking,node_embeddings,node_faiss toneAmber
class node_query_rewrite,node_retrieval,node_summary_context,node_chat_state,node_answer,node_newsapi toneMint
class node_groq toneIndigo
```

## Components

### Workspaces

- [Workspace Picker](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [Newsroom](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [Topic Radar](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [Document Vault](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`

### Source Loading

- [Article Loading](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [PDF Parsing](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [Text Chunking](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [Embeddings](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [Session FAISS](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`

### Retrieval and Answers

- [Query Rewriting](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [Scoped Retrieval](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [Summary Context](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [Chat History](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`
- [Generated Answer](https://github.com/udit-tripathi07/newsrag/blob/main/app.py): `app.py`

### Other components

- **User**
- **NewsAPI**
- **Groq LLM**

## Connections

- User → Workspace Picker: opens (evidence: `README.md`)
- Workspace Picker → Newsroom: selects (evidence: `README.md`)
- Workspace Picker → Topic Radar: selects (evidence: `README.md`)
- Workspace Picker → Document Vault: selects (evidence: `README.md`)
- Newsroom → Article Loading: loads coverage (evidence: `README.md`)
- Topic Radar → Article Loading: searches articles (evidence: `README.md`)
- NewsAPI → Article Loading: provides articles (evidence: `README.md`)
- Document Vault → PDF Parsing: uploads PDFs (evidence: `README.md`)
- Article Loading → Text Chunking: indexes articles (evidence: `README.md`)
- PDF Parsing → Text Chunking: extracts pages (evidence: `README.md`)
- Text Chunking → Embeddings: embeds chunks (evidence: `README.md`)
- Embeddings → Session FAISS: stores vectors (evidence: `README.md`)
- Newsroom → Query Rewriting: asks questions (evidence: `README.md`)
- Topic Radar → Query Rewriting: asks questions (evidence: `README.md`)
- Document Vault → Query Rewriting: asks questions (evidence: `README.md`)
- Query Rewriting → Scoped Retrieval: contextualizes query (evidence: `README.md`)
- Chat History → Query Rewriting: supplies history (evidence: `README.md`)
- Scoped Retrieval → Session FAISS: searches scope (evidence: `README.md`)
- Scoped Retrieval → Summary Context: uses full context (evidence: `README.md`)
- Scoped Retrieval → Groq LLM: provides context (evidence: `README.md`)
- Summary Context → Groq LLM: provides context (evidence: `README.md`)
- Groq LLM → Generated Answer: generates answer (evidence: `README.md`)
- Generated Answer → Chat History: updates history (evidence: `README.md`)
- Generated Answer → User: returns answer (evidence: `README.md`)
