The challenge
A small shop needs two things that usually come from different products: somewhere to manage the catalog and orders, and a fast public store.
I wanted to see how far one Next.js codebase could go as admin, CMS and API at once, with a separate storefront that holds no data of its own.
The approach
I built it in August 2023 following Code With Antonio's tutorial, then connected the admin to a MySQL database on PlanetScale, deployed both apps on Vercel and branded the store as 002. Every table in the Prisma schema carries a storeId, so one login can run several shops and each gets its own /api/{storeId} routes.
Two details stood out. PlanetScale doesn't allow foreign keys, so the schema uses Prisma's relationMode and indexes every relation field by hand. And checkout writes an unpaid Order before sending the shopper to Stripe; the webhook then marks it paid, saves the address and archives the sold products so they drop out of the API.
- Multi-store CMSBillboards, categories, sizes, colors and products managed per store, with Cloudinary image uploads.
- Generated APIPublic GET routes for the storefront; POST, PATCH and DELETE only for the signed-in store owner via Clerk.
- Filterable storefrontCategory pages filter by size and color through URL query params, with a cart persisted in localStorage.
- Stripe checkoutCheckout sessions tied to an order id, settled by a signed webhook.
From admin to checkout
- 01ManageCreate a store, billboards and products
- 02ServePer-store REST routes over Prisma
- 03ShopStorefront fetches, filters, adds to cart
- 04PayStripe Checkout, webhook marks it paid




