sk for an e-commerce backend and you get products, carts and orders, and most of it is CRUD that any framework handles. Then one day a product with one unit left goes on sale, and two customers both get a confirmation email.
That second part is what decides whether a shop backend is any good, and it lives in a handful of places: where prices are stored, what an order remembers about them, and the few statements that take stock out of the warehouse. Get those right and the CRUD around them is routine. Get them wrong and the bug shows up only under load, on the day you sell the most.
This post builds the whole backend with NestJS 12, PostgreSQL and Drizzle: a catalog that staff manage, a cart per customer, a checkout that can't oversell, cancelling and shipping, a curl session, tests that race real requests against a real database, and a production checklist. Every file is here, including the sign-in side it starts from.…