This view covers all functionality related to placing an order: adding/removing items from a shopping cart, selecting a pick-up location for the order, checkout with payment validation and order processing, querying, viewing and cancelling existing orders, rating meals and creating reviews for verified purchases.
This is a microservice architecture that also uses the event-driven architecture (EDA) architecture style for processing an order. Key patterns used:
- BFF
- Database per Microservice (aka Database per Service)
- Wrapper (aka Legacy Wrapper, Anticorruption Layer)
- CQRS
- Publish-subscribe (in the event-driven architecture)
- Handles the requests from the frontend apps relative to the different steps the customer goes through when they click checkout.
- It allows the user to apply a coupon, in which case the service interacts with the
Promotions
service to validate the coupon and recalculate the cost based on the discount. - When processing the final submit for the meal order,
Checkout
callsInventory query
for validating the order against meal availability in the selected pick-up location (if one was chosen). If everything is OK, a domain event "Purchase Order Created" is published. - The purchase order is processed asynchronously, as described in the sequence diagram further down.
- Will process the payment for a submitted purchase order.
- Uses a third-party payment gateway. To avoid coupling the logic to one specific payment gateway provider, the interaction is through a wrapper service.
- If the payment is successful,
Payment
publishes an Order Payment Confirmed event containing all order details and payment status.
- Payflow is the payment gateway service for PayPal. We used it as a (likely) example of payment gateway.
- External payment gateway service that offers a public API to merchant partners.
- Responsible for sending out notifications to the customers via one or more mechanisms:
- app push notification
- SMS
- It subscribes to various events and puts together the corresponding personalized messages according to pre-defined templates.
- Has basic operations for creating or modifying an order.
- It's invoked:
- by Order processing when a meal order is placed.
- by Order BFF when the customer updates or cancels an order.
- It uses the CQRS pattern.
- This batch program generates purchases based on active subscription.
- A subscription is charged every month. The payment has to be processed and notifications are generated, similar to a purchase order placed online.
- Has endpoints to allow the customer to rate meals, add reviews, or give non-public feedback for verified purchases
- Has also endpoints for querying and searching reviews and ratings. These endpoints are used when looking at a meal item from the catalog.