# kwu5/finnews-rag architecture

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

- Interactive diagram: https://gitdiagram.com/kwu5/finnews-rag
- Repository: https://github.com/kwu5/finnews-rag

## Overview

FinNews-RAG ingests financial news, builds a chunk-level vector index, and serves grounded Q&A with citations and abstention. Its main workflow runs through the pipeline: fetch news, normalize and deduplicate articles, persist them, then chunk and index them. The Q&A interface retrieves from that index and passes evidence to the answer generator. A separate evaluation branch measures retrieval and generation quality and compares configurations; scheduled jobs and an API expose the daily briefing capability. Edges reflect README statements and shown source references; unsampled subsystem details are limited to documented capabilities.

Main entry points: [`src/pipeline.py`](https://github.com/kwu5/finnews-rag/blob/main/src/pipeline.py) (Ingestion pipeline), [`src/evaluation/harness.py`](https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/harness.py) (Evaluation harness), [`app.py`](https://github.com/kwu5/finnews-rag/blob/main/app.py) (Q&A demo), [`src/rag/qa.py`](https://github.com/kwu5/finnews-rag/blob/main/src/rag/qa.py) (Grounded QA engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["News ingestion"]
  node_pipeline["Ingestion pipeline<br/>[pipeline.py]"]
  node_rss_reader["RSS reader<br/>[rss_reader.py]"]
  node_news_api_client["News API client<br/>[world_news_api.py]"]
  node_extractor["Article extractor<br/>[extractor.py]"]
end

subgraph group_indexing["Article indexing"]
  node_cleaner["Text cleaner<br/>[cleaner.py]"]
  node_url_canon["URL canonicalizer<br/>[url_canon.py]"]
  node_content_hash["Content hashing<br/>[content_hash.py]"]
  node_deduplicator["Article deduplicator<br/>[deduplicator.py]"]
  node_article_db[("Article database<br/>[database.py]")]
  node_chunker["Article chunker<br/>[chunker.py]"]
  node_embedding["Embedding generator<br/>[embeddings.py]"]
  node_vector_store[("Chunk vector store<br/>[vector_store.py]")]
end

subgraph group_rag["Grounded Q&amp;A"]
  node_streamlit["Q&amp;A demo<br/>[app.py]"]
  node_retriever["Chunk retriever<br/>[retriever.py]"]
  node_qa_engine["Grounded QA engine<br/>[qa.py]"]
  node_llm_client["LLM client<br/>[llm_client.py]"]
end

subgraph group_briefing["Briefing delivery"]
  node_briefing_report["Briefing generator"]
  node_api["Briefing API<br/>[main.py]"]
  node_scheduler["Daily scheduler<br/>[jobs.py]"]
end

subgraph group_evaluation["Quality evaluation"]
  node_eval_harness["Evaluation harness<br/>[harness.py]"]
  node_eval_sweep["Configuration sweep<br/>[sweep.py]"]
  node_eval_testset["Labeled test set<br/>[testset.py]"]
  node_eval_judge["Generation judge<br/>[judge.py]"]
  node_eval_metrics["Retrieval metrics<br/>[metrics.py]"]
end

node_user(("User"))
node_rss["RSS feeds"]
node_world_news["World News API"]
node_openai["OpenAI"]

node_user -->|"asks"| node_streamlit
node_streamlit -->|"submits query"| node_qa_engine
node_pipeline -->|"fetches feeds"| node_rss_reader
node_rss_reader -->|"reads feeds"| node_rss
node_rss_reader -->|"extracts articles"| node_extractor
node_pipeline -->|"falls back"| node_news_api_client
node_news_api_client -->|"fetches news"| node_world_news
node_pipeline -->|"canonicalizes URLs"| node_url_canon
node_pipeline -->|"cleans text"| node_cleaner
node_pipeline -->|"hashes content"| node_content_hash
node_pipeline -->|"deduplicates articles"| node_deduplicator
node_deduplicator -->|"compares similarity"| node_embedding
node_pipeline -->|"saves articles"| node_article_db
node_pipeline -->|"chunks articles"| node_chunker
node_pipeline -->|"loads unindexed"| node_article_db
node_pipeline -->|"embeds chunks"| node_embedding
node_pipeline -->|"indexes chunks"| node_vector_store
node_streamlit -->|"initializes"| node_embedding
node_streamlit -->|"initializes"| node_vector_store
node_streamlit -->|"initializes"| node_llm_client
node_qa_engine -->|"retrieves context"| node_retriever
node_retriever -->|"embeds query"| node_embedding
node_retriever -->|"searches chunks"| node_vector_store
node_qa_engine -->|"generates answer"| node_llm_client
node_llm_client -->|"calls model"| node_openai
node_qa_engine -->|"returns citations"| node_streamlit
node_pipeline -->|"generates briefing"| node_briefing_report
node_briefing_report -->|"summarizes news"| node_llm_client
node_user -->|"requests briefing"| node_api
node_api -->|"runs pipeline"| node_pipeline
node_scheduler -->|"runs daily"| node_pipeline
node_eval_harness -->|"measures retrieval"| node_retriever
node_eval_harness -->|"evaluates answers"| node_qa_engine
node_eval_harness -->|"loads queries"| node_eval_testset
node_eval_harness -->|"computes scores"| node_eval_metrics
node_eval_harness -->|"judges generations"| node_eval_judge
node_eval_sweep -->|"compares configurations"| node_eval_harness
node_eval_sweep -->|"varies chunking"| node_chunker
node_eval_sweep -->|"builds indexes"| node_vector_store

click node_pipeline "https://github.com/kwu5/finnews-rag/blob/main/src/pipeline.py"
click node_rss_reader "https://github.com/kwu5/finnews-rag/blob/main/src/ingestion/rss_reader.py"
click node_news_api_client "https://github.com/kwu5/finnews-rag/blob/main/src/ingestion/world_news_api.py"
click node_extractor "https://github.com/kwu5/finnews-rag/blob/main/src/ingestion/extractor.py"
click node_cleaner "https://github.com/kwu5/finnews-rag/blob/main/src/processing/cleaner.py"
click node_url_canon "https://github.com/kwu5/finnews-rag/blob/main/src/processing/url_canon.py"
click node_content_hash "https://github.com/kwu5/finnews-rag/blob/main/src/processing/content_hash.py"
click node_deduplicator "https://github.com/kwu5/finnews-rag/blob/main/src/processing/deduplicator.py"
click node_article_db "https://github.com/kwu5/finnews-rag/blob/main/src/storage/database.py"
click node_chunker "https://github.com/kwu5/finnews-rag/blob/main/src/rag/chunker.py"
click node_embedding "https://github.com/kwu5/finnews-rag/blob/main/src/processing/embeddings.py"
click node_vector_store "https://github.com/kwu5/finnews-rag/blob/main/src/storage/vector_store.py"
click node_streamlit "https://github.com/kwu5/finnews-rag/blob/main/app.py"
click node_retriever "https://github.com/kwu5/finnews-rag/blob/main/src/rag/retriever.py"
click node_qa_engine "https://github.com/kwu5/finnews-rag/blob/main/src/rag/qa.py"
click node_llm_client "https://github.com/kwu5/finnews-rag/blob/main/src/summarization/llm_client.py"
click node_briefing_report "https://github.com/kwu5/finnews-rag/blob/main/src/summarization/report_generator.py"
click node_api "https://github.com/kwu5/finnews-rag/blob/main/src/api/main.py"
click node_scheduler "https://github.com/kwu5/finnews-rag/blob/main/src/scheduler/jobs.py"
click node_eval_harness "https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/harness.py"
click node_eval_sweep "https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/sweep.py"
click node_eval_testset "https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/testset.py"
click node_eval_judge "https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/judge.py"
click node_eval_metrics "https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/metrics.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_pipeline,node_rss_reader,node_news_api_client,node_extractor,node_user toneBlue
class node_cleaner,node_url_canon,node_content_hash,node_deduplicator,node_article_db,node_chunker,node_embedding,node_vector_store toneAmber
class node_streamlit,node_retriever,node_qa_engine,node_llm_client,node_world_news toneMint
class node_briefing_report,node_api,node_scheduler toneRose
class node_eval_harness,node_eval_sweep,node_eval_testset,node_eval_judge,node_eval_metrics,node_rss,node_openai toneIndigo
```

## Components

### News ingestion

- [Ingestion pipeline](https://github.com/kwu5/finnews-rag/blob/main/src/pipeline.py): `src/pipeline.py`
- [RSS reader](https://github.com/kwu5/finnews-rag/blob/main/src/ingestion/rss_reader.py): `src/ingestion/rss_reader.py`
- [News API client](https://github.com/kwu5/finnews-rag/blob/main/src/ingestion/world_news_api.py): `src/ingestion/world_news_api.py`
- [Article extractor](https://github.com/kwu5/finnews-rag/blob/main/src/ingestion/extractor.py): `src/ingestion/extractor.py`

### Article indexing

- [Text cleaner](https://github.com/kwu5/finnews-rag/blob/main/src/processing/cleaner.py): `src/processing/cleaner.py`
- [URL canonicalizer](https://github.com/kwu5/finnews-rag/blob/main/src/processing/url_canon.py): `src/processing/url_canon.py`
- [Content hashing](https://github.com/kwu5/finnews-rag/blob/main/src/processing/content_hash.py): `src/processing/content_hash.py`
- [Article deduplicator](https://github.com/kwu5/finnews-rag/blob/main/src/processing/deduplicator.py): `src/processing/deduplicator.py`
- [Article database](https://github.com/kwu5/finnews-rag/blob/main/src/storage/database.py): `src/storage/database.py`
- [Article chunker](https://github.com/kwu5/finnews-rag/blob/main/src/rag/chunker.py): `src/rag/chunker.py`
- [Embedding generator](https://github.com/kwu5/finnews-rag/blob/main/src/processing/embeddings.py): `src/processing/embeddings.py`
- [Chunk vector store](https://github.com/kwu5/finnews-rag/blob/main/src/storage/vector_store.py): `src/storage/vector_store.py`

### Grounded Q&A

- [Q&A demo](https://github.com/kwu5/finnews-rag/blob/main/app.py): `app.py`
- [Chunk retriever](https://github.com/kwu5/finnews-rag/blob/main/src/rag/retriever.py): `src/rag/retriever.py`
- [Grounded QA engine](https://github.com/kwu5/finnews-rag/blob/main/src/rag/qa.py): `src/rag/qa.py`
- [LLM client](https://github.com/kwu5/finnews-rag/blob/main/src/summarization/llm_client.py): `src/summarization/llm_client.py`

### Briefing delivery

- [Briefing generator](https://github.com/kwu5/finnews-rag/blob/main/src/summarization/report_generator.py): `src/summarization/report_generator.py`
- [Briefing API](https://github.com/kwu5/finnews-rag/blob/main/src/api/main.py): `src/api/main.py`
- [Daily scheduler](https://github.com/kwu5/finnews-rag/blob/main/src/scheduler/jobs.py): `src/scheduler/jobs.py`

### Quality evaluation

- [Evaluation harness](https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/harness.py): `src/evaluation/harness.py`
- [Configuration sweep](https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/sweep.py): `src/evaluation/sweep.py`
- [Labeled test set](https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/testset.py): `src/evaluation/testset.py`
- [Generation judge](https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/judge.py): `src/evaluation/judge.py`
- [Retrieval metrics](https://github.com/kwu5/finnews-rag/blob/main/src/evaluation/metrics.py): `src/evaluation/metrics.py`

### Other components

- **User**
- **RSS feeds**
- **World News API**
- **OpenAI**

## Connections

- User → Q&A demo: asks (evidence: `app.py`)
- Q&A demo → Grounded QA engine: submits query (evidence: `app.py`)
- Ingestion pipeline → RSS reader: fetches feeds (evidence: `src/pipeline.py`)
- RSS reader → RSS feeds: reads feeds (evidence: `README.md`)
- RSS reader → Article extractor: extracts articles (evidence: `src/ingestion/rss_reader.py`)
- Ingestion pipeline → News API client: falls back (evidence: `src/pipeline.py`)
- News API client → World News API: fetches news (evidence: `README.md`)
- Ingestion pipeline → URL canonicalizer: canonicalizes URLs (evidence: `src/pipeline.py`)
- Ingestion pipeline → Text cleaner: cleans text (evidence: `src/pipeline.py`)
- Ingestion pipeline → Content hashing: hashes content (evidence: `src/pipeline.py`)
- Ingestion pipeline → Article deduplicator: deduplicates articles (evidence: `src/pipeline.py`)
- Article deduplicator → Embedding generator: compares similarity (evidence: `src/processing/deduplicator.py`)
- Ingestion pipeline → Article database: saves articles (evidence: `src/pipeline.py`)
- Ingestion pipeline → Article chunker: chunks articles (evidence: `src/pipeline.py`)
- Ingestion pipeline → Article database: loads unindexed (evidence: `src/pipeline.py`)
- Ingestion pipeline → Embedding generator: embeds chunks (evidence: `src/pipeline.py`)
- Ingestion pipeline → Chunk vector store: indexes chunks (evidence: `src/pipeline.py`)
- Q&A demo → Embedding generator: initializes (evidence: `app.py`)
- Q&A demo → Chunk vector store: initializes (evidence: `app.py`)
- Q&A demo → LLM client: initializes (evidence: `app.py`)
- Grounded QA engine → Chunk retriever: retrieves context (evidence: `src/rag/qa.py`)
- Chunk retriever → Embedding generator: embeds query (evidence: `src/rag/retriever.py`)
- Chunk retriever → Chunk vector store: searches chunks (evidence: `src/rag/retriever.py`)
- Grounded QA engine → LLM client: generates answer (evidence: `src/rag/qa.py`)
- LLM client → OpenAI: calls model (evidence: `src/summarization/llm_client.py`)
- Grounded QA engine → Q&A demo: returns citations (evidence: `app.py`)
- Ingestion pipeline → Briefing generator: generates briefing (evidence: `src/pipeline.py`)
- Briefing generator → LLM client: summarizes news (evidence: `README.md`)
- User → Briefing API: requests briefing (evidence: `src/api/main.py`)
- Briefing API → Ingestion pipeline: runs pipeline (evidence: `src/api/main.py`)
- Daily scheduler → Ingestion pipeline: runs daily (evidence: `src/scheduler/jobs.py`)
- Evaluation harness → Chunk retriever: measures retrieval (evidence: `src/evaluation/harness.py`)
- Evaluation harness → Grounded QA engine: evaluates answers (evidence: `src/evaluation/harness.py`)
- Evaluation harness → Labeled test set: loads queries (evidence: `src/evaluation/harness.py`)
- Evaluation harness → Retrieval metrics: computes scores (evidence: `src/evaluation/harness.py`)
- Evaluation harness → Generation judge: judges generations (evidence: `src/evaluation/harness.py`)
- Configuration sweep → Evaluation harness: compares configurations (evidence: `src/evaluation/sweep.py`)
- Configuration sweep → Article chunker: varies chunking (evidence: `src/evaluation/sweep.py`)
- Configuration sweep → Chunk vector store: builds indexes (evidence: `src/evaluation/sweep.py`)
