To set up this project using Docker, follow these steps:
-
Ensure Docker is installed on your machine. You can download it from Docker's official website.
-
Clone the repository to your local machine:
git clone <repository-url> cd <repository-directory>
-
Build the Docker images using the provided Dockerfile:
docker compose build
-
Start the services defined in the
docker-compose.ymlfile:docker compose up
-
Access the application at
http://localhost:<port>(replace<port>with the port specified in yourdocker-compose.ymlfile and create an environment variableHTTP_PUBLISH_PORTin your.envfile). -
Stop the services when you're done:
docker compose down
-
Go inside container
docker exec -it <container_id> bash- Run the following commands to install dependencies, run tests, migrations and seeders
composer install
composer dump-autoloadphp artisan migratephp artisan db:seedphp artisan test./vendor/bin/phpstan analysephp artisan l5-swagger:generateTo run the console commands, you need to go inside the container and run the following commands:
- Run
php artisan queue:workto run the default queue - Run
php artisan download:articlesto fetch the articles from the 3rd party API and store in the database
The scheduled command is defined in the routes/console.php file.
To run the scheduled commands, you need to go inside the container and run the following commands:
php artisan queue:work
php artisan schedule:workI have configured the scheduled commands to run everyday at 1:00 AM to download the articles from the 3rd party API and store in the database.
I have deployed the project on AWS lightsail instance and the swagger documentation is available at http://13.55.9.197:8090/api/documentation.
- API Documentation with Swagger
- Scheduler to download the articles from the 3rd party API
- Queue to process and store the articles
- API Rate Limiter
- Caching using Redis
- Feature and Unit Testing
- Authentication with Sanctum
- Error Handling
- Laravel Pint to indent the code
- PHPStan to check the code quality
- Dockerizing the application
- 3rd Party News API Sources implemented - NewsAPI, The New York Times, The Guardian