Skip to content

ishaquehassan/news-aggregator-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

News Aggregator API

A robust Laravel-based API that aggregates news from multiple sources into a unified endpoint. The system fetches, normalizes, and serves news articles from various providers while handling rate limiting, caching, and data consistency.

🌟 Features

📝 API Documentation

Complete API documentation is available on Postman: API Documentation

🗂️ Project Structure

app/
├── Console
│   └── Commands              # Custom Artisan commands
├── Contracts
│   ├── Articles             # Article-related interfaces
│   ├── Auth                 # Authentication interfaces
│   └── UserPreferences     # User preferences interfaces
├── Helpers                  # Helper functions
├── Http
│   ├── Controllers
│   │   ├── API
│   │   │   ├── Articles
│   │   │   ├── Auth
│   │   │   └── UserPreferences
│   │   └── Auth
│   ├── Requests
│   │   └── UserPreferences
│   └── Resources
├── Jobs
│   └── News                # News fetching jobs
├── Models                  # Eloquent models
├── Providers              # Service providers
└── Services
    └── Implementations
        ├── Articles        # News service implementations
        ├── Auth           # Authentication services
        └── UserPreferences # User preferences services

🚀 Quick Setup

Prerequisites

  • Docker Desktop
  • Git
  • Composer (for local development)

Installation

  1. Clone the repository
git clone <repository-url>
cd news-aggregator
  1. Run the setup script
chmod +x setup.sh
./setup.sh

The setup script will:

  • Configure the environment
  • Start Docker containers
  • Install dependencies
  • Run migrations
  • Generate application key
  • Set up the scheduler
  • Fetch initial articles

Manual Setup

If you prefer manual setup:

  1. Copy environment file
cp .env.example .env
  1. Start Docker containers
docker compose up -d
  1. Install dependencies
docker compose exec app composer install
  1. Generate application key
docker compose exec app php artisan key:generate
  1. Run migrations
docker compose exec app php artisan migrate
  1. Create storage link
docker compose exec app php artisan storage:link

🔧 Configuration

The application uses the following ports:

  • API: http://localhost:8000
  • MySQL: localhost:3306

Default database configuration:

  • Database: news_aggregator_api
  • Username: root
  • Password: none

📋 Available Commands

Fetch articles from news services:

# Show options to fetch from
docker compose exec app php artisan articles:fetch

# Fetch from all services
docker compose exec app php artisan articles:fetch --all

# Fetch from specific service
docker compose exec app php artisan articles:fetch newsapi.org

Run tests:

docker compose exec app php artisan test

View logs:

docker compose logs -f
docker compose logs -f scheduler

🔒 Security

  • Rate limiting is implemented for all API endpoints
  • Request validation and sanitization
  • Error handling and logging
  • API authentication ready (if needed)

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

📜 License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

news-aggregator-api With Laravel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published