Skip to content

ivanmunozruiz/api-coding-task

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LOTR CRUD Project - Api coding task

LOTR Ring
**A comprehensive CRUD application based on The Lord of the Rings universe, developed using Symfony and Domain-Driven Design (DDD). The project incorporates API documentation with AsyncAPI and OpenAPI, testing tools, and Dockerized environments.**

This project includes a POSTMAN 2.1 collection with the requests

Click here to download the file

Table of Contents


Project Overview

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.


Installation

Follow the steps below to set up the project:

  1. Clone the repository:

    git clone https://github.com/ivanmunozruiz/api-coding-task.git
    cd api-coding-task
  2. Build and start the Docker containers:

    make build
  3. Install dependencies using Composer:

    make composer-install
  4. Run database migrations:

    make up

Usage

Docker Setup

To start the application, use the following command:

make up

This will start all the Docker containers in the background and apply the necessary database migrations.

To stop the containers:

make stop

Async Events

RabbitMQ Management Panel

The 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

Available Makefile Commands

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.


Documentation

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).

AsyncAPI Documentation

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


Testing & Code Quality

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

Contributing

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.


License

This project is licensed under the MIT License.

About

This is the technical test project for API oriented backends

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 88.0%
  • HTML 5.2%
  • Makefile 2.3%
  • Gherkin 2.0%
  • Shell 0.8%
  • CSS 0.8%
  • Other 0.9%