Architecture overview
Context
One container image runs in two roles (Integrations__Roles): Api serves HTTP, and Worker runs the
message consumers and the scheduled jobs. In Kubernetes they are separate Deployments; locally and in the demo, one
process runs both.
Layers
Dependencies point inwards. The Application layer owns the ports (ITaxProvider, IAddressProvider,
IPartyProvider, ICertificateProvider, IExchangeRateProvider, IEventPublisher, IAppDbContext), and the
outer layers implement them. These rules are enforced by architecture tests (tests/.../Architecture/LayeringTests.cs):
| Rule | Why |
|---|---|
| Domain depends on nothing but the base library | Business rules stay testable and portable |
| Contracts are self-contained | Other teams reference them as a package |
| Application reaches the outside only through its own ports | Providers can be swapped (Mexico, a different FX source) |
| The Avalara SDK is used only inside the AvaTax adapter | One place to change when Avalara changes |
| Adapter classes are internal | Callers depend on ports, not on implementations |
A request, end to end
Saving before calling AvaTax and using a document code derived from the caller's natural key means a crash or retry, including a redelivered message whose first attempt rolled back, adjusts the same AvaTax transaction instead of creating a second one. The transactional outbox means events leave only when the change commits.
Where to go next
- Resilience: timeouts, retries, circuit breaking, PendingTax
- Security: authentication, scopes, entity access, data minimization
- Decisions: the ADRs behind the design
- Events and Database