Order Support Decision Engine Driven by a Rule DAG and an Order Status API
Company: DoorDash
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Onsite
When something goes wrong with a food delivery order (it is late, lost or never delivered), support agents need to respond consistently. Build a system that evaluates an order's current state and automatically decides what to do: issue a refund, close the request, escalate, and so on.
There is no starter code. You build three pieces:
- an API that represents order status, which the system queries to read an order;
- a rule set defined as a directed acyclic graph (DAG) of checks and actions;
- an engine that reads the order through your API, walks the rule graph from its start node, and returns the decision.
An example rule graph:
```text
Start
|
v
Is the order late?
|-- Yes --> Issue refund --> End
|-- No -------------------> End
```
The engine must work for any rule graph built from the same kinds of nodes, not only this example. Implement the pieces and show the example graph deciding correctly for a late order and for an on-time order.
```hint Two kinds of nodes
Look at the example and ask which nodes ask a question about the order and which nodes do something, and what each kind needs to store to know where to go next.
```
```hint The graph is input
Someone other than you will write future rule graphs. Ask what could be wrong with a graph you are handed, and whether you want to find out when the graph is loaded or halfway through handling an order.
```
### Clarifying Questions
- Which fields does the order status API expose (status, promised and actual delivery times, amount, previous refunds), and what exactly makes an order late?
- Can a check have more than two outcomes, and can one path perform several actions in sequence?
- Should the engine execute actions such as refunds itself, or only return the decided action for another service to carry out?
- What should happen when the order does not exist or the status API fails?
- Is the rule graph loaded from a file at start-up, or can it change while the service runs?
### What a Strong Answer Covers
- A small order status API with a clear order model and explicit error responses
- A rule graph format with distinct check and action nodes, labeled branches and one start node
- Validation when a graph is loaded: unknown node references, missing branches, unknown checks or actions, cycles and unreachable nodes
- A deterministic engine that reads the order once, walks the graph, and records a trace of every check and action
- Checks and actions registered by name, so new rules need no engine changes
- Tests for both branches of the example, for malformed graphs and for API failures
### Follow-up Questions
- A support request is retried and the engine runs twice for the same order. How do you make sure the refund is issued only once?
- Rule authors want to change the graph without a deploy. How do you version graphs and roll back a bad one?
- An agent asks why the engine escalated a particular order. What can you show them?
- What would you change to run this for every support request on the platform rather than for a demo?
Overview: A coding and design exercise that builds an order support engine from scratch: an order status API, a rule set expressed as a directed acyclic graph of checks and actions, and an engine that walks the graph to decide whether to refund, close or escalate. It tests data modeling, graph validation, extensibility and testing.
Read the full DoorDash Software Engineer interview experience this question came from