# korelexai/ai-cyber-newspaper architecture

> Architecture diagram of the GitHub repository korelexai/ai-cyber-newspaper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/korelexai/ai-cyber-newspaper
- Repository: https://github.com/korelexai/ai-cyber-newspaper

## Overview

#### Purpose and entry points
This is a Python batch pipeline that produces a daily, static “newspaper” of the top AI-security stories from recent feeds, Hacker News, and arXiv. The primary executable is `main.py`; it orchestrates collection through HTML edition generation. Generated content is served as static files from `output/`, optionally through GitHub Pages.

#### Pipeline orchestration
`main.py` coordinates four stages: fetch raw articles, score/filter them, summarize the selected stories, and render an edition. It is the principal control-flow boundary and owns the handoff of normalized article records between stages.
- `main.py`
- `fetch.py`
- `generate.py`

#### Source definition and acquisition
Source scope is centralized in `sources.py`: RSS/Atom source definitions, Hacker News searches, AI-security keyword weights, lookback window, score threshold, and top-story count. `fetch.py` retrieves each configured source and normalizes heterogeneous upstream responses into a common article shape; external source failures should remain isolated here rather than affecting rendering.
- `sources.py`
- `fetch.py`

#### Relevance filtering and ranking
`score.py` applies the recency window and keyword-based AI-plus-cybersecurity relevance model, then ranks candidate articles and selects the configured top N. This is the editorial-policy boundary: changing scope, strictness, or incident emphasis should flow from `sources.py` into this stage rather than be embedded in fetch or template logic.
- `score.py`
- `sources.py`

#### Summarization boundary
Selected articles pass to `summarize.py`, which produces short “why this matters” blurbs. It conditionally calls Anthropic Claude when `ANTHROPIC_API_KEY` is available; otherwise it uses article-provided text as a fallback. This keeps the core edition pipeline functional without an AI-provider dependency.
- `summarize.py`
- `main.py`

#### Rendering and publication artifacts
`generate.py` renders ranked, summarized stories into the newspaper template and writes both the current edition and date-stamped archives. The static-output contract is `output/latest.html`, `output/index.html`, and edition HTML/JSON files under `output/editions/`; consumers need only serve this directory.
- `generate.py`
- `templates/newspaper.html`
- `output/editions/2026-08-20.html`

#### Scheduled runtime and infrastructure
The intended runtime is Python with dependencies declared in `requirements.txt`. GitHub Actions runs the job daily and commits regenerated output, making the repository itself the publication store. GitHub Pages can serve `output/`; Vercel-related files indicate an alternative static deployment path. A separate subscription/API and Supabase schema area exists, but it is not part of the documented core newspaper pipeline.
- `.github/workflows/daily.yml`
- `requirements.txt`
- `api/subscribe.py`
- `supabase/schema.sql/schema.sql`

Main entry points: [`fetch.py`](https://github.com/korelexai/ai-cyber-newspaper/blob/main/fetch.py) (Acquisition & normalization), [`generate.py`](https://github.com/korelexai/ai-cyber-newspaper/blob/main/generate.py) (Edition renderer), [`main.py`](https://github.com/korelexai/ai-cyber-newspaper/blob/main/main.py) (Pipeline orchestrator), [`score.py`](https://github.com/korelexai/ai-cyber-newspaper/blob/main/score.py) (Relevance ranking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Daily runtime"]
  node_actions{{"Daily GitHub Action<br/>scheduler<br/>[daily.yml]"}}
  node_requirements["Python dependencies<br/>[requirements.txt]"]
  node_main["Pipeline orchestrator<br/>Python entry point<br/>[main.py]"]
end

subgraph group_pipeline["Editorial pipeline"]
  node_sources["Source policy<br/>source configuration<br/>[sources.py]"]
  node_fetch["Acquisition &amp; normalization<br/>Python stage<br/>[fetch.py]"]
  node_feeds(("RSS / Atom feeds<br/>external sources"))
  node_hackernews(("Hacker News search<br/>external source"))
  node_arxiv(("arXiv<br/>external source"))
  node_score["Relevance ranking<br/>Python stage<br/>[score.py]"]
  node_summarize["Story summarization<br/>Python stage<br/>[summarize.py]"]
  node_claude(("Anthropic Claude<br/>optional AI provider"))
end

subgraph group_publication["Static publication"]
  node_generate["Edition renderer<br/>Python stage<br/>[generate.py]"]
  node_template["Newspaper template<br/>HTML template<br/>[newspaper.html]"]
  node_editions["Edition archive<br/>static artifacts<br/>[2026-08-20.html]"]
  node_static_output[("Static output<br/>publication contract")]
  node_pages(("GitHub Pages / static host<br/>deployment target"))
end

subgraph group_optional["Separate subscription area"]
  node_subscribe["Subscription API<br/>separate API<br/>[subscribe.py]"]
  node_supabase[("Supabase schema<br/>database schema<br/>[schema.sql]")]
end

node_actions -->|"runs daily"| node_main
node_requirements -.->|"provides runtime"| node_main
node_main -->|"collects articles"| node_fetch
node_sources -->|"defines inputs"| node_fetch
node_feeds -->|"retrieves"| node_fetch
node_hackernews -->|"searches"| node_fetch
node_arxiv -->|"retrieves"| node_fetch
node_fetch -->|"normalized candidates"| node_score
node_sources -->|"editorial policy"| node_score
node_score -->|"selected stories"| node_summarize
node_claude -.->|"optional blurb generation"| node_summarize
node_summarize -->|"ranked summaries"| node_generate
node_template -->|"renders with"| node_generate
node_generate -->|"writes current edition"| node_static_output
node_generate -->|"writes dated editions"| node_editions
node_static_output -->|"serves"| node_pages
node_subscribe -->|"uses"| node_supabase

click node_actions "https://github.com/korelexai/ai-cyber-newspaper/blob/main/.github/workflows/daily.yml"
click node_requirements "https://github.com/korelexai/ai-cyber-newspaper/blob/main/requirements.txt"
click node_main "https://github.com/korelexai/ai-cyber-newspaper/blob/main/main.py"
click node_sources "https://github.com/korelexai/ai-cyber-newspaper/blob/main/sources.py"
click node_fetch "https://github.com/korelexai/ai-cyber-newspaper/blob/main/fetch.py"
click node_score "https://github.com/korelexai/ai-cyber-newspaper/blob/main/score.py"
click node_summarize "https://github.com/korelexai/ai-cyber-newspaper/blob/main/summarize.py"
click node_generate "https://github.com/korelexai/ai-cyber-newspaper/blob/main/generate.py"
click node_template "https://github.com/korelexai/ai-cyber-newspaper/blob/main/templates/newspaper.html"
click node_editions "https://github.com/korelexai/ai-cyber-newspaper/blob/main/output/editions/2026-08-20.html"
click node_subscribe "https://github.com/korelexai/ai-cyber-newspaper/blob/main/api/subscribe.py"
click node_supabase "https://github.com/korelexai/ai-cyber-newspaper/blob/main/supabase/schema.sql/schema.sql"

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_actions,node_requirements,node_main toneBlue
class node_sources,node_fetch,node_feeds,node_hackernews,node_arxiv,node_score,node_summarize,node_claude toneAmber
class node_generate,node_template,node_editions,node_static_output,node_pages toneMint
class node_subscribe,node_supabase toneRose
```

## Components

### Daily runtime

- [Daily GitHub Action](https://github.com/korelexai/ai-cyber-newspaper/blob/main/.github/workflows/daily.yml): scheduler · Runs the pipeline daily and commits regenerated content. · `.github/workflows/daily.yml`
- [Python dependencies](https://github.com/korelexai/ai-cyber-newspaper/blob/main/requirements.txt): dependencies · `requirements.txt`
- [Pipeline orchestrator](https://github.com/korelexai/ai-cyber-newspaper/blob/main/main.py): Python entry point · Coordinates normalized article records across all editorial stages. · `main.py`

### Editorial pipeline

- [Source policy](https://github.com/korelexai/ai-cyber-newspaper/blob/main/sources.py): source configuration · Defines feeds, searches, scoring weights, windows, and limits. · `sources.py`
- [Acquisition & normalization](https://github.com/korelexai/ai-cyber-newspaper/blob/main/fetch.py): Python stage · Isolates upstream failures while converting sources to common article records. · `fetch.py`
- **RSS / Atom feeds**: external sources
- **Hacker News search**: external source
- **arXiv**: external source
- [Relevance ranking](https://github.com/korelexai/ai-cyber-newspaper/blob/main/score.py): Python stage · Filters by recency and AI-security relevance, then selects top stories. · `score.py`
- [Story summarization](https://github.com/korelexai/ai-cyber-newspaper/blob/main/summarize.py): Python stage · Creates why-it-matters blurbs with a text fallback. · `summarize.py`
- **Anthropic Claude**: optional AI provider · Used only when ANTHROPIC_API_KEY is available.

### Static publication

- [Edition renderer](https://github.com/korelexai/ai-cyber-newspaper/blob/main/generate.py): Python stage · Writes current and archived HTML and JSON editions. · `generate.py`
- [Newspaper template](https://github.com/korelexai/ai-cyber-newspaper/blob/main/templates/newspaper.html): HTML template · `templates/newspaper.html`
- [Edition archive](https://github.com/korelexai/ai-cyber-newspaper/blob/main/output/editions/2026-08-20.html): static artifacts · Contains dated edition HTML and JSON. · `output/editions/2026-08-20.html`
- **Static output**: publication contract · Includes latest.html and index.html for static hosting.
- **GitHub Pages / static host**: deployment target

### Separate subscription area

Not part of the core newspaper pipeline.

- [Subscription API](https://github.com/korelexai/ai-cyber-newspaper/blob/main/api/subscribe.py): separate API · `api/subscribe.py`
- [Supabase schema](https://github.com/korelexai/ai-cyber-newspaper/blob/main/supabase/schema.sql/schema.sql): database schema · `supabase/schema.sql/schema.sql`

## Connections

- Daily GitHub Action → Pipeline orchestrator: runs daily
- Python dependencies → Pipeline orchestrator: provides runtime
- Pipeline orchestrator → Acquisition & normalization: collects articles
- Source policy → Acquisition & normalization: defines inputs
- RSS / Atom feeds → Acquisition & normalization: retrieves
- Hacker News search → Acquisition & normalization: searches
- arXiv → Acquisition & normalization: retrieves
- Acquisition & normalization → Relevance ranking: normalized candidates
- Source policy → Relevance ranking: editorial policy
- Relevance ranking → Story summarization: selected stories
- Anthropic Claude → Story summarization: optional blurb generation
- Story summarization → Edition renderer: ranked summaries
- Newspaper template → Edition renderer: renders with
- Edition renderer → Static output: writes current edition
- Edition renderer → Edition archive: writes dated editions
- Static output → GitHub Pages / static host: serves
- Subscription API → Supabase schema: uses
