Why architecture matters when the codebase grows
Your order service from the caching phase works, but look at it. It validates input, queries the book catalog, creates the order, inserts into the database, enqueues the background job, and handles errors. One function that knows about Zod, Drizzle, BullMQ, and business rules all at once. That is the fat service problem.
The cost of a fat service is not obvious on day one. It shows up on day ninety, when two engineers try to change the order flow at the same time and collide on every line. It shows up the first time you want to test a business rule in isolation and discover you need a running database and a Redis connection to do it. It shows up when you want to reuse the same workflow from a CLI and find everything is tangled with HTTP.
No. For a throwaway prototype, a fat service is fine. For anything you expect to keep building on, separate the business rules from the I/O once your service starts growing. The layers in this module are the minimum shape that scales. Start small, reach for this when the pain shows up.
Quiz: Quiz
Loading practice…