Event driven pseudo-verification system with public and private facing REST(-ish) API.
Technologies used in the project:
PHP 8.1
Symfony ^6.0.*
MySQL 8.0
Nginx
RabbitMQ
As well as:
Mailhog
- for emails verifications
Gotify
- for sms verifications
Prerequisites: you will need Docker & Docker-compose in order to set up the project.
- Checkout code from git -
git clone https://github.com/pavel-vasiluk/verification-system.git
- Spin-up docker containers by running
docker-compose up
- Then proceed to
php
container in order to continue project setup -docker exec -it --user root php /bin/bash
- Run
composer install
in order to install project dependencies - Afterwards run
bin/console doctrine:migrations:migrate
to execute all project db migrations (for test-database use additional-e test
option) - Make sure everything is up - project should start being available at http://localhost:8000
- In order to test SMS notifications additional steps need to be completed:
- Proceed to http://localhost:8080 (Gotify UI), login if needed
- Press APPS -> Create application-> provide any name / description you want, and press Create
- Copy your created application token value and proceed to project
.env
file (or create local override.env.local
) - Add Gotify token parameter, e.g.
GOTIFY_APP_TOKEN=AEZ.CAEd79GiR40
- In order to start consuming notification messages, following console command should be running on the background -
bin/console messenger:consume
Create new verification via public REST endpoint request. Examples:
POST http://localhost:8000/verifications
- creating email verification
{
"subject": {
"identity": "[email protected]",
"type": "email_confirmation"
}
}
POST http://localhost:8000/verifications
- creating mobile verification
{
"subject": {
"identity": "+37120000001",
"type": "mobile_confirmation"
}
}
Expected response example:
{
"id": "4e1daba5-0470-41fe-966a-9372aa428304"
}
Afterwards, notification should be sent to your email or sms client (Mailhog / Gotify).
Copy id
from response, as well as code
from your email or sms.
Prepare verification confirmation request:
PUT http://localhost:8000/verifications/4e1daba5-0470-41fe-966a-9372aa428304/confirm
{
"code": "10539088"
}
Expected response: 204 (no content)
System services specifications:
Template service Verification service Notification service
Project has its code style rules defined by php-cs-fixer
dev-dependency.
In order to test your code suggestion against it, run vendor/bin/php-cs-fixer fix
To access any of the project servers (e.g. MySQL, RMQ, etc), review credentials provided in docker-compose.yml
Project has both unit and functional tests (phpunit).
Tests can be executed by bin/phpunit
*
- Note! test environment also requires valid Gotify app token as .env variable.
- You can add it to the local-test .env override file
.env.test.local
, e.g.GOTIFY_APP_TOKEN=AEZ.CAEd79GiR40