Production-ready e-commerce storefront for MiniVersePrints, a Sri Lankan 3D-printed figure, bust, miniature and collectible business.
- Next.js 16 App Router, TypeScript, React 19
- Tailwind CSS 4
- Supabase PostgreSQL, Authentication and Storage
- Server actions and route handlers
- Zod validation
- PayHere sandbox-ready payment flow
- Jest tests for checkout calculations, permissions and order payload creation
- Install dependencies:
npm install- Create a local env file:
cp .env.example .env.local-
Fill in Supabase and PayHere values in
.env.local. -
Run the dev server:
npm run devOpen http://localhost:3000.
Required:
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_SERVICE_ROLE_KEY=
NEXT_PUBLIC_SITE_URL=http://localhost:3000
PAYHERE_MERCHANT_ID=
PAYHERE_MERCHANT_SECRET=
PAYHERE_MODE=sandboxNever expose SUPABASE_SERVICE_ROLE_KEY or PAYHERE_MERCHANT_SECRET in client components.
- Create a Supabase project.
- In SQL Editor, run migrations in order:
supabase/migrations/001_initial_schema.sql
supabase/migrations/002_rls_policies.sql
- Run demo data:
supabase/seed.sql
- Create Storage buckets:
product-images
review-images
payment-slips
custom-order-references
homepage-banners
Use public read access for product and banner images. Keep payment slips and custom references private unless you add signed URL handling.
- Start the app and register at
/register. - In Supabase Dashboard, open Authentication > Users.
- Add this to the user
app_metadata:
{ "role": "admin" }- Ensure the matching row in
profileshasrole = 'admin'. - Log out and back in, then open
/admin.
- Go to
/admin/products/new. - Add name, slug/SKU, descriptions, LKR pricing, stock, product type, category, tags and SEO fields.
- Use Supabase Storage URLs for placeholder or final product images.
- Mark items as featured, new arrival or best seller as needed.
- Use
/admin/categories,/admin/tags,/admin/shipping,/admin/coupons,/admin/bannersand/admin/settingsfor store management.
- Create a PayHere sandbox merchant account.
- Put sandbox merchant credentials in
.env.local. - Keep
PAYHERE_MODE=sandbox. - Configure notification URL:
https://your-domain.com/api/payhere/notify
For local testing, expose the dev server with a tunnel and use the tunneled notify URL.
Payment hashes are generated server-side in /api/payhere/hash. The merchant secret is not sent to the browser. Payment notifications are verified server-side before orders are marked paid.
To switch to live mode:
- Replace sandbox merchant credentials with live credentials.
- Set
PAYHERE_MODE=live. - Update PayHere return, cancel and notify URLs to the production Vercel domain.
- Run a low-value live test order before announcing online payments.
- Push the project to a Git provider.
- Import it in Vercel.
- Add every variable from
.env.exampleto Vercel Project Settings > Environment Variables. - Set
NEXT_PUBLIC_SITE_URLto the production URL. - Deploy.
- In Supabase, add the Vercel URL to Auth redirect URLs.
- In PayHere, set production return/cancel/notify URLs.
npm run dev
npm run lint
npm test
npm run build- Home page loads with hero, product sections, categories, reviews and WhatsApp button.
- Shop search, filters, sorting and pagination work on mobile and desktop.
- Product page can select variations, add to cart, wishlist and open WhatsApp enquiry.
- Ready-stock cart cannot exceed available stock.
- Checkout validates Sri Lankan phone number and address fields.
- COD, bank transfer, store pickup and PayHere routes create correct order/payment states.
- PayHere notify route verifies checksum and does not double-process callbacks.
- Public track order shows status without exposing private customer details.
- Customer can register, log in, manage profile, addresses, wishlist and orders.
- Admin-only
/adminredirects non-admin users. - Admin can manage products, categories, tags, shipping, coupons, orders, reviews, banners, settings and custom orders.
- Bank transfer slip submission moves order to payment verification.
- Sitemap, robots, metadata and product structured data render correctly.
- Checkout subtotal, delivery, discount and stock validation.
- Admin role permission checks.
- Order insert payload and initial status rules.
Run with:
npm testDemo products and placeholder images are editable sample data. Replace them from the admin dashboard or Supabase Storage before launch.