Overview
We model the domain first — orders, claims, shipments, approvals — then build services whose boundaries follow those concepts.
Code is reviewed, typed and tested so the next engineer can change it safely.
Trade-offs
- Modular monolith vs services
- A modular monolith is cheaper to run and change early; split into services only where scaling or ownership demands it.
- Build vs buy
- Buy commodity capability, build the workflow that differentiates the business.
Architecture
Integration layer
Moves data between systems reliably. Every message is queued, retried on failure and deduplicated so nothing posts twice.
- REST & webhook adapters
- Queue with retries
- Idempotency keys
- Schema mapping
Illustrative diagram. For the end-to-end view, see the architecture on the Developers home.
Workflow
Model
Name the entities and states.
What we design for
- Business rules living only in people's heads
- Unclear ownership between modules
- Tests that break on every refactor
Explicit state transitions
type OrderState = "received" | "validated" | "approved" | "shipped";
const allowed: Record<OrderState, OrderState[]> = {
received: ["validated"], validated: ["approved"],
approved: ["shipped"], shipped: [],
};
export function transition(from: OrderState, to: OrderState) {
if (!allowed[from].includes(to)) throw new Error(`${from} -> ${to} not allowed`);
return to;
}