The repository consists on a proposed solution to a technical challenge raised during the selection process for a Backend Developer position.
This is a Symfony project for an API service, with a development environment configured in Docker.
- Clone this repo:
git clone [email protected]:jgarciatorralba/translator-microservice-challenge.git
- Navigate to the
/.docker
folder, then rundocker compose up -d
to download images and set up containers.- Important: the configuration is prepared to expose the server container's port on host's port 8000, the database container's port on host's 6432, and the message broker container's port on hosts' 5672 and 15672, so make sure they are available before running the above command.
- Once completed, open with VisualStudio and in the command palette ("View > Command Palette") select the option "Dev Containers: Reopen in Container".
- Inside the development container, install packages with
composer install
. - Even though an empty database named app_db should have been created with the installation, you can still run
sf doctrine:database:create
for good measure. - With the database created and the connection to the app successfully established, execute the existing migrations in folder
/etc/migrations
using the commandsf doctrine:migrations:migrate
.
- Run the test suite by executing the command:
php bin/phpunit
- Important: make sure to clear Symfony's testing cache by running
sf cache:clear --env=test
before executing them. - Create the test database by running the command
sf doctrine:database:create --env=test
and execute the corresponding migration withsf doctrine:migrations:migrate --env=test
.
- Important: make sure to clear Symfony's testing cache by running
- Run PHPUnit tests:
php bin/phpunit
- Run CodeSniffer analysis:
php ./vendor/bin/phpcs <filename|foldername>
- Correct detected coding standard violations:
php ./vendor/bin/phpcbf <filename|foldername>
- Correct detected coding standard violations:
- Run PHPStan analysis:
php ./vendor/bin/phpstan analyse <foldernames>
- Delete existing database:
sf doctrine:database:drop --force
- Run worker to consume messages queued in the message broker:
sf messenger:consume async -vv
- To facilitate development, support is limited to only a handful of languages: English, Spanish, French, German, Italian and Portuguese.
- A maximum of 255 characters is allowed for each translation request to prevent reaching the free tier limit too quickly.
- Universally Unique Identifiers (UUIDs) are used to enhance API security.
- Enumerations are employed for translation status and supported languages instead of plain text to better control database input.
- Jorge García Torralba → jorge-garcia
- Feel free to open a pull request with suggestions or improvements!