This project provide a web application to list and details movies form TMDb.
This implementation rely on the docker
and docker-compose
binaries.
Make sure that you have already installed this dependencies before execute the described commands of this file:
The project defines a very simple initial architecture (it will change for a more robust one in future implementations). It will requests informations from the TMDb API and cache the response into a local cache storage. Every time the same information was be requested it will return the response from the cache storage (by default store for a day).
This implementation was made using PHP, exclusively relying on standards suggested by the PHP-Fig also known as PSRs. In that way any dependency used to provide implementations of PSRs can be replaced anytime, anywhere in the code.
All classes implemented here was made using the principle of dependency injection and inversion of control (using the PSR-11), so any implementation can be easily intercepted or replaced via container dependency injection.
- PSR-11 Container are being provided by Zend ServiceManger defined into
config/container.php
file. - The
ConfigProvider
pattern suggested by the Zend Framework was applied for merging configs through Zend Config Aggregator defined intoconfig/config.php
file. - The HTTP RequestHandler layer are also being provided by a Zend implementation library.
- HTTP Request Client are being provided through Symfony HTTP Client Component.
- The cache layer are beeing provided through PSR-16 via Filesystem Adapter of PHP-Cache implementation.
- Log are being managed by Monolog through my very own Monolog Factories library.
- For rendering templates the PHP League Plates was used.
Follow the steps described below:
- Copy the
.env.example
to a.env
file; - Add the TMDb API Key into
TMDB_API_KEY
of yours.env
file; - Run in a terminal, inside application path directory:
$ docker-compose -f docker-compose.yml up --build -d webapp
- Open your browser into http://localhost;
For development mode, use the steps described below:
- Copy the
.env.example
to a.env
file; - Add the TMDb API Key into
TMDB_API_KEY
of yours.env
file; - Set
CONFIG_CACHE_ENABLED
of yours.env
file to0
; - Run in a terminal, inside application path directory:
$ docker-compose run --rm composer install $ docker-compose up -d webapp
- Open your browser into http://localhost;
Monitoring the logs are as simple as run the following command:
$ docker-compose logs -f webapp
This project provide phpunit test cases that can be run with the following command:
$ docker-compose run --rm phpunit
- Change to use Redis as a cache provider;
- Add a local database store, to avoid ask every time for information to TMDb API, and also act as a fallback in fail situations;
- Schedule async updates of upcoming movies, making the frontend only consume the local store database;
- Decouple the frontend from application code. To do so it would be needed first:
- Change endpoints to API with JSON response bodies;
- Add some authorization logic (such as OAuth2);
- Isolate frontend that will only interact with the backend via async requests (could be also separated into another repository);
- Isolate TMDb API communication logic into a separate composer library;