How masuud10/furniture-version works
Purpose and Runtime
A Next.js App Router furniture storefront with customer accounts, cart/checkout, catalog administration, and order operations. TypeScript server/client components and Server Actions sit over Supabase (Postgres, Auth, Storage, RLS, RPC). Primary application root: src/app/layout.tsx; route protection/session refresh begins in src/middleware.ts and src/lib/supabase/middleware.ts.
Route Domains and Entry Points
Storefront pages cover discovery, product detail, search, cart, checkout, gallery, and contact under src/app/(storefront)/; its shared chrome is src/app/(storefront)/layout.tsx. Auth and account experiences are isolated in src/app/(auth)/ and src/app/(account)/account/. Privileged back-office routes are under src/app/admin/, with the admin boundary enforced by src/features/admin/guard.ts and shared shell in src/app/admin/layout.tsx.
Catalog Read Model and Media
Catalog reads are centralized rather than coupled directly to pages: src/lib/catalog/queries.ts, src/lib/catalog/source.ts, and src/lib/catalog/types.ts define the access/model boundary. Listing filters and query parsing belong in src/lib/catalog/listing-params.ts; cache invalidation is coordinated through src/lib/catalog/revalidate.ts. Product/gallery media resolve through src/lib/catalog/media-url.ts and generated/local metadata such as src/lib/catalog/generated-real-media.json; Supabase Storage is provisioned in supabase/migrations/20260820090600_storage.sql.
Commerce Flow
Cart state supports guest and persisted/read paths via src/lib/cart/guest-cart.ts, src/lib/cart/model.ts, and src/lib/cart/read.ts; UI mutations enter through src/features/cart/actions.ts. Checkout submits via src/features/checkout/actions.ts from src/app/(storefront)/checkout/checkout-form.tsx. Database commerce schema/RPCs define the transactional order-placement boundary in supabase/migrations/20260820090300_commerce.sql and supabase/migrations/20260820090500_rpc.sql. Order lifecycle rules are explicit in src/lib/orders/transitions.ts, then exercised by admin actions in src/features/admin/order-actions.ts.
Identity, Customer Data, and Authorization
Supabase clients are split by execution context: browser, server, and privileged service access in src/lib/supabase/client.ts, src/lib/supabase/server.ts, and src/lib/supabase/admin.ts. Sign-in/up mutations are owned by src/features/auth/actions.ts; account address/profile writes by src/features/account/address-actions.ts. Identity, customer contact, roles, and row-level access policies are materially defined in supabase/migrations/20260820090100_identity.sql, supabase/migrations/20260820090400_rls.sql, and supabase/migrations/20260820100000_customer_contact.sql.
Administration and Content Mutation
Admins manage products, media, and orders through src/app/admin/products/product-form.tsx, src/app/admin/products/media-manager.tsx, and src/app/admin/orders/order-controls.tsx. Their commands are consolidated in src/features/admin/product-actions.ts and src/features/admin/order-actions.ts, preserving a separation between UI forms, authorization guard, writes, and catalog cache revalidation.
Presentation, SEO, and External Surface
Reusable storefront state/UI includes variant selection and add-to-cart at src/components/storefront/variant-context.tsx and src/components/storefront/add-to-cart.tsx. Pricing and locale-safe money formatting are centralized in src/lib/money.ts. Search/discovery metadata, JSON-LD, OG images, sitemap, and robots are generated through src/lib/seo/, src/app/(storefront)/opengraph-image.tsx, src/app/sitemap.ts, and src/app/robots.ts. Static videos and gallery assets remain available from public/media/.
Components 19
Next.js surface
- App root
src/app/layout.tsx - Session middleware · Refreshes sessions before route handling.
src/middleware.ts - Storefront routes
src/app/(storefront)/layout.tsx - Auth and account
- SEO surface · Produces discovery metadata, structured data, OG images, sitemap, and robots.
Commerce domains
- Cart and checkout · Mutates guest or persisted carts and submits checkout.
src/features/checkout/actions.ts - Cart read model · Unifies guest and persisted cart reads.
src/lib/cart/read.ts - Catalog read model · Centralizes catalog queries, types, filters, media, and revalidation.
src/lib/catalog/queries.ts - Storefront interactions · Owns variant selection and add-to-cart interaction.
src/components/storefront/add-to-cart.tsx - Identity and profile writes
src/features/auth/actions.ts - Order transitions
src/lib/orders/transitions.ts
Back office
- Admin shell
src/app/admin/layout.tsx - Admin guard
src/features/admin/guard.ts - Product and media commands · Writes catalog data and triggers catalog revalidation.
src/features/admin/product-actions.ts - Order operations · Applies explicit order lifecycle transitions.
src/features/admin/order-actions.ts
Supabase platform
- Supabase clients · Browser, server, middleware, and privileged access clients.
src/lib/supabase/server.ts - Identity and RLS · Defines identities, customer contacts, roles, and row-level policies.
supabase/migrations/20260820090400_rls.sql - Commerce schema and RPC · Owns transactional order placement and commerce data.
supabase/migrations/20260820090500_rpc.sql - Product media storage
supabase/migrations/20260820090600_storage.sql
Connections 26
- App root → Session middleware: request lifecycle
- Session middleware → Supabase clients: refreshes session
- App root → Storefront routes: renders
- App root → Auth and account: renders
- App root → Admin shell: renders
- Storefront routes → Catalog read model: reads catalog
- Storefront routes → Storefront interactions: hosts interactions
- Storefront interactions → Cart and checkout: add and checkout
- Cart and checkout → Cart read model: reads cart
- Cart and checkout → Commerce schema and RPC: places order via RPC
- Catalog read model → Supabase clients: queries through
- Catalog read model → Product media storage: resolves media
- Auth and account → Identity and profile writes: submits writes
- Identity and profile writes → Supabase clients: uses
- Supabase clients → Identity and RLS: auth and policy enforcement
- Admin shell → Admin guard: enforces access
- Admin guard → Supabase clients: checks role
- Admin shell → Product and media commands: catalog commands
- Admin shell → Order operations: order commands
- Product and media commands → Commerce schema and RPC: writes products
- Product and media commands → Product media storage: manages media
- Product and media commands → Catalog read model: revalidates
- Order operations → Order transitions: validates transitions
- Order operations → Commerce schema and RPC: updates orders
- Commerce schema and RPC → Identity and RLS: protected by policies
- Storefront routes → SEO surface: publishes metadata