How sanjayrk2007/morningdrop works
Purpose and Entry Points
The Morning Drop is a Python-based daily newsletter curation pipeline for Indian Gen-Z/young professionals. It ingests news, uses LLMs to select and rewrite stories, adds live sports context, formats HTML, and sends via email.
Primary CLI entry point: main.py, supporting draft/review (--draft, --approve) and unattended execution (--auto). Windows scheduling is provided by setup_scheduler.ps1 and run_morning_drop.bat; CI/scheduled automation may also run through .github/workflows/morning_drop.yml.
Workflow Orchestration
graph.py defines the LangGraph state-machine pipeline and its transitions. The graph separates acquisition/selection from downstream enrichment and delivery, allowing a human approval boundary after curation.
Core flow: fetch RSS stories → exclude prior deliveries → LLM-select stories → cross-category deduplicate → either persist a draft or continue automatically → inject sports data → narrate by category persona → produce HTML → email delivery.
Paths: graph.py, main.py, config.py.
Content Acquisition and Curation
RSS source/category definitions and behavioral settings are externalized in config.yaml, loaded through config.py. The curation stage operates on recent feed items and uses configured LLM providers/models to choose a compact set of newsletter-worthy stories.
Semantic/fuzzy cross-deduplication is an explicit architecture stage, preventing repeated stories across domains. Its output is the normalized candidate set that becomes either the review draft or final newsletter input.
Paths: graph.py, config.yaml, config.py.
LLM Provider Boundary
The system uses a dual LLM strategy: OpenRouter-hosted models are preferred when OPENROUTER_API_KEY is available; a local Ollama runtime is the resilience/offline fallback. LLMs serve two distinct roles: editorial selection and category-specific conversational narration.
This isolates variable provider availability from the rest of the graph: rate limits, missing cloud credentials, or cloud failures should route work to local models rather than block newsletter generation.
Paths: graph.py, config.py, requirements.txt.
Human Review and Persistent Memory
Manual execution has a two-phase control boundary: --draft saves curated output for editorial review; --approve resumes narration and delivery from that curated selection. Auto mode bypasses this approval gate.
SQLite stores sent-story/history state so previously delivered URLs can be filtered before selection, preserving continuity across scheduled runs. The checked-in database represents the local persistence artifact.
Paths: main.py, db.py, news.db.
Sports Enrichment, Presentation, and Delivery
Sports content is enriched late in the pipeline so live cricket and football information remains current at send time. sports_api.py encapsulates external scoreboard/API access; its result is fed into the sports narration rather than treated as a normal RSS source.
The final stage turns narrated sections into an HTML email and sends it through Gmail SMTP using environment-provided credentials. Delivery is therefore an external side-effect boundary after all curation and rendering work succeeds.
Paths: sports_api.py, email_sender.py, graph.py.
Runtime and Operations
The runtime is Python with LangGraph/LangChain-style LLM integration, SQLite local state, OpenRouter and Ollama inference backends, RSS sources, sports APIs, and Gmail SMTP. Daily unattended operation targets Windows Task Scheduler via setup_scheduler.ps1; repository automation is also represented in .github/workflows/morning_drop.yml.
Paths: requirements.txt, setup_scheduler.ps1, .github/workflows/morning_drop.yml.
Main entry points: graph.py LangGraph workflow · config.py LLM provider routing · sports_api.py Live sports data · email_sender.py Gmail SMTP sender
Components 19
Pipeline Control
- CLI modes · Runs draft, approval, or unattended modes.
main.py - LangGraph workflow · Coordinates curation, review, enrichment, rendering, and delivery.
graph.py - Settings loader
config.py - Draft approval gate · Draft mode pauses after curated selection; approval resumes delivery.
main.py
Curation & Enrichment
- RSS sources & rules
config.yaml - Delivery history · Filters URLs already sent and records continuity state.
news.db - Select & deduplicate · Chooses newsletter stories and removes cross-category repeats.
graph.py - Live sports data · Fetches current cricket and football context late in the run.
sports_api.py - Category narration · Produces persona-specific conversational sections.
graph.py - HTML newsletter
graph.py
External Services
- RSS feeds
- LLM provider routing · Prefers OpenRouter and falls back to local Ollama.
config.py - OpenRouter models
- Ollama runtime · Resilience and offline inference fallback.
- Scoreboard APIs
- Gmail SMTP sender
email_sender.py - Gmail SMTP
Automation
- Windows daily schedule
setup_scheduler.ps1 - GitHub scheduled run
.github/workflows/morning_drop.yml
Connections 22
- Windows daily schedule → CLI modes: launches
- GitHub scheduled run → CLI modes: runs
- CLI modes → LangGraph workflow: selects mode
- Settings loader → LangGraph workflow: configures
- RSS sources & rules → Settings loader: loaded by
- LangGraph workflow → RSS feeds: fetches stories
- LangGraph workflow → Delivery history: excludes prior deliveries
- LangGraph workflow → Select & deduplicate: passes recent stories
- Select & deduplicate → LLM provider routing: uses for selection
- LLM provider routing → OpenRouter models: preferred
- LLM provider routing → Ollama runtime: fallback
- Select & deduplicate → Draft approval gate: persists draft
- Draft approval gate → LangGraph workflow: approved selection resumes
- LangGraph workflow → Live sports data: enriches late
- Live sports data → Scoreboard APIs: retrieves live scores
- Live sports data → Category narration: sports context
- LangGraph workflow → Category narration: curated stories
- Category narration → LLM provider routing: uses for rewriting
- Category narration → HTML newsletter: sections
- HTML newsletter → Gmail SMTP sender: rendered email
- Gmail SMTP sender → Gmail SMTP: sends via SMTP
- Gmail SMTP sender → Delivery history: records sent stories