I have question on how to design an order management microservice. An order has different workflow based on the previous state or based on the business needs. I'm guessing at some point cannot keep on adding if/else/switch because it would be very difficult manage workflows and this will also leads to more bugs.
Order Management service has to manage the order/items in the order from creation to delivery. At each every point there could be sub workflows like Rewards, Cancellation etc..
Moreover, most of the order management work is done event-driven ( Ex: if the change happens then listen and trigger another action ) & there are some ad-hoc workflows which requires to backtrack order to previous states or move/skip some actions altogether and continue processing different workflows.
What I have already Tried:
- Kind of StateMachine based workflow management.
- I was able to come up with approach to manage different workflows by creating JSON DSL based on configs and select and continue processing the workflow based on that config.
- Able to manage 10+ different types of orders now.
- Number of config files are continuing to increase.
- Not able rearrange or change the workflow at runtime.
- Changing the order of workflow affects the existing orders placed.
My question are,
- How do really big companies like Amazon/Shopify maintaining the workflow ?
- What design pattern we have to follow to make sure we are able to scale ?
- What design pattern we have to follow to achieve observability ?