This project aggregates news articles from three different platforms (News API, Guardian API, and New York Times API) and exposes APIs to interact with the data.
Ensure you have the following installed:
- PHP 8.2^
- Composer
- Docker & Docker Compose
- Laravel
-
Copy the
.env.example
file to.env
:cp .env.example .env
-
Update the
.env
file if needed. API Keys are already configured for news fetching:NEWS_API_KEY="0736c8a60aa248c0ab4efe6d89534eef" GUARDIAN_API_KEY="aafbb65b-f798-48a3-9deb-e16aac1176f1" NYT_API_KEY="A1RG7AH2LaA1w1x5cqa1J9oGjax3V85G"
Run the following command to install PHP dependencies:
composer install
Run database migrations to create necessary tables:
php artisan migrate
-
Build and run the Docker containers:
docker-compose up -d
-
The application will be available at:
http://localhost
Swagger documentation is set up using the L5-Swagger package.
To generate Swagger documentation:
php artisan l5-swagger:generate
Once generated, access the Swagger UI at:
http://localhost/api/documentation
The application includes a command to fetch news articles from the APIs:
Run the following command:
php artisan app:fetch-articles
This command consumes APIs using the provided keys and stores the articles in the database.
-
Swagger Documentation: Located at:
swagger_news_aggregator
(converted Postman collection to Swagger format)
-
Postman Collection: Import the collection
news-aggregator.postman_collection
from the project root directory. -
APIs Location:
- All API routes are defined in
routes/api.php
.
- All API routes are defined in
-
Install Composer dependencies:
composer install
-
Copy
.env.example
to.env
:cp .env.example .env
-
Run migrations:
php artisan migrate
-
Start Docker environment:
docker-compose up -d
-
Generate Swagger docs:
php artisan l5-swagger:generate
-
Fetch articles (optional):
php artisan app:fetch-articles
- Docker: Simplifies environment setup and allows consistent development.
- Swagger: API documentation is automatically generated and available at
/api/documentation
. - Postman: Use the provided collection for testing APIs quickly.
For More information Contact me at: [email protected]! 🚀