System Design Atlas

Multi-stage request approval

06 / 10Worked example

The overall architecture

Which responsibility belongs in the API, which can the worker assume after committing?

The approval API accepts submissions, decisions, and status queries. After commit, the worker reads the outbox and hands over U-17. Both processes use the authoritative relational data store; the purchasing application remains outside the system boundary.

Starting point Step 5 defined request, task and handover as separate states.

Assumptions for the example case

Illustrative design: an internal procurement request for 6,000 euros undergoes business review followed by budget review. The inclusive budget threshold is 5,000 euros. These figures are assumptions rather than operational measurements. Ordering, payment, contract law and automatic decisions are outside the scope.

Runtime components within approval coordination

Runtime view · API and worker share a relational datastore

Applicants and reviewersCommands and Work Lists
People → APIHTTPS · Authenticated commands and queries

System boundary · Approval coordination

API processSubmission, decision, withdrawal and status consultation
API → SQLBusiness state, version and outbox in one transaction
Worker processHandover and reminders outside the request path
SQL → WorkerRead committed pending U-17
Worker → SQLSave proof of acceptance and retry status
Relational SQL datastoreA-17 · R-3 · Tasks · Policy P-2 · Outbox
Worker → PurchasingSend U-17; Purchasing → Worker confirms new or existing acceptance
Purchasing applicationConfirms new or existing U-17
  • Separate runtime processes
  • Authoritative SQL datastore
  • People and purchasing outside

The approval transaction writes state and outbox together. A worker then delivers U-17 to the external target.

API, worker and SQL are runtime components. People and the purchasing application sit outside the boundary.

Domain modules in API and Worker

Component view · Domain responsibilities within processes

API process

Application managementMaintains A-17, R-3 and the request version; orchestrates submission and withdrawal
Application management → Rule evaluationRequest the versioned rule
Rule evaluationProvides P-2 and determines whether budget approval is required
Rule evaluation → Task managementDetermine review order
Task managementChecks role, status and version; produces F-17 and then G-17
Task management → Handover coordinationInitiate only after overall approval
Handover coordinationWrites U-17 with request status upon overall approval

Worker process

Outbox readerRead due U-17 repeatedly
Purchasing adapterSend U-17 and reconcile results
ReminderHighlight due tasks without changing business state
Outbox reader → Purchasing adapterPass due U-17 for delivery
SQL → ReminderReading Due Open Tasks
API ↔ SQL ↔ WorkerThe API commits business state and outbox; the worker reads U-17 and stores acceptance evidence. Status queries read A-17, the active revision, tasks and handovers.
  • Modules per runtime process
  • Joint transaction contract

Request and task management update business state in one transaction. Reminders read due tasks; handover coordination tracks acceptance evidence separately.

The component view exposes responsibilities inside the API and worker; it does not show independent services.

Starting architecture

Modular core
Application management, rule evaluation, task management and handover coordination remain domain modules of a clear core.
Two runtime roles
The API process answers requests. The worker processes outbox and reminder repeatably. Both share a transactional database boundary.
Product neutral choice
SQL, Worker and Outbox follow from transaction, history and external repetition. They do not require a specific workflow engine.

Map business responsibilities to implementation

Building block at a glanceModule cooperationRuntime
Application managementMaintains revision and request version; calls rule evaluation and task managementAPI
Rule evaluationProvides versioned threshold rule P-2; determines whether budget approval is requiredAPI as an internal call
Task managementChecks permissions and tasks; updates request management and requests handover at completionAPI within a transaction
Handover coordinationWrites U-17 in the approval transaction; the purchasing adapter delivers it laterAPI and Worker

Application management

Module cooperation
Maintains revision and request version; calls rule evaluation and task management
Runtime
API

Rule evaluation

Module cooperation
Provides versioned threshold rule P-2; determines whether budget approval is required
Runtime
API as an internal call

Task management

Module cooperation
Checks permissions and tasks; updates request management and requests handover at completion
Runtime
API within a transaction

Handover coordination

Module cooperation
Writes U-17 in the approval transaction; the purchasing adapter delivers it later
Runtime
API and Worker

Terms in this step

Modular monolith
A domain-structured application core with clear module boundaries and one release unit. Here, API and worker are two processes of the same application, rather than independently owned domain services.
Runtime process
An executable component such as the API or worker, distinct from a domain task or module.

Try it yourself

Assign submission, approval decision, reminder and U-17 handover to the API or worker. Justify one assignment.

A hint for your attempt

Ask if the step needs an immediate answer or can withstand an external repetition.

Compare with a possible solution
API
Submission and decision belong in the API because they check current business state and return a result or 409 to the person.
Worker
Reminder and U-17 transmission are with the worker because they can run repeatedly and timed after a commit.

Apply to your project

Which of your domain modules need an immediate answer, and which ones are allowed to work in a decoupled manner?

The next step checks the separation on four normal and error scenarios.