BD News Lens & BCS Editorial Studio

Bilingual multi-perspective Bangladesh news aggregator and editorial annotation workspace

বাইলিঙ্গুয়াল সংবাদ বিশ্লেষণ · EN | বাংলা

Context & Problem

Following national events in Bangladesh across both Bangla and English newsrooms usually means bouncing between dozens of tabs, trying to notice which outlets lead with a story and which ignore it. At the same time, preparing for Bangladesh Civil Service (BCS) written essays requires collecting high-signal opinion pieces, grading their analytical depth, and extracting structured notes without losing track of the original paragraph context.

BD News Lens (bdnews) brings those two workflows into one system: a cross-lingual news intelligence pipeline paired with an editorial reading and annotation studio.

System Architecture

18 News Portals (10 Bangla, 8 English) + 11 Opinion Feeds
   │
   ▼  3-Tier Ingestion (ETag/304 · homepage_rank · trafilatura)
   │
   ├──► Cross-Lingual Clustering
   │      ├─ Gemini embeddings (primary)
   │      └─ Offline TF-IDF + bilingual entity glossary (--no-llm fallback)
   │
   ├──► Deterministic Scoring & Blindspot Engine (0–100)
   │      └─ Breadth (35%) · Perspective (20%) · Front-page (20%) · Velocity (15%) · Impact (10%)
   │
   └──► Dual Persistence & Delivery
          ├─ Local/CI SQLite + Static Digest (GitHub Pages every 3h)
          └─ Neon Lakebase Postgres + FastAPI + Svelte 5 (Heroku interactive mode)

1. Resilient 3-Tier Ingestion

News portals vary wildly in feed reliability. Instead of trusting RSS alone, each portal runs through an isolated three-tier pipeline:

  1. Conditional RSS/Atom polling using ETag and If-Modified-Since headers to avoid redundant downloads.
  2. Declarative homepage_rank extraction (BeautifulSoup + lxml) to capture front-page prominence signals.
  3. Capped on-demand lead extraction via trafilatura when feed summaries are sparse.

2. Cross-Lingual Clustering & Deterministic Offline Fallback

Bangla and English articles covering the same event rarely share identical keywords. The clustering stage generates multilingual semantic embeddings via a model cascade (gemini-embedding-2 → gemini-embedding-001), while keeping an automatic --no-llm fallback powered by scikit-learn TF-IDF vectors and a curated Bangladeshi bilingual entity glossary. Even without an API key or network quota, clustering and ranking still complete cleanly.

3. Quota-Lean LLM Cascade & 1-RTT Postgres Queries

To stay resilient against free-tier rate limits, unchanged story clusters are skipped via cluster-hash caching, and rate-limited models enter model_cooldowns rather than wasting retries. Batches step through Gemini and Gemma fallback models automatically.

When running against remote Neon Postgres in interactive multi-user mode (with Managed Neon Auth JWKS verification), hot endpoints use psycopg3 connection pooling and single-round-trip SQL (COUNT(*) OVER(), json_agg, and RETURNING) so UI interactions avoid cascading database round-trips.

4. Svelte 5 Studio & XSS-Safe Annotation Export

The frontend renders instant EN | বাংলা switching, perspective coverage bars, and a BCS Editorial Studio covering 11 opinion feeds across 6 essay themes. Users can grade editorials against a 0–100 rubric, attach paragraph-anchored highlights, and export a formatted Markdown study notebook (bcs-essay-notebook.md), rendered through a tokenized Markdown parser without raw {@html} injection.

Trade-offs & Lessons Learned

  • Static scheduled mode vs. live interactive server: Supporting both a 3-hour GitHub Actions static digest on GitHub Pages and a live FastAPI + Postgres deployment on Heroku meant keeping pipeline output deterministic (digest.json) and separating read-only public views from authenticated studio mutations.
  • Deterministic scoring before LLM synthesis: Computing importance scores and editorial Blindspots mathematically before generating bilingual summaries keeps rankings inspectable and keeps the site useful even when --no-llm mode is active.