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.
- Aggregates news from multiple providers:
- Automated article fetching via scheduler
- Rate limiting and caching
- Unified response format
- Category-based filtering
- Search functionality
- Docker containerization
Complete API documentation is available on Postman: API Documentation
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
- Docker Desktop
- Git
- Composer (for local development)
- Clone the repository
git clone <repository-url>
cd news-aggregator
- 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
If you prefer manual setup:
- Copy environment file
cp .env.example .env
- Start Docker containers
docker compose up -d
- Install dependencies
docker compose exec app composer install
- Generate application key
docker compose exec app php artisan key:generate
- Run migrations
docker compose exec app php artisan migrate
- Create storage link
docker compose exec app php artisan storage:link
The application uses the following ports:
- API:
http://localhost:8000
- MySQL:
localhost:3306
Default database configuration:
- Database:
news_aggregator_api
- Username:
root
- Password: none
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
- Rate limiting is implemented for all API endpoints
- Request validation and sanitization
- Error handling and logging
- API authentication ready (if needed)
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE.md file for details.