Where would you put the boundary between the web app, API and worker?
After this you can answer: Where would you put the boundary between the web app, API and worker?
Say it in 30 seconds
Section titled “Say it in 30 seconds”The deeper answer
Section titled “The deeper answer”Start with the invariant: a confirmed booking must have its seats deducted exactly once for that user intent. The API owns that transaction. Moving the seat decision into the browser or an asynchronous email handler would split the decision from its durable record.
The Next.js app can render pages and cache public event data. Feature hooks call the API; browser code does not import its runtime. The API validates input and checks the session before applying business rules. The worker consumes versioned messages containing the facts it needs, rather than querying Postgres for email content.
These are responsibility boundaries, not a demand for many independently deployed services. MiniTickets keeps one API with small layers. I would split further only when ownership, scaling or failure isolation justified the operational cost.
Counter-questions
Section titled “Counter-questions”What happens when email is down?
Why not let the worker book the seats?
How would you prove the boundary helps?
Where in MiniTickets
Section titled “Where in MiniTickets”Read Layers, then inspect the api-app piece →.
apps/api/src/services/bookings.ts → bookTicketRead this book online: https://book.theversehub.in/