Cafe design
Architecture
The SchildCafé consists of the following components
Coffee machine(s) – takes and returns jobs, pretends to be busy in between
Servitør – takes and stores client orders and returns finished orders
Barista – cron job dispatches and retrieves the jobs in the orders
and a MySQL database.
The components of the SchildCafé.
Design principles
The design is to be based on Twelve-Factor App approach.
Microservices in Docker containers
Communication via APIs
Configuration from environment variables
Logging in JSON to STDOUT/STDERR
/healthcheckenpoint/metricsendpoint for PrometheusX-Request-IDfor all API calls
Data exchange
For the two APIs mentioned in the diagram, the data requests are
Oder submission at Servitør
POST to /submit-order with JSON payload:
{
"coffees" : [
{ "product": "COFFEE", "count": 2 },
{ "product": "KAKAO", "count": 5 },
{ "product": "TEA", "count": 4 }
]
}
and reply is a single UUID string 878a4ba5-f03b-4431-85dd-3d24fef7148e.
Order retrieval at Servitør
GET to retrieve-order/:UUID and successful reply is JSON
{
"orderId": "878a4ba5-f03b-4431-85dd-3d24fef7148e",
"orderReceived": "2023-03-30T10:51:47.000Z",
"orderReady": "2023-03-30T10:55:01Z",
"orderRetrieved": "2023-03-30T10:56:35.000Z",
"orderSize": 11,
"orderBrewed": 11
}
Job starting at Coffee Machine
POST ro /start-job with JSON payload:
{
"product": "COFFEE",
"jobId": "04dd77fc-93f3-440c-8ce3-4fe698bfe61a"
}
Note that jobID is optional and can even be changed by the Coffee Machine!
The successful reply is
{
"jobId": "04dd77fc-93f3-440c-8ce3-4fe698bfe61a",
"product": "COFFEE",
"jobStarted": "2023-03-30T10:54:01.000Z",
"jobReady": "2023-03-30T10:54:18.000Z"
}
Job retrieval at Coffee Machine
GET to /retrieve-job/:UUID and successful reply is JSON
{
"jobId": "04dd77fc-93f3-440c-8ce3-4fe698bfe61a",
"product": "COFFEE",
"jobStarted": "2023-03-30T10:54:01.000Z",
"jobReady": "2023-03-30T10:54:18.000Z",
"jobRetrieved": "2023-03-30T10:55:01.000Z"
}