Skip to content

carolusquintus/receipt-processor

Repository files navigation

Receipt Processor Challenge

This is receipt-proccess challenge developed by Carlos Rosas for Fetch Backend Engineer position.

Challenge was developed using:

  • Java 17
  • Gradle
  • Micronaut
  • Redis
  • Docker

And designed with Hexagonal Architecture and Domain Driven Design.

Setup local environment

The only assume is that the reviewer has UNIX like OS workstation and Docker.

Open your Terminal and follow next steps.

  1. Download SDKMan.
curl -s "https://get.sdkman.io" | bash

SDKMan install

  1. Install java jdk 17.
sdk install java 17.0.8-zulu

jdk install

  1. Install Gradle.
sdk install gradle 7.6.1

jdk install

Previous steps are not strictly necessary, because this project uses gradle wrapper.

But there's no reason to take risks 😃

  1. Clone or paste project in your preferred location.
git clone https://github.com/carolusquintus/receipt-processor.git

clone repo

  1. Move to project.
cd receipt-processor

move to project

Build

Now that your located in the project, there are some small tweaks in order to build it properly.

  1. Print your current working directory and copy it.
pwd

print

  1. Open .env file located at root project, with your favorite text editor. .env file

  2. Replace PROJECT_DIR var env with path copied from Build -> Step 1. PROJECT_DIR

  3. Replace DOCKER_USERvar env with your personal or business Docker Hub user. DOCKER_USER

  4. Build receipt-processor project.

gradle build

Or

./gradlew build

gradle gradlew

  1. Build and run docker-compose.yml
docker-compose up -d

docker-compose

  1. Validate that services are up & running.
docker-compose top

docker-compose

Test

Next steps are for Postman configuration.

  1. Import api.yml provided by receipt-processor-challenge
https://raw.githubusercontent.com/fetch-rewards/receipt-processor-challenge/main/api.yml

postman import api imported

  1. Once imported, double click on Receipt Processor collection and go to collection variables tab
    and substitute baseUrl Current value with http://localhost:8080 baseUrl

  2. Open POST Submits a receipt for processing request and go to Tests tab.
    Insert this snippet in order to set receiptId as a collection variable after each request.

var jsonData = pm.response.json();
pm.collectionVariables.set("receiptId", jsonData.id);

receiptId

  1. Open GET Returns the points awarded for the recipt request and go to Params tab.
    Substitute id Path variable with previous {{receiptId}} Get calculation receiptId

  2. Go back to POST Submits a receipt for processing request and copy a json body provided by the challenge
    from README.md or receipt-processor-challenge/examples
    Send a request and you will see the UUID response, which will be saved in {{receipId}} collections variable. 1 POST /receipts/process

  3. Go to GET Returns the points awarded for the recipt request and you will see that current request provides previous UUID saved.
    and also the proper receipt points calculation. 1 GET /receipts/{id}/points

  4. Example: 2 POST /receipts/process 2 GET /receipts/{id}/points

Unit testing & code coverage (WIP)

This project uses JaCoCo(Java Code Coverage) plugin to generate html test reports.

  1. Run and generate test reports.
./gradlew test

gradlew test

  1. Go to and locate index.html files and open them in your browser.

    1. (WIP) For Test Summary report go to.
    receipt-processor/build/reports/tests/test/index.html

    test-summary index.html test-summary index.html opened

    1. (WIP) For JaCoCo report go to.
    receipt-processor/build/reports/jacoco/test/html/index.html

    jacoco index.html jacoco index.html opened

About

Receipt Processor Challenge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published