πŸ“° News Automator β€” Real-Time News Aggregator (Python + Streamlit)
βš“

πŸ“° News Automator β€” Real-Time News Aggregator (Python + Streamlit)

Summary: A professional, real-time news application that fetches and filters headlines across categories and sources. Built to showcase modern Python web development, API integration, and clean UI/UX in a portfolio-ready app.

Stack: Python Β· Streamlit Β· NewsAPI Β· Requests Β· python-dotenv Β· pandas

🎯 What This App Does (at a glance)

  • Real-time news: Pulls the latest headlines by category.
  • Smart search: Query across all sources (e.g., β€œAI”, β€œinflation”).
  • Source explorer: Browse sources per category with descriptions and links.
  • Polished UI: Responsive layout with sidebar controls and custom styling.
  • Resilient: Graceful error handling (timeouts, missing keys, bad responses).
  • Tunable: Choose how many articles to display (e.g., 5–50).
image

🧩 Why I Built It

I wanted a compact project that demonstrates:

  • API integration end-to-end (auth, params, pagination guards, status handling).
  • Interactive UX with Streamlit (sidebar configs, dynamic results).
  • Clean code structure (separating UI from business logic).
  • Deployability (local + Streamlit Cloud / Docker options).

πŸ› οΈ Technologies

  • Python 3.8+
  • Streamlit for the interactive web app
  • NewsAPI for live data
  • Requests for HTTP calls
  • python-dotenv for environment variables
  • pandas for light transformation/formatting

πŸ“¦ Project Structure

Port/
β”œβ”€β”€ streamlit_news_app.py    # UI: Streamlit app (layout, controls, display)
β”œβ”€β”€ news_automator.py        # Logic: API calls, validation, error handling
β”œβ”€β”€ requirements.txt         # Dependencies
β”œβ”€β”€ .env                     # Environment variables (create this locally)
└── README.md                # Project documentation

βš™οΈ Setup (Local)

  1. Clone
git clone <your-repo-url>
cd Port
  1. Install deps
pip install -r requirements.txt
  1. Configure env
  2. Create a .env file in the project root:

API_KEY=your_news_api_key_here

Get a free API key from NewsAPI.org.

  1. Run
streamlit run streamlit_news_app.py

Then open http://localhost:8501

πŸš€ Usage

  • Browse by category: Business, Entertainment, General, Health, Science, Sports, Tech
  • β†’ Set number of results, click Fetch News.

  • Search: Enter keywords (β€œAI regulation”, β€œinterest rates”), fetch relevant articles.
  • View sources: Explore available sources per category with links and descriptions.

UI niceties

  • Responsive layout, sidebar configuration
  • Friendly error messages (API limits, network errors)
  • Portfolio panel (tech stack, links, instructions)

🧠 Core Functions (from news_automator.py)

  • get_articles_by_category(category, max_articles=20) β†’ top headlines for a category
  • get_articles_by_query(query, max_articles=20) β†’ search across sources
  • get_news_sources(category) β†’ list sources + metadata

Built-in validation & error handling (HTTP status checks, empty results, API key checks).

πŸ—οΈ Architecture & Design Choices

Separation of concerns

  • UI (Streamlit) in streamlit_news_app.py
  • Business logic (API calls, parsing) in news_automator.py

Reliability

  • Try/except wrappers around API calls
  • Clear user messages for rate limits / invalid keys / no results
  • Configurable page size to avoid API overload

UX

  • Minimal clicks to value (category β†’ fetch β†’ read)
  • Clean card-style article blocks with title, description, source, link
  • Consistent typography and spacing for readability

πŸ” Secrets & Config

  • API key stored in .env via python-dotenv
  • Never hard-code keys; ignore .env in version control
  • Ready for Streamlit Cloud secrets if deploying there

🌐 Deployment Options

  • Local: streamlit run streamlit_news_app.py
  • Streamlit Cloud: Push to GitHub β†’ set API_KEY as a secret β†’ deploy
  • Docker (optional): Containerise for portability
  • Heroku / AWS / GCP / Azure: As a simple Python web service

βœ… What I Learned

  • Designing a small but solid app that’s easy to read and extend
  • Handling the realities of rate limits / timeouts / empty payloads
  • Creating a professional UI quickly with Streamlit
  • Packaging portfolio projects with clear docs and clean structure

πŸ”­ Roadmap / Improvements

  • Saved Searches & Bookmarks: Persist favourite topics
  • Multi-API fallback: If NewsAPI rate-limits, degrade gracefully
  • Scheduling & Caching: Faster reloads + fewer API calls
  • Topic modeling: Cluster related news (NLP)
  • Email/Slack digests: Daily/weekly summaries for selected topics
  • Dark mode toggle and theme presets

πŸ”— Links

🧾 SEO (for this page)

  • Title: News Automator β€” Real-Time News Aggregator (Python + Streamlit)
  • Meta Description: A portfolio project by Teslim Adeyanju: real-time news app built with Python, Streamlit, and NewsAPI β€” featuring smart search, source browser, and a clean responsive UI.

πŸ“Œ Badge (optional Notion block)

Status: Live β€’ Tech: Python, Streamlit, NewsAPI β€’ Focus: API integration, UI/UX, Error handling

Β© Teslim Adeyanju 2025. All Rights Reserved.