This challenge has been developed entirely by Mario Calín Sánchez.
The code challenge has been developed using the technologies:
- Ubuntu 22.04
- Java JDK 21
- Apache Maven 3.9.6
I have set some assumptions about the business rules that I consider relevant:
- The transaction reference is a string in form of UUID. This has made really simple the generation of unique identifiers. I am aware that they may not be efficient in production ready databases.
- The feature definition of the check transaction status endpoint features have slightly changed. I find setting the transaction date before
calling the
system more understandable, therefore the
Andstep concerning the transaction date has been moved fromWhentoGiven. - In the check transaction status endpoint it is not mandatory to set the
channelparameter. In that case, the default value is been given toINTERNALin the query.
For developing the application, the following technologies have been used:
- Springboot 3.2 as web framework.
- H2 In memory database as persistence
Every maven command in this section must be used in the project's root folder.
For building the app the following maven command can be used:
mvn install -DskipTestsUnit tests for CreateTransactionCommand and SearchTransactionsQuery have been created as an example.
To run only unit tests use the following maven command:
mvn testAn integration test for SQLTransactionRepository with H2 database has been created.
Two ways of creating acceptance test have been followed:
- Acceptance test with only JUnit (create transaction and search transaction endpoints)
- Cucumber with gherkin language (check endpoint status)
To run both integration and acceptance tests the following maven command can be used:
mvn verifyTo run the application just run the following maven command inside the project's root folder. It will run the app in
the url http://localhost:8080.
mvn spring-boot:runA simple GitHub action has been added to verify that the build is passing. It is located in the .github/workflows/build.yml and it consist
of steps for building and testing the application. GitHub also provides a cool green "tick" in the repo page if the build is passing.
See an example of an action passing (the full description migght not be available)
In this section I explain some features that the application provides.
Flyway has been used in order to illustrate database migrations. Currently, there is only a table creation script, and it is executed if the database is not in the last version automatically.
Thanks to the open api plugin a file called openapi.yml is created for defining the api contract. Currently, the file is placed in the
target folder after running the integration testing phase.
I have followed architectural and testing concepts: Test driven design, Acceptance test driven design, Domain driven design, hexagonal architecture and a form of CQRS with a simple command-query bus implementation.
Conventional commits have been as can be checked in the commits history.
Some api usage examples are provided in this section. They are based on curl tool and they are ready to be used in an unix shell.
Moreover, with the application running you are able to see the api specification accessing the
link http://localhost:8080/swagger-ui/index.html#/.
Create a transaction with all parameters
curl -i -X POST http://localhost:8080/v1/transaction/create \
-H 'Content-Type: application/json' \
-d '{ "reference":"a005c77c-88e0-4436-bd6e-1867047739c1", "account_iban":"ES9820385778983000760236", "date":"2019-07-16T16:55:42.000Z", "amount":193.38, "fee":3.18, "description":"Restaurant payment"}' Create a transaction with no reference
curl -i -X POST http://localhost:8080/v1/transaction/create \
-H 'Content-Type: application/json' \
-d '{ "account_iban":"ES9820385778983000760236", "date":"2019-07-16T16:55:42.000Z", "amount":193.38, "fee":3.18, "description":"Restaurant payment"}' Create a transaction with no iban results in bad request
curl -i -X POST http://localhost:8080/v1/transaction/create \
-H 'Content-Type: application/json' \
-d '{ "reference":"a005c77c-88e0-4436-bd6e-1867047739c1", "date":"2019-07-16T16:55:42.000Z", "amount":193.38, "fee":3.18, "description":"Restaurant payment"}' Some transaction have been loaded for testing purposes. Those transaction are created for ES0204877966878429941794 IBAN. Use the examples
below.
Search transactions for iban.
curl -i -X GET http://localhost:8080/v1/transaction/search?account_iban=ES0204877966878429941794Search transactions for iban ordered by amount.
curl -i -X GET http://localhost:8080/v1/transaction/search?account_iban=ES0204877966878429941794&orderByAmount=ascSome transaction have been loaded for testing purposes. Use the examples below.
Check transaction status
curl -i -X POST http://localhost:8080/v1/transaction/status \
-H 'Content-Type: application/json' \
-d '{ "reference":"462789e2-d01f-4bcd-96bc-d391050648e9", "channel":"INTERNAL"}'curl -i -X POST http://localhost:8080/v1/transaction/status \
-H 'Content-Type: application/json' \
-d '{ "reference":"462789e2-d01f-4bcd-96bc-d391050648e9"}'curl -i -X POST http://localhost:8080/v1/transaction/status \
-H 'Content-Type: application/json' \
-d '{ "reference":"6b732680-330e-4e35-a9f6-14699784adcd", "channel":"ATM"}'curl -i -X POST http://localhost:8080/v1/transaction/status \
-H 'Content-Type: application/json' \
-d '{ "reference":"89cb0aa2-1569-4aea-ae0a-6e2560a17bdd", "channel":"CLIENT"}'- Asynchronous communication and event driven architectures are really common in microservices. It might be advisable to add domain events
such as
TransactionCreated. - In order to make this services a containerized application, a
Dockerfilemight be added in order to provide a cloud-ready docker image. - Enrich openapi specification with endpoint information, documentation, requests and responses.