This project includes a POSTMAN 2.1 collection with the requests
Click here to download the file
This project is a CRUD application built using Symfony and follows Domain-Driven Design (DDD) principles. It models key elements from The Lord of the Rings universe, including characters, factions and equipment. The application is Dockerized and supports both OpenAPI and AsyncAPI specifications for documentation.
Follow the steps below to set up the project:
-
Clone the repository:
git clone https://github.com/ivanmunozruiz/api-coding-task.git cd api-coding-task -
Build and start the Docker containers:
make build
-
Install dependencies using Composer:
make composer-install
-
Run database migrations:
make up
To start the application, use the following command:
make upThis will start all the Docker containers in the background and apply the necessary database migrations.
To stop the containers:
make stopThe project also includes RabbitMQ as queue manager for asynchronous events. To see rabbitmq management panel, visit RabbitMQ Management Panel (With the Docker containers running).
user: guest
password: guest- Consume Async events:
make consume-async-events
Below is a list of available commands in the Makefile. You can use make <command> to run them:
| Command | Description |
|---|---|
make build |
Build the Docker containers and install dependencies |
make composer-install |
Install PHP dependencies via Composer |
make composer-update |
Update Composer dependencies |
make enter-container-php |
Enter the PHP container |
make asyncapi-resolve |
Generate AsyncAPI documentation |
make openapi-resolve |
Generate OpenAPI documentation |
make php-lint |
Run PHP code linter |
make phpstan |
Run PHPStan static analysis |
make rector |
Apply code improvements using Rector |
make unit-test |
Run unit tests |
make mutant-test |
Run mutant tests |
make bdd-test |
Run Behat BDD tests |
make functional-test |
Run Functional tests |
make up |
Start the Docker containers |
make stop |
Stop the Docker containers |
make consume-async-events |
Start Consumer async events exchange consumer |
For a full list of commands, run make help.
OpenAPI Documentation Swagger UI (Click here)
The project includes a fully documented API using OpenAPI. To generate or validate the OpenAPI spec:
- Generate OpenAPI spec:
make openapi-resolve
- Validate OpenAPI spec:
make openapi-lint
The documentation can be found in the gen/openapi.yaml file.
To see the documentation you can visit Swagger Editor (With the Docker containers running).
The project also includes AsyncAPI documentation for asynchronous message-based interactions:
- Generate AsyncAPI spec:
make asyncapi-resolve
- Validate AsyncAPI spec:
make asyncapi-lint
The generated AsyncAPI documentation is located in gen/asyncapi.yaml. if you want to visualize it, copy yml content and paste it in AsyncAPI Playground.
Click here to download the file
We use several tools to ensure code quality and reliability:
-
Unit Testing: Execute unit tests with PHPUnit:
make unit-test
-
Mutation Testing: Run mutation tests with Infection:
make mutant-test
-
Behavior-Driven Development (BDD): Execute BDD tests with Behat:
make bdd-test
-
Static Code Analysis: Check code quality with PHPStan:
make phpstan
-
Automatic Code Fixes: Run Rector to refactor code automatically:
make rector
Contributions are welcome! Please fork this repository and submit a pull request with your changes. Ensure that all tests pass and code follows the PSR standards.
This project is licensed under the MIT License.
