# nikil-crypto-spec/ai_chronicle architecture

> Architecture diagram of the GitHub repository nikil-crypto-spec/ai_chronicle, 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/nikil-crypto-spec/ai_chronicle
- Repository: https://github.com/nikil-crypto-spec/ai_chronicle

## Overview

This is a manually run scientific-newsletter generator. Its main workflow loads publisher/topic settings, collects recent articles, filters and deduplicates them, ranks by topic relevance, optionally fetches article text, summarizes through a selected LLM or abstract fallback, then renders and sends an HTML digest or writes a dry-run file. SQLite state prevents repeats across live runs. The graph preserves both collector types and the optional embedding and LLM paths; unsampled subsystem links are included only where the README or SOURCE INDEX supports them.

Main entry points: [`newsletter/sender.py`](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/sender.py) (Email or dry-run output), [`newsletter/llm/factory.py`](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/llm/factory.py) (LLM selection), [`newsletter/config.py`](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/config.py) (Runtime settings), [`newsletter/models.py`](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/models.py) (Raw article items)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Configuration"]
  node_source_config["Publisher sources<br/>[sources.yaml]"]
  node_topic_config["Topics and prompts<br/>[topics.yaml]"]
  node_runtime_config["Runtime settings<br/>[config.py]"]
end

subgraph group_collection["Article collection"]
  node_collector_registry["Collector selection<br/>[registry.py]"]
  node_rss_collector["RSS / Atom collector<br/>[rss.py]"]
  node_html_collector["HTML collector<br/>[html.py]"]
  node_raw_items["Raw article items<br/>[models.py]"]
end

subgraph group_processing["Relevance and summaries"]
  node_state[("Seen-item state<br/>[state.py]")]
  node_dedupe["Cross-source dedupe<br/>[dedupe.py]"]
  node_ranking["Topic ranking<br/>[ranking.py]"]
  node_fulltext["Full-text enrichment<br/>[fulltext.py]"]
  node_llm_factory["LLM selection<br/>[factory.py]"]
  node_local_llm["Local LLM adapter<br/>[local.py]"]
  node_copilot_llm["Copilot adapter<br/>[copilot.py]"]
  node_summariser["Structured summaries<br/>[summariser.py]"]
end

subgraph group_delivery["Newsletter delivery"]
  node_formatter["HTML rendering<br/>[formatter.py]"]
  node_template["Newsletter template<br/>[newsletter.html.j2]"]
  node_sender["Email or dry-run output<br/>[sender.py]"]
  node_output_file["Rendered HTML file"]
end

node_user(("Newsletter user"))
node_publisher_sites(("Scientific publishers"))
node_llm_services(("LLM services"))
node_smtp(("SMTP service"))

node_user -->|"configures sources"| node_source_config
node_user -->|"configures interests"| node_topic_config
node_source_config -->|"selects collector"| node_collector_registry
node_collector_registry -->|"builds RSS"| node_rss_collector
node_collector_registry -->|"builds HTML"| node_html_collector
node_publisher_sites -->|"provides feeds"| node_rss_collector
node_publisher_sites -->|"provides pages"| node_html_collector
node_rss_collector -->|"produces items"| node_raw_items
node_html_collector -->|"produces items"| node_raw_items
node_topic_config -->|"loads topics and prompts"| node_runtime_config
node_user -->|"sets run options"| node_runtime_config
node_user -->|"controls state use"| node_state
node_raw_items -->|"checks seen URLs"| node_state
node_raw_items -->|"deduplicates"| node_dedupe
node_dedupe -->|"ranks candidates"| node_ranking
node_topic_config -->|"scores against topics"| node_ranking
node_ranking -->|"selects top items"| node_fulltext
node_fulltext -->|"provides article text"| node_summariser
node_ranking -->|"provides ranked items"| node_summariser
node_runtime_config -->|"configures backend"| node_llm_factory
node_llm_factory -->|"builds local adapter"| node_local_llm
node_llm_factory -->|"builds Copilot adapter"| node_copilot_llm
node_local_llm -->|"calls Ollama"| node_llm_services
node_copilot_llm -->|"calls Azure OpenAI"| node_llm_services
node_llm_factory -->|"supplies client"| node_summariser
node_summariser -->|"provides summaries"| node_formatter
node_formatter -->|"renders template"| node_template
node_formatter -->|"provides subject and HTML"| node_sender
node_runtime_config -->|"provides SMTP settings"| node_sender
node_sender -->|"sends email"| node_smtp
node_sender -->|"writes dry run"| node_output_file
node_sender -->|"records sent items"| node_state

click node_source_config "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/config/sources.yaml"
click node_topic_config "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/config/topics.yaml"
click node_runtime_config "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/config.py"
click node_collector_registry "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/collectors/registry.py"
click node_rss_collector "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/collectors/rss.py"
click node_html_collector "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/collectors/html.py"
click node_raw_items "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/models.py"
click node_state "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/state.py"
click node_dedupe "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/dedupe.py"
click node_ranking "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/ranking.py"
click node_fulltext "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/fulltext.py"
click node_llm_factory "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/llm/factory.py"
click node_local_llm "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/llm/local.py"
click node_copilot_llm "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/llm/copilot.py"
click node_summariser "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/summariser.py"
click node_formatter "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/formatter.py"
click node_template "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/templates/newsletter.html.j2"
click node_sender "https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/sender.py"
click node_output_file "https://github.com/nikil-crypto-spec/ai_chronicle/tree/main/out"

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_source_config,node_topic_config,node_runtime_config,node_user toneBlue
class node_collector_registry,node_rss_collector,node_html_collector,node_raw_items toneAmber
class node_state,node_dedupe,node_ranking,node_fulltext,node_llm_factory,node_local_llm,node_copilot_llm,node_summariser toneMint
class node_formatter,node_template,node_sender,node_output_file toneRose
class node_publisher_sites,node_llm_services,node_smtp toneIndigo
```

## Components

### Configuration

- [Publisher sources](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/config/sources.yaml): `config/sources.yaml`
- [Topics and prompts](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/config/topics.yaml): `config/topics.yaml`
- [Runtime settings](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/config.py): `newsletter/config.py`

### Article collection

- [Collector selection](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/collectors/registry.py): `newsletter/collectors/registry.py`
- [RSS / Atom collector](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/collectors/rss.py): `newsletter/collectors/rss.py`
- [HTML collector](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/collectors/html.py): `newsletter/collectors/html.py`
- [Raw article items](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/models.py): `newsletter/models.py`

### Relevance and summaries

- [Seen-item state](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/state.py): `newsletter/state.py`
- [Cross-source dedupe](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/dedupe.py): `newsletter/dedupe.py`
- [Topic ranking](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/ranking.py): `newsletter/ranking.py`
- [Full-text enrichment](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/fulltext.py): `newsletter/fulltext.py`
- [LLM selection](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/llm/factory.py): `newsletter/llm/factory.py`
- [Local LLM adapter](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/llm/local.py): `newsletter/llm/local.py`
- [Copilot adapter](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/llm/copilot.py): `newsletter/llm/copilot.py`
- [Structured summaries](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/summariser.py): `newsletter/summariser.py`

### Newsletter delivery

- [HTML rendering](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/formatter.py): `newsletter/formatter.py`
- [Newsletter template](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/templates/newsletter.html.j2): `templates/newsletter.html.j2`
- [Email or dry-run output](https://github.com/nikil-crypto-spec/ai_chronicle/blob/main/newsletter/sender.py): `newsletter/sender.py`
- [Rendered HTML file](https://github.com/nikil-crypto-spec/ai_chronicle/tree/main/out): `out`

### Other components

- **Newsletter user**
- **Scientific publishers**
- **LLM services**
- **SMTP service**

## Connections

- Newsletter user → Publisher sources: configures sources (evidence: `README.md`)
- Newsletter user → Topics and prompts: configures interests (evidence: `README.md`)
- Publisher sources → Collector selection: selects collector (evidence: `newsletter/collectors/registry.py`)
- Collector selection → RSS / Atom collector: builds RSS (evidence: `newsletter/collectors/registry.py`)
- Collector selection → HTML collector: builds HTML (evidence: `newsletter/collectors/registry.py`)
- Scientific publishers → RSS / Atom collector: provides feeds (evidence: `README.md`)
- Scientific publishers → HTML collector: provides pages (evidence: `newsletter/collectors/html.py`)
- RSS / Atom collector → Raw article items: produces items (evidence: `newsletter/collectors/rss.py`)
- HTML collector → Raw article items: produces items (evidence: `newsletter/collectors/html.py`)
- Topics and prompts → Runtime settings: loads topics and prompts (evidence: `newsletter/config.py`)
- Newsletter user → Runtime settings: sets run options (evidence: `README.md`)
- Newsletter user → Seen-item state: controls state use (evidence: `README.md`)
- Raw article items → Seen-item state: checks seen URLs (evidence: `README.md`)
- Raw article items → Cross-source dedupe: deduplicates (evidence: `README.md`)
- Cross-source dedupe → Topic ranking: ranks candidates (evidence: `run.py`)
- Topics and prompts → Topic ranking: scores against topics (evidence: `newsletter/ranking.py`)
- Topic ranking → Full-text enrichment: selects top items (evidence: `run.py`)
- Full-text enrichment → Structured summaries: provides article text (evidence: `run.py`)
- Topic ranking → Structured summaries: provides ranked items (evidence: `run.py`)
- Runtime settings → LLM selection: configures backend (evidence: `newsletter/llm/factory.py`)
- LLM selection → Local LLM adapter: builds local adapter (evidence: `newsletter/llm/factory.py`)
- LLM selection → Copilot adapter: builds Copilot adapter (evidence: `newsletter/llm/factory.py`)
- Local LLM adapter → LLM services: calls Ollama (evidence: `README.md`)
- Copilot adapter → LLM services: calls Azure OpenAI (evidence: `README.md`)
- LLM selection → Structured summaries: supplies client (evidence: `run.py`)
- Structured summaries → HTML rendering: provides summaries (evidence: `run.py`)
- HTML rendering → Newsletter template: renders template (evidence: `newsletter/formatter.py`)
- HTML rendering → Email or dry-run output: provides subject and HTML (evidence: `run.py`)
- Runtime settings → Email or dry-run output: provides SMTP settings (evidence: `run.py`)
- Email or dry-run output → SMTP service: sends email (evidence: `README.md`)
- Email or dry-run output → Rendered HTML file: writes dry run (evidence: `README.md`)
- Email or dry-run output → Seen-item state: records sent items (evidence: `run.py`)
