The arrow that points the wrong way
Pricing logic sits in the domain and reads orders from Postgres. To do that, the domain imports the database library and its row types directly.
Everything works. But the domain now cannot be tested without a database, cannot be reused behind a different store, and a schema change reaches into business rules that have nothing to do with storage. The dependency runs from the thing that should be stable to the thing that changes most.
Boundaries, outermost first: Domain core: Pricing rules (worth protecting) Infrastructure: Postgres adapter (knows SQL), In-memory adapter (for tests) Outside every boundary: an empty slot for the owned by the domain Connections: Pricing rules calls owned by the domain — defines and uses (step 1) Postgres adapter calls owned by the domain — implements (step 2) In-memory adapter calls owned by the domain — implements (step 3)