Why have procedure, service and query layers in such a small API?
After this you can answer: Why have procedure, service and query layers in such a small API?
Say it in 30 seconds
Section titled “Say it in 30 seconds”The deeper answer
Section titled “The deeper answer”A booking procedure derives the user from the authenticated session, enforces its rate policy through a service, and calls the booking service. It does not accept a caller-supplied owner. The service distinguishes a valid retry from reuse of a key for different booking parameters, then invalidates event caches after a new commit.
The query performs the seat checks, decrement, booking insert and outbox insert in one Postgres transaction. Although the checks express business rules, moving them outside the locked transaction would introduce a race. The exception protects a stronger rule: the data checked must be the data changed.
The useful review question is who owns each decision and side effect. Adding a generic repository interface to every file would add indirection without improving this boundary.
Counter-questions
Section titled “Counter-questions”What changes when HTTP is replaced?
What failure would a misplaced check create?
Would you mock every layer?
Where in MiniTickets
Section titled “Where in MiniTickets”Read Layers, then inspect the api-app piece →.
apps/api/src/queries/bookings.ts → createBookingTxRead this book online: https://book.theversehub.in/