A full-stack marketplace/e-commerce app built with Next.js App Router, Prisma + Postgres, Better Auth, Stripe Checkout, UploadThing uploads, and Resend email.
This README is written for v0.1.0 (last verified: 2026-05).
- Try it Yourself (Live Demo)
- Why This Exists
- Tech Stack
- Quick Start (Local)
- Environment Variables
- Database (Prisma)
- Authentication
- Payments (Stripe)
- Uploads (UploadThing)
- Troubleshooting
🚀 Try it yourself! The project is deployed and available at: marketplace.phexuss.dev
Important: This is a test/demo project for showcasing functionality — no real products are sold, and no real payments are processed.
The site uses Stripe Test API, so you can safely test the checkout flow with Stripe's test card numbers:
- Test card:
4242 4242 4242 4242 - Any future expiration date (e.g.,
12/34) - Any 3-digit CVC (e.g.,
123)
📘 Full list of test cards: Stripe Testing Documentation
Feel free to:
- Sign up and log in
- Browse products
- Add items to cart
- Complete a test checkout with Stripe test cards
- Explore the dashboard
The admin panel is available only when running locally (not deployed to production for security).
To access it locally:
- Update your user's
rolefield to"admin"in the database - Navigate to
/admin
Admin features:
- Create, edit, and delete products
- Manage product images via UploadThing
- Configure categories, styles, colors, and sizes
You want a real-world Next.js project that covers the “hard parts” (auth, database, uploads, payments) without needing multiple services and repos. This codebase is a single Next.js app that ties those pieces together end-to-end.
- Next.js (App Router) + React
- Prisma v7 + PostgreSQL (Prisma Adapter PG)
- Better Auth (email/password + Google OAuth)
- Stripe (Checkout Sessions)
- UploadThing (authenticated image uploads)
- Resend (transactional emails)
- Biome (lint + format)
- Node.js 20+
- npm 9+ (or newer)
- A PostgreSQL database (local, Docker, or hosted)
npm cicp .env.example .envIf you are on Windows PowerShell:
Copy-Item .env.example .envAt minimum for local development, set:
DATABASE_URLNEXT_PUBLIC_BASE_URL(usehttp://localhost:3000locally)
If you plan to use sign-up/sign-in, uploads, or checkout, you must also configure the related keys (see the table below).
npx prisma migrate devThis repo includes a seed script that creates categories/styles/colors/sizes and sample products.
npx prisma db seednpm run devCopy .env.example to .env and fill in values.
| Variable | Required | Used for | Notes |
|---|---|---|---|
DATABASE_URL |
Yes | Prisma + Postgres | Example:postgresql://user:pass@localhost:5432/db?schema=public |
NEXT_PUBLIC_BASE_URL |
Yes | Next.js metadata + Stripe redirects | Must be a valid absolute URL (ex:http://localhost:3000) |
BETTER_AUTH_SECRET |
For auth | Better Auth | Set a long random secret string |
BETTER_AUTH_URL |
For auth | Better Auth | Usually the same asNEXT_PUBLIC_BASE_URL locally |
RESEND_API_KEY |
For email flows | Better Auth email verification + password reset | src/lib/email.ts sends via Resend |
GOOGLE_CLIENT_ID |
Optional | Google OAuth | Only needed if you enable Google sign-in |
GOOGLE_CLIENT_SECRET |
Optional | Google OAuth | Only needed if you enable Google sign-in |
UPLOADTHING_TOKEN |
For uploads | UploadThing | Needed for the/api/uploadthing route |
STRIPE_SECRET_KEY |
For checkout/admin products | Stripe API | Use a test key locally (sk_test_...) |
ROUTER_AI_API_KEY |
Optional | (Reserved) | Present in.env.example but not referenced in src/ currently |
- Schema:
prisma/schema.prisma - Migrations:
prisma/migrations/* - Prisma config:
prisma.config.ts(loads.envviadotenv/config) - Generated client output:
src/generated/prisma
Common commands:
# Apply migrations and generate Prisma Client
npx prisma migrate dev
# Seed data (runs: tsx prisma/seed.ts)
npx prisma db seed
# Reset the database (DANGEROUS: deletes data)
npx prisma migrate reset- The Better Auth handler is mounted at
src/app/api/auth/[...all]/route.ts. - Email/password auth is enabled.
- Google OAuth is configured if you set
GOOGLE_CLIENT_ID+GOOGLE_CLIENT_SECRET.
The admin page requires session.user.role === "admin".
To grant yourself access locally, update your user in the database and set role to admin.
- Checkout sessions are created in the server action
src/app/actions/checkout.ts. - After Stripe redirects back,
src/app/(main)/checkout/success/page.tsxverifies payment and updates the order status toPAID.
You must set:
STRIPE_SECRET_KEYNEXT_PUBLIC_BASE_URL(used forsuccess_url/cancel_url)
- Upload route:
src/app/api/uploadthing/* - The UploadThing middleware requires an authenticated session.
- Next.js image remote patterns are configured for UploadThing hosts in
next.config.ts.
You are missing NEXT_PUBLIC_BASE_URL. Set it to a full URL, for example:
NEXT_PUBLIC_BASE_URL=http://localhost:3000- Ensure
.envexists and containsDATABASE_URL. - Ensure your Postgres instance is running and reachable.
src/lib/email.ts sends from noreply@phexuss.dev. In Resend, you must verify the domain/sender or change the from address to something your Resend account is allowed to send.




