System Design Atlas

Tax returns and assessment

10 / 10Worked example

Final design

Which tests verify concurrency control and completion for a return in the overall architecture?

The conclusion retains the full topology from step 6. Inside the boundary: interface → assessment API → return revisions, rules, evidence and draft notices. Calculation and delivery processing read durable work from this store. The delivery service is external. Processing exchanges domain messages; results reach the interface through the API. The evidence plan tests concurrency, retries, boundaries and terminal closure for return E-37. Table entries are expected outcomes, not executed tests.

Starting point Approval and technical delivery remain separate roles.

Assumptions for the example case

A fictional administrative workflow using an invented calculation model to bind return year, rule revision and draft assessment notice. The model uses an allowance of 100000 cents; only the excess is charged at 10 % and rounded to whole cents using round-half-up. All figures and test targets are illustrative assumptions.

Overall architecture with checks and review loops

Runtime topology

  1. 1 · Tax filer → Tax assessment API
  2. 2 · Tax assessment API → Relational case datastore
  3. 3 · Relational case datastore → Calculation processing
  4. 4 · Calculation processing → Tax assessment API
  5. 5 · Tax assessment API → Delivery processing
Tax filerInformation and supporting documents
Delivery serviceAcknowledge technical transmission

Bounded tax-assessment workflow

Tax assessment APIRevision and verification status
Protected document storeImmutable evidence
Relational case datastoreReturn and review status
Calculation processingCalculate frozen status
Delivery processingSend document hash
Tax filer → Tax assessment APITax return and evidence
Tax assessment API → Protected document storeImmutable proof
Tax assessment API → Relational case datastoreRevision and status
Relational case datastore → Calculation processingFrozen status
Calculation processing → Tax assessment APIDraft assessment notice
Tax assessment API → Delivery processingReleased document hash
Delivery processing → Delivery serviceTechnical receipt
Replay 4 · State 5 · Flow 7 · Operations 9Allowance: 100,000 cents · excess charged at 10 %

Approval binds exactly one return revision and one rule revision from the same model year.

The tax filer submits information and evidence through the assessment API. A protected document store holds immutable evidence; a relational case store holds return revisions and review status. Calculation processing reads a frozen rule and return revision and produces a draft assessment notice. Approvers confirm the exact content; delivery processing sends its document hash to the external delivery service. Caseworkers review the technical acknowledgement and close the bounded workflow. Calculation and transmission use separate asynchronous paths. The same components and arrows as step 6. Test markers: API/commit → concurrency and replay (4/5/7); boundary check → exact limit (2); domain role/closure → terminal evidence (9).

Test plan for the complete design

ComponentTest and expected resultReturn to an earlier step
Tax assessment APIAmendment and approval both expect version 5. Amendment first prevents approval of the old draft. Approval first preserves the old version; after a fresh read, amendment opens a linked follow-up review.Steps 3 and 5
Command journalIdentical retries take effect once; changed content produces a conflict.Steps 4 and 7
Domain boundary checkTest 99999, 100000 and 100001 cents. Expected rule: the fictional model uses an allowance of 100000 cents; only the excess is charged at 10 % and rounded to whole cents using round-half-up.Step 2
Tax return revisions, rule versions, evidence and draft assessment noticesAfter technical completion, an amendment changes neither the old document hash nor the calculation result; it creates a linked follow-up review.Steps 5 and 9
Calculation and delivery processingA calculation job generates the draft assessment notice from a frozen return revision. Approval checks the current revision again. After commit, the unchanged document is transmitted. A missing transport response remains unknown and does not establish legally effective notification.Steps 6 and 7

Tax assessment API

Test and expected result
Amendment and approval both expect version 5. Amendment first prevents approval of the old draft. Approval first preserves the old version; after a fresh read, amendment opens a linked follow-up review.
Return to an earlier step
Steps 3 and 5

Command journal

Test and expected result
Identical retries take effect once; changed content produces a conflict.
Return to an earlier step
Steps 4 and 7

Domain boundary check

Test and expected result
Test 99999, 100000 and 100001 cents. Expected rule: the fictional model uses an allowance of 100000 cents; only the excess is charged at 10 % and rounded to whole cents using round-half-up.
Return to an earlier step
Step 2

Tax return revisions, rule versions, evidence and draft assessment notices

Test and expected result
After technical completion, an amendment changes neither the old document hash nor the calculation result; it creates a linked follow-up review.
Return to an earlier step
Steps 5 and 9

Calculation and delivery processing

Test and expected result
A calculation job generates the draft assessment notice from a frozen return revision. Approval checks the current revision again. After commit, the unchanged document is transmitted. A missing transport response remains unknown and does not establish legally effective notification.
Return to an earlier step
Steps 6 and 7

First end-to-end test and outstanding evidence

End-to-end path
Test amendment against approval end to end. A calculation job generates the draft assessment notice from a frozen return revision. Approval checks the current revision again. After commit, the unchanged document is transmitted. A missing transport response remains unknown and does not establish legally effective notification.
Clarify before extending the scope
Agree the real delivery-service contract, retention, recovery targets and roles before extending the scope. All limits here are design assumptions. This evidence table specifies tests to run; integration, browser checks and reader comprehension tests follow separately.

Test an amendment against approval end to end

Test an amendment against approval end to end

Test an amendment against approval end to end.

An amended return arrives while draft approval is pending. Closure requires both technical and domain evidence.

Amendment and approval both expect version 5. Amendment first prevents approval of the old draft. Approval first preserves the old version; after a fresh read, amendment opens a linked follow-up review. Your test defines the input and expected result.

Alternative considered
An initial end-to-end path limited to lists and forms postpones the critical state checks.
Trade-off
The first end-to-end path needs controlled concurrency and failure points.
Reassess
Passing the counterexample tests and checks with readers provides grounds for extending the case.

Try it yourself

Choose two architectural decisions: concurrency protection and evidence-backed completion. For each, name the test, expected result and step to revisit.

A hint for your attempt

Link the markers of the overall architecture with the associated design steps.

Compare with a possible solution
Concurrency control
Amendment and approval both expect version 5. Amendment first prevents approval of the old draft. Approval first preserves the old version; after a fresh read, amendment opens a linked follow-up review. Expected invariant: exactly one return revision and one rule revision from the same model year bind the approved draft; amendment requires renewed review. Failures lead back to step 5 and the command contract in step 4.
Test completion and retries
Start: a technically completed case has an immutable document hash, calculation result and transmission record. Submit an amendment with a new return revision, then repeat the same key and content. Expected: exactly one linked follow-up review; the old document hash, calculation result and transmission record remain identical. Replay returns the same follow-up record; a new approval of the old case conflicts. Failures lead back to step 9 for ownership and step 7 for the failure sequence.

Apply to your project

Which two counterexample tests will you run first in your own end-to-end implementation?

Transfer the architecture and counterexamples to the editable Markdown design template.

Start your own design

Choose a small case from your project. The template collects the ten design tasks and leaves space for your sketches, decisions, and open assumptions. You can edit it in your text editor or note-taking app.

Download design template (.md)
Compare the ten tasks with the example case
  1. Purpose and boundary

    Which evidence about a tax return would originate outside the application in your project?

    In the example: The rule year and tax return remain explicitly linked. A fictional administrative workflow with an invented calculation model linking the tax return year, rule revision and draft assessment notice.

  2. Requirements

    Which rule of your project remains binding even with slow processing?

    In the example: The calculation model and rounding are identified as fictional. The invented model uses an allowance of 100000 cents; only the amount above it is charged at 10 % and rounded to whole cents using round-half-up.

  3. Scale estimates

    Which individual object concentrates load more strongly than the daily average when processing return revisions?

    In the example: Concurrent amendments complement the volume test profile. An average of 1 events/s says little about amendment and approval of the same tax return.

  4. Interfaces

    Which input fields make two change intentions different in your project?

    In the example: Approval binds the tax return and document hash. The return revision, model year, rule revision, calculation result and document hash must remain identical on replay.

  5. Data and states

    Which states must remain protected in your model against late replay?

    In the example: Draft assessment notices remain immutable versions. After technical completion, an amendment changes neither the old document hash nor the calculation result; it creates a linked follow-up review.

  6. Overall architecture

    Which planned service boundary would distribute a currently local guarantee across the network?

    In the example: The calculation job and delivery use the same manifest. Tax return revisions, rule versions, evidence and draft assessment notices must express the same valid state.

  7. Critical flow

    What feedback could be missing even though the underlying action has already taken place?

    In the example: Check amendments again before approval. The approved draft assessment notice binds exactly one return revision and one rule revision from the same model year; an amendment requires renewed review.

  8. Bottlenecks and trade-offs

    Which similar display could have two different causes in your project?

    In the example: Document requests and calculation backlogs have separate signals. Long processing time may result from requests for additional evidence or a calculation backlog. Waiting reason, run manifest and delivery status are measured separately.

  9. Operations and security

    Which open state in your project needs a domain specialist as well as technical operations?

    In the example: Approval and technical delivery remain separate roles. After technical completion, an amendment changes neither the old document hash nor the calculation result; it creates a linked follow-up review.

  10. Final design

    Which two counterexample tests will you run first in your own end-to-end implementation?

    In the example: Test an amendment against approval end to end. Amendment and approval both expect version 5. Amendment first prevents approval of the old draft. Approval first preserves the old version; after a fresh read, amendment opens a linked follow-up review.