Skip to content

fairsource-de/recipes-test-application

Repository files navigation

Recipe Manager

This application serves as a part of a coding challenge. It consists of two microservices:

  • recipe-service — A CRUD application for managing recipes (Quarkus + PostgreSQL)

  • price-calculator — A stateless service that calculates ingredient prices for a recipe

Prerequisites

  • Java 21+

  • Maven 3.9+

  • Docker

Quick Start

Option 1: Docker Compose

# Start all containers
docker compose up -d

Option 2: Shell Scripts

# Build both services
./local-build.sh

# Start PostgreSQL, price-calculator, and recipe-service
./local-run-env.sh

Recipe Service API

Method Path Description

GET

/api/recipes

List all recipes

GET

/api/recipes/{id}

Get a recipe by ID

POST

/api/recipes

Create a new recipe

PUT

/api/recipes/{id}

Update a recipe

DELETE

/api/recipes/{id}

Delete a recipe

GET

/api/recipes/{id}/price

Calculate price for a recipe (calls price-calculator)

Example: Create a Recipe

curl -X POST http://localhost:8080/api/recipes \
  -H 'Content-Type: application/json' \
  -d '{
    "title": "Scrambled Eggs",
    "description": "Simple breakfast",
    "difficulty": "EASY",
    "preparationTime": 10,
    "servings": 2,
    "ingredients": [
      {"name": "Eggs", "amount": 4, "unit": "PIECE"},
      {"name": "Butter", "amount": 10, "unit": "GRAM"},
      {"name": "Salt", "amount": 2, "unit": "GRAM"}
    ]
  }'

Price Calculator API

Method Path Description

POST

/api/prices/calculations

Calculate prices for a list of ingredients

Example: Calculate Prices

curl -X POST http://localhost:8082/api/prices/calculations \
  -H 'Content-Type: application/json' \
  -d '{
    "ingredients": [
      {"name": "Eggs", "amount": 4, "unit": "PIECE"},
      {"name": "Butter", "amount": 10, "unit": "GRAM"}
    ]
  }'

Architecture

+----------------+      REST       +------------------+
|                | --------------> |                  |
|  recipe-       |                 |  price-calculator |
|  service       | <-------------- |  (port 8082)      |
|  (port 8080)   |                 +------------------+
|                |
|                | ---- JDBC ----> PostgreSQL (port 5432)
+----------------+

Stopping the Application

# Docker Compose
docker compose down

# Shell Scripts
docker stop recipe-service price-calculator recipe-db

About

A Quarkus application for testing and demos

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors