About the FTGO monolith
The FTGO application, which is a Spring Boot application, has a monolithic architecture.
It consists of the (Gradle) modules shown in the following diagram:

The key responsibilities of each module is as follows:
ftgo-application- contains the Spring Boot main application classftgo-order-service- the order and delivery management controller and domain serviceftgo-consumer-service- the consumer management controller and domain serviceftgo-restaurant-service- the restaurant management controller and domain serviceftgo-courier-service- the courier management controller and domain serviceftgo-domain- contains domain classes:Consumer,Courier,Order,Restaurantftgo-common- contains generic value objects, such as Money, and Address.
About Delivery Management
Delivery management is responsible for scheduling of couriers who pick up orders from restaurants and deliver them to consumers.
A delivery is scheduled when the restaurant accepts an Order and commits to a pickup time.
It’s cancelled when the Order is cancelled.
The scheduling of each courier is primarily driven by their availability and current location, which is provided by the Courier mobile application, and each Order’s pickup and drop-off locations.
Tangled Order management and Delivery management
Although they are logically separate, Order management and Delivery management are intertwined as shown in the following diagram:

Delivery Management is part of Order Management, within the ftgo-order-service module.
It also involves part of Courier Management within ftgo-courier-service.
In particular, the following types implement both:
OrderService- in addition to managingOrders, it also implements the logic for scheduling deliveriesOrderentity - a single entity represents bothOrders andDeliverysOrderStateenum - the lifecycle of the order contains both order and delivery management states.
Let’s look at each one.
OrderService class
The OrderService class contains delivery management logic:
public class OrderService {
public void accept(long orderId, LocalDateTime readyBy) {
...
scheduleDelivery(order, readyBy);
}
public void scheduleDelivery(Order order, LocalDateTime readyBy) { ... }
public void notePickedUp(long orderId) { ... }
public void noteDelivered(long orderId) { ... }
In particular, the scheduleDelivery() method implements the bulk of the courier scheduling logic.
Order entity
The Order entity represents both Orders and Deliverys:
@Entity
@Table(name = "orders")
@Access(AccessType.FIELD)
@DynamicUpdate
public class Order {
@Enumerated(EnumType.STRING)
private OrderState orderState;
@ManyToOne
private Courier assignedCourier;
...
OrderState
The OrderState enum has values corresponds to both order management and delivery management (e.g. PICKED_UP, DELIVERED):
public enum OrderState {
APPROVED,
ACCEPTED, PREPARING, READY_FOR_PICKUP, PICKED_UP, DELIVERED,
CANCELLED,
}
Delivery management and Couriers
Delivery management also uses part of the Courier entity:
@Entity
@Access(AccessType.FIELD)
@DynamicUpdate
public class Courier {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Boolean available;
@Embedded
private Plan plan;
The other aspects of the Courier entity are not relevant to Delivery Management, such as their personal and financial details.
Delivery management and Restaurants
Delivery management also needs to know the address of each Restaurant since that’s the pickup location for an Order.
@Entity
@Table(name = "restaurants")
@Access(AccessType.FIELD)
@DynamicUpdate
public class Restaurant {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Embedded
private Address address;
The other aspects of the Restaurant entity are not relevant to Delivery Management, such its menu.
What’s next
- Look at the FTGO monolithic application code
- Study the first step refactoring step, which splits the code
- Read chapter 13 of my book Microservices patterns, which covers refactoring to microservices
- Talk to me about my microservices consulting and training services
Premium content now available for paid subscribers at
