Table of Contents
Build a publicly accessible service designed to stream an audio MP3 file to users upon accessing a specific URL corresponding to the desired audio episode. Certain episodes may be set as private, requiring authentication for streaming, which can be achieved either through header authentication or via a signed URL.
Before running this project, ensure that you have the following installed:
- PHP (minimum version: 8.1.0)
- Composer (minimum version: 2.0.0)
- Node.js (minimum version: 14.0.0)
- NPM (minimum version: 6.0.0)
- MySQL (minimum version: 8.0.0)
Clone the repository to your local machine:
git clone https://github.com/Ahmad-Chebbo/media-streaming-microservice.git
Install the PHP dependencies:
composer install
Copy the .env.example file to a new file called .env:
cp .env.example .env
Generate an application key:
php artisan key:generate
Update the .env file with your database credentials.
php artisan migrate
To run the tests, run the following command
Note the test will refresh the database records
php artisan test
php artisan db:seed
To start the development server, run the following command:
php artisan serve
Then visit http://localhost:8000 to view the application.
Some functionalities such as logging analytics require running the queue, but don't forget to run the Analytics service and change the ANALYTIC_SERVICE_MICROSERVICE_URL parameter in the .env file to match the analytics service URL.
php artisan queue:work
The repository contains a DockerFile that can be used in the following commands:
docker build -t streaming-microservice .
followed by the following commands:
docker run -d -p 9000:9000 --name streaming-container streaming-microservice
During the development process of this project, I created additional backend functionalities such as:
- Storing Episode: I created a code that downloadn& store the mp3 file from the given url to the local storage or save an mp3 file in case of having a file instead of an mp3 url in the given request.
- Streaming Episode: I created a controller method called streamEpisodeFromTheStorage that can be used in case of storing the episode in the local storage (like the previous point).
Although these functionalities are not used in the current version, you are welcome to review the code.