Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/microservices-patterns/ftgo-application/llms.txt

Use this file to discover all available pages before exploring further.

The Kitchen Service in the FTGO application represents the restaurant’s kitchen workflow. It manages Ticket aggregates that track the preparation lifecycle of each order, from creation through acceptance, preparation, and pickup. The service participates in the CreateOrderSaga, CancelOrderSaga, and ReviseOrderSaga as a saga participant, and publishes ticket domain events consumed by the Delivery Service. This page covers the service’s responsibilities, domain model, REST API, messaging, and database schema.

Responsibilities

  • Create and manage Ticket aggregates that mirror each food order in the kitchen
  • Receive saga commands from the Order Service to create, confirm, cancel, and revise tickets
  • Allow kitchen staff to accept tickets via the REST API, specifying an estimated ready-by time
  • Publish ticket domain events (TicketAcceptedEvent, TicketCancelled, etc.) so the Delivery Service can schedule and cancel couriers
  • Track preparation lifecycle: acceptance → preparing → ready for pickup → picked up

Domain Model

The core aggregate is Ticket, persisted to the tickets table.
FieldTypeNotes
idLongMatches the orderId from the Order Service
stateTicketStateCurrent state in the lifecycle
previousStateTicketStateSaved before entering pending states, used for saga compensation
restaurantIdLongThe restaurant this ticket belongs to
lineItemsList<TicketLineItem>Stored in the ticket_line_items collection table
readyByLocalDateTimeTarget ready time set on acceptance
acceptTimeLocalDateTimeTime the ticket was accepted
preparingTimeLocalDateTimeTime kitchen began preparing
pickedUpTimeLocalDateTimeTime courier picked up the order
readyForPickupTimeLocalDateTimeTime kitchen marked order ready

Ticket states

CREATE_PENDING → AWAITING_ACCEPTANCE → ACCEPTED → PREPARING → READY_FOR_PICKUP → PICKED_UP
                       ↘                    ↘
                  CANCEL_PENDING        REVISION_PENDING

                  CANCELLED
CREATE_PENDING is the initial state set at construction. The saga’s ConfirmCreateTicket command advances it to AWAITING_ACCEPTANCE. Kitchen staff then call the REST API to move it to ACCEPTED, after which the service emits TicketAcceptedEvent.
The previousState field is critical for saga compensation. When a cancel or revise command puts the ticket into a pending state, the service stores previousState so it can revert cleanly if the saga is rolled back.

REST API

The service listens on port 8083.
MethodPathDescription
POST/tickets/{ticketId}/acceptKitchen staff accept a ticket and set an estimated ready-by time

Accept ticket request body

{
  "readyBy": "2026-05-21T18:30:00"
}
The readyBy timestamp must be in the future at the time of acceptance. If readyBy is not after the current time, the service throws an IllegalArgumentException and returns an error.
The REST API surface of the Kitchen Service is intentionally minimal — most state transitions happen via saga commands over the messaging layer rather than direct HTTP calls.

Messaging

Events published

Events are emitted on the net.chrisrichardson.ftgo.kitchenservice.domain.Ticket channel:
EventTrigger
TicketCreatedEventSaga’s ConfirmCreateTicket command confirms the ticket
TicketAcceptedEventKitchen staff accept via POST /tickets/{ticketId}/accept; includes readyBy time
TicketPreparationStartedEventKitchen calls preparing() on the ticket
TicketPreparationCompletedEventKitchen calls readyForPickup() on the ticket
TicketPickedUpEventCourier calls pickedUp() on the ticket
TicketCancelledSaga’s ConfirmCancelTicketCommand confirms cancellation
TicketRevisedSaga’s ConfirmReviseTicketCommand confirms revision
The TicketAcceptedEvent and TicketCancelled events are consumed by the Delivery Service to schedule or cancel courier assignments.

Saga commands handled

The service listens on the kitchenService command channel (defined in KitchenServiceChannels.COMMAND_CHANNEL):
CommandHandlerDescription
CreateTicketcreateTicket()Creates a new Ticket in CREATE_PENDING state
ConfirmCreateTicketconfirmCreateTicket()Advances ticket to AWAITING_ACCEPTANCE
CancelCreateTicketcancelCreateTicket()Rolls back a pending ticket creation
BeginCancelTicketCommandbeginCancelTicket()Moves ticket to CANCEL_PENDING
ConfirmCancelTicketCommandconfirmCancelTicket()Advances ticket to CANCELLED
UndoBeginCancelTicketCommandundoBeginCancelTicket()Reverts ticket from CANCEL_PENDING to previous state
BeginReviseTicketCommandbeginReviseTicket()Moves ticket to REVISION_PENDING
UndoBeginReviseTicketCommandundoBeginReviseTicket()Reverts ticket from REVISION_PENDING to previous state
ConfirmReviseTicketCommandconfirmReviseTicket()Applies revised line items and reverts to previous state

Events consumed

SourceEventHandler
Restaurant ServiceRestaurantCreatedBuilds a local restaurant record for validation

Database

The Kitchen Service uses MySQL. Key tables:
TableDescription
ticketsThe Ticket aggregate: state, restaurant ID, timestamps
ticket_line_items@ElementCollection collection table for TicketLineItem entries
Saga reply messages and outbox events are managed by the Eventuate Tram framework via the message and received_messages tables.

Build docs developers (and LLMs) love