Skip to content

sunzid02/news-aggregator

Repository files navigation

News Aggregator – Laravel + React Dashboard

News Aggregator is a modern, full-stack application designed to collect, manage, and display news articles from multiple external APIs.

Built on a robust Laravel 12 backend and a dynamic React frontend using Inertia.js, it adheres to software best practices (DRY, KISS, and SOLID) to ensure scalability and maintainability.


Project Overview

This project is primarily backend-focused, utilizing Laravel to fetch live news data from sources like NewsAPI, The Guardian, and The New York Times. The system normalizes this disparate data, prevents duplicates, stores it in a local database, and provides clean RESTful endpoints for searching, filtering, and managing user preferences. And display on the Frontend in a Dashboard.


Features

  • Fetch & Store Articles: Collect and store live news articles from multiple sources into a unified local database.
  • Data Unification: Implement a unified data structure and duplicate prevention logic during the import process.
  • Advanced Searching: Search and filter articles by keyword, category, author, or date via powerful API endpoints.
  • Automation: Automated data refreshing via Laravel Scheduler and Queue workers.
  • API Endpoints: Clean, efficient RESTful API endpoints for frontend integration or third-party use.
  • Modern UI: Clean, SPA-like frontend built using Inertia.js + React + Vite.

Technology Stack 🛠️

Backend 💻

Technology Description
Laravel 12 (PHP 8.2+) Core backend framework for routing, database management, and API integration.
MySQL / PostgreSQL Relational database systems for article storage and user data.
Redis Optional cache and queue system for background jobs and scheduled tasks.
GuzzleHTTP PHP HTTP client for reliable external API data fetching.
Artisan Console Laravel’s CLI used for task scheduling and custom commands.

Frontend ✨

Technology Description
React (via Inertia.js) SPA-like frontend integrated directly with Laravel routes.
Vite Fast development server, build tool, and hot module replacement.
TailwindCSS Utility-first CSS framework for modern, responsive UI styling.
Axios For making asynchronous AJAX requests to the Laravel backend.

APIs Used 🌐

API Name Description Documentation
NewsAPI.org Provides global headlines and trending news. NewsAPI Documentation
The Guardian API UK-based curated news and editorial data. The Guardian API Docs
New York Times API Top international news and categorized articles. NYTimes API Docs

Getting Started

Prerequisites

Ensure the following are installed and accessible on your system:

  • PHP 8.2+
  • Composer
  • Node.js & npm
  • MySQL or PostgreSQL

Installation and Setup

  1. Clone the repository

    git clone [https://github.com/](https://github.com/)<your-username>/news-aggregator.git
    cd news-aggregator
  2. Install dependencies

    composer install
    npm install
  3. Set up environment

    cp .env.example .env
    php artisan key:generate

    Then, configure your .env file with database credentials and API keys:

    APP_NAME="NewsAg"
    APP_ENV=local
    APP_URL=http://localhost
    
    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=news_aggregator
    DB_USERNAME=root
    DB_PASSWORD=
    
    NEWSAPI_KEY=your_newsapi_key
    GUARDIAN_KEY=your_guardian_key
    NYT_KEY=your_nyt_key
  4. Run migrations and seeders

    php artisan migrate --seed
  5. Start the development servers

    # Start the Laravel backend server
    php artisan serve
    
    # Start the Vite frontend development server
    npm run dev

    Now open your browser to http://127.0.0.1:8000


Usage Example: Synchronizing Recent News

The news:sync command can be used to synchronize news data within a specific time window, running immediately and respecting the defined parameters.

# Synchronize news articles published within the last 24 hours
php artisan news:sync --hours=24 --now

# Add a sync job to the queue (processed by queue:work)
php artisan news:sync --hours=24

#Make sure your queue worker is running in another terminal or supervisor process:
php artisan queue:work

Usage

After the development server is running

Navigate to http://localhost:8000 in your browser to use the NewsAggregator App.

Demo Screenshot

News Aggregator Demo News Aggregator Demo

Demo Video

Watch the demo video

About

share world recent news...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published