A Simple Tech News Aggregator with RSS, FastAPI and React

Pick a topic and a time period, and get the latest articles from several RSS feeds in one list.
Hackathon
Software Engineering
Author
Published

November 23, 2024

I follow a handful of blogs and newsletters across different topics, and checking each one separately got tedious. So at a weekend hackathon run by FSHM, I built a small aggregator: pick a topic and a time period, and it pulls the articles from every feed for that topic into one list, newest first.

Code: Zilch123/Tech-News-Aggregator

Why RSS

Most blogs and newsletters still publish an RSS feed, which means no scraping, no API keys and no rate limits. A feed is just an XML file with the latest posts, and feedparser turns it into Python objects.

The feeds

Topics and their feeds live in a YAML file, so adding a source doesn’t need a code change:

feeds:
  "datascience":
    - name: "KDNuggets"
      url: "https://www.kdnuggets.com/feed"
    - name: "Analytics Vidhya"
      url: "https://www.analyticsvidhya.com/feed/"

  "Generative AI":
    - name: "Hugging Face Blog"
      url: "https://huggingface.co/blog/feed.xml"

The repo also has feeds for front end, back end, operating systems, OpenStreetMap and mathematics.

The backend

The backend is a FastAPI app with one endpoint:

@app.get("/fetch_articles/")
async def fetch_articles_api(
    topic: str = Query(..., description="Specify a topic"),
    time_period: str = Query(..., description="Specify a time period"),
):
    articles = fetch_articles(topic, time_period)
    return {"topic": topic, "time_period": time_period, "articles": articles}

For a request, it:

  1. Looks up the feeds for the topic.
  2. Fetches them in parallel with a thread pool, since most of the time is spent waiting on the network.
  3. Parses each entry’s date with dateutil, which handles the different date formats feeds use.
  4. Drops anything older than the chosen period (last week, month, year, 3 years, 5 years or all time).
  5. Sorts what’s left, newest first.
with ThreadPoolExecutor(max_workers=5) as executor:
    article_lists = list(executor.map(self._fetch_feed, feeds))
    for articles in article_lists:
        all_articles.extend(articles)

Each article comes back with a title, summary, link and timestamp.

The frontend

The frontend is React with Vite and Tailwind. It has two dropdowns (topic and time period) and a search button. Results show as cards with the title, summary, publish date and a link to the original article.

Running it

Everything runs with Docker Compose. From the project folder:

docker compose up

The frontend runs at localhost:5173 and the API at localhost:8000.

To run without Docker, start the backend first (cd backend && bash run.sh), then the frontend (cd frontend && npm run dev).

Adding a topic

Add the topic and its feed URLs to rss_feeds.yaml, then add the topic name to the TOPICS list in App.jsx so it shows up in the dropdown.