PeerQuik Documentation
The Ultimate SaaS Starter Kit Installation Guide
PeerQuik: The Ultimate SaaS Starter Kit
PeerQuik is a production-ready Next.js 14 boilerplate designed to jumpstart your B2C or C2C application, whether itβs a marketplace, SaaS with subscriptions, or a custom portal. It includes prebuilt features like authentication, Stripe payments, an admin panel, reviews, emails, cron jobs, maps, currency conversion, and moreβsaving you hours of development time.
This guide is beginner-friendly and assumes no prior experience with some tools. You can reuse PeerQuik for multiple projects by repeating the setup process for each new instance. Just copy the project folder and follow the steps below.
1. π Prerequisitesβ²
Before you start, ensure you have the following installed:
- Node.js (v18 or higher): Download from nodejs.org.
- npm: Comes with Node.js. Verify with
npm -v. - Code Editor: We recommend Visual Studio Code.
- PostgreSQL (local) or Supabase (cloud): For the database.
- Docker (optional): For VPS deployment with Coolify.
- Accounts:
- Google Cloud Console (for OAuth).
- Stripe (for payments).
- Resend (for emails).
- Mapbox (for maps).
- FreeCurrencyAPI (for currency conversion).
- Google reCAPTCHA (for form protection).
Note: Sign up for these services in advance, as youβll need API keys during setup.
2. π§ Tech Stack Overviewβ²
PeerQuik uses modern, industry-standard technologies:
- Next.js 14 (App Router): A React framework for server-side rendering (SSR) and static site generation (SSG). The App Router organizes routes by folders.
- TypeScript: Adds type safety to prevent coding errors.
- Tailwind CSS: A utility-first CSS framework for rapid styling.
- Prisma + PostgreSQL/Supabase: Prisma is an ORM (Object-Relational Mapping) tool for managing your database. PostgreSQL is a powerful, free database; Supabase is a user-friendly alternative.
- NextAuth: Handles secure authentication (email, Google OAuth, roles).
- Stripe: Manages payments and subscriptions with invoices and webhooks.
- Resend: Sends transactional emails (e.g., password resets, invoices).
- Docker + Coolify: Simplifies deployment on a VPS (Virtual Private Server).
- Mapbox + OpenStreetMap: Displays interactive maps for listings.
- FreeCurrencyAPI: Converts prices to different currencies in real-time.
- Google reCAPTCHA: Protects forms from bots.
- Cron Jobs: Automates tasks like currency updates or data cleanup.
- Programmatic SEO: Generates sitemap.xml, robots.txt, and dynamic pages for SEO.
3. π Getting Startedβ²
3.1 π Installation βΌ
- Download and Extract:
- Unzip the
peerquik-boilerplate.zipfile you received. - Navigate to the project folder:
cd peerquik
- Unzip the
- Set Up Environment Variables:
- Copy the example environment file:
cp .env.example .env
- Open
.env.exampleand create a.envfile, paste the variables, and add your API keys (see Section 8 for details). Example:DATABASE_URL="postgresql://user:password@localhost:5432/peerquik" GOOGLE_CLIENT_ID="your_google_client_id" GOOGLE_CLIENT_SECRET="your_google_client_secret" STRIPE_SECRET_KEY="your_stripe_secret_key" RESEND_API_KEY="your_resend_api_key" NEXT_PUBLIC_MAPBOX_TOKEN="your_mapbox_token" FREECURRENCYAPI_KEY="your_currency_api_key" RECAPTCHA_SITE_KEY="your_recaptcha_site_key" RECAPTCHA_SECRET_KEY="your_recaptcha_secret_key"
- Copy the example environment file:
- Install Dependencies:
npm install
- Set Up Database:
- Local PostgreSQL:
- Install PostgreSQL (instructions).
- Create a database named
peerquik:psql -U postgres -c "CREATE DATABASE peerquik;"
- Update
DATABASE_URLin.envwith your credentials.
- Supabase:
- Sign up at supabase.com.
- Create a new project and copy the database URL to
DATABASE_URLin.env.
- Apply the database schema:
npx prisma migrate dev --name init
- Local PostgreSQL:
- Run the App:
npm run dev
- Open http://localhost:3000 in your browser.
- β Checkpoint: You should see the PeerQuik landing page.
Note: To reuse PeerQuik for another project, copy the peerquik folder to a new location and repeat these steps with new API keys and a fresh database.
3.2 π¨ Customize Your Brand βΌ
- Logo and Favicon:
- Replace
public/logo.svgwith your logo. - Update
public/favicon.icowith your favicon.
- Replace
- Colors and Fonts:
- Edit
tailwind.config.ts:theme: { extend: { colors: { primary: "#123456", // Your brand color }, }, } - Modify global styles in
app/globals.css.
- Edit
- Landing Page:
- Update text and images in
app/page.tsx. - Edit site metadata in
app/layout.tsxandapp/_document.tsx.
- Update text and images in
3.3 π Protected Routes βΌ
Routes are organized by user roles:
app/(protected)/buyer/: For buyers.app/(protected)/seller/: For sellers.app/(protected)/admin/: For admins.
Server-Side Protection:
import { getServerSession } from "next-auth";
import { redirect } from "next/navigation";
const session = await getServerSession(authOptions);
if (!session) redirect("/login");
Client-Side Protection:
import { useSession } from "next-auth/react";
import { useRouter } from "next/navigation";
const { status } = useSession();
const router = useRouter();
if (status === "unauthenticated") router.push("/login");
4. π Authentication Systemβ²
PeerQuik uses NextAuth.js for secure authentication:
- Email Login: Supports email + password with verification (magic link).
- Google OAuth: Login with Google accounts.
- Roles: Buyer, Seller, Admin.
4.1 Configure Google OAuth βΌ
- Go to Google Cloud Console.
- Create a new project.
- Enable OAuth 2.0 and set:
- Local URI:
http://localhost:3000/api/auth/callback/google - Production URI:
https://yourdomain.com/api/auth/callback/google
- Local URI:
- Add to
.env:GOOGLE_CLIENT_ID=your_id GOOGLE_CLIENT_SECRET=your_secret
4.2 Roles and User Types βΌ
There are two user types configured in the app:
- User Type A β e.g., buyer, student, client.
- User Type B β e.g., seller, instructor, provider.
Each user type has its own registration and login flows, as well as personalized views, routing, and dashboard components.
4.3 Extend User Model βΌ
To add fields to the User model, edit prisma/schema.prisma:
model User {
id String @id @default(cuid())
email String @unique
role String
phone String?
profileComplete Boolean @default(false)
}
You can also add more models and relations. Apply changes:
npx prisma migrate dev --name extend-user
5. π¦ Database and ORMβ²
- Database: PostgreSQL (local or Supabase).
- ORM: Prisma.
- Schema: Defined in
prisma/schema.prisma.
To modify the schema:
- Edit
prisma/schema.prisma. - Run:
npx prisma migrate dev --name your_change_name
6. βοΈ Folder Structureβ²
PeerQuik uses Next.js App Router:
app/: Routes and pages.components/: Reusable UI components (modals, hooks, maps, favorites, buttons, etc.).actions/: Server-side logic (Server Actions).lib/: Helper functions (auth, utilities).utils/: Specific utilities (e.g., currency conversion).
7. βοΈ Listings and Reviewsβ²
Flow:
- Sellers create listings.
- Buyers search and contact sellers.
- Buyers leave reviews after interactions.
- Users can mark favorite listings or sellers.
Form Setup:
- Forms use
react-hook-formandzodfor validation. - Custom inputs are in
components/ui. - Example form:
import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; const form = useForm({ resolver: zodResolver(yourSchema) }); <Form {...form.register("field")} />
Add Relationships:
- Update
prisma/schema.prismawith new models. - Run:
npx prisma db push
- Create API routes in
app/api/route.ts. - Add actions in
app/actions.ts.
Frontend Customization:
- Pages are created, but you need to finalize the frontend using AI tools (e.g., for styling or layout).
- Customize the
ItemCardcomponent incomponents/ItemCard.tsxfor listings or sellers using AI to match your design.
8. π§© Integrationsβ²
8.1 π³ Stripe (Subscriptions) βΌ
What is it? Stripe allows you to accept payments and manage subscriptions easily.
Steps:
- Create an account at stripe.com.
- In the Stripe Dashboard:
- Go to "Products" β Create a product for your subscription.
- Add one or more prices (e.g., monthly, annual).
- Add to
.env:STRIPE_SECRET_KEY=your_secret_key STRIPE_WEBHOOK_SECRET=your_webhook_secret NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_publishable_keyNote: Find these keys in Stripe Dashboard β "Developers" β "API Keys" and "Webhooks".
- Webhooks:
- Create an endpoint in Stripe for notifications.
- URL:
https://yourapp.com/api/stripe/webhooks - Code is in:
app/api/stripe/webhooks/route.ts
- Subscriptions:
- When a user subscribes, call the endpoint:
app/api/stripe/subscribe-seller/route.ts
- When a user subscribes, call the endpoint:
- Invoicing:
- Invoices are generated automatically in PDF using
jspdf. - Sent to users via Resend (see below).
- Invoices are generated automatically in PDF using
8.2 π© Emails with Resend βΌ
What is it? A service for sending emails from your app without complications.
Steps:
- Create an account at resend.com.
- Important: If you donβt verify your domain, you can only send emails from the registered email.
- Add to
.env:RESEND_API_KEY=your_resend_key
- Edit
actions/mail.tsto set the sender:from: "Your App <noreply@yourapp.com>",
Change
yourapp.comto your domain or use the registered email if unverified. - Test email templates locally:
npm run email
8.3 πΊ Maps (Mapbox + OpenStreetMap) βΌ
What is it? Displays maps for user locations, centers, or searches.
Steps:
- Create an account at mapbox.com.
- Copy your access token and add to
.env:NEXT_PUBLIC_MAPBOX_TOKEN=your_mapbox_token
Mapbox + OpenStreetMap powers maps in listings and search.
8.4 π± FreeCurrencyAPI βΌ
What is it? Converts prices between different currencies.
Steps:
- Create an account at freecurrencyapi.com.
- Add to
.env:FREECURRENCYAPI_KEY=your_api_key
- Conversion logic is in:
utils/currencyconverter.ts. - A cron job updates exchange rates periodically (see Section 9).
8.5 β Google reCAPTCHA βΌ
What is it? Prevents spam in forms, especially for non-logged-in users.
Steps:
- Go to Google reCAPTCHA Admin.
- Register your domain (e.g.,
yourapp.com). - Add keys to
.env:RECAPTCHA_SITE_KEY=your_site_key RECAPTCHA_SECRET_KEY=your_secret_key
Used in public forms (registration, contact, etc.).
9. β° Cron Jobsβ²
Cron jobs automate tasks like currency updates or data cleanup.
- Scripts: Defined in
utils/cronJob.ts. Add all cron jobs here. - Vercel Limitation: The free tier allows only one cron job. For more, use a VPS with Coolify.
- Coolify:
- Go to the "Cron Jobs" panel in Coolify.
- Watch my tutorial on YouTube if you have questions.
- Vercel:
- Edit
vercel-cron.jsonto configure cron jobs.
- Edit
10. π§ SEO & Programmatic SEOβ²
- Sitemap: Auto-generated in
app/sitemap.ts. - Robots.txt: Configured in
app/robots.ts. - PSEO: The
/pseofolder generates dynamic pages for keywords or regions.
11. π ChatGPT Promptsβ²
Use the provided prompts to generate:
- Terms of Service: Save in
app/terms-of-service/page.tsx. - Privacy Policy: Save in
app/privacy-policy/page.tsx. - User Data Deletion: Save in
app/user-data-deletion/page.tsx.
Run the prompts in ChatGPT or a similar AI tool and paste the output.
12. π¦ Deploymentβ²
12.1 π©οΈ Vercel + Supabase (Easy) βΌ
- Push your project to GitHub.
- Connect to vercel.com.
- Add
.envvariables in Vercel Settings. - Deploy the app.
- Set up a Supabase database (see Section 3.1).
12.2 π³ Coolify + VPS βΌ
- Set up a VPS (e.g., DigitalOcean, Hetzner).
- Install Docker and Coolify (docs).
- Authenticate with GitHub Container Registry:
echo "your_token" | docker login ghcr.io -u your_username --password-stdin
- Build and push:
docker build -t ghcr.io/your_username/peerquik:latest . docker push ghcr.io/your_username/peerquik:latest - Deploy via Coolifyβs dashboard.
- Watch my tutorial on YouTube if you have questions.
13. π Troubleshootingβ²
- Error: Database connection failed:
- Check
DATABASE_URLin.env. - Ensure PostgreSQL/Supabase is running.
- Check
- Error: Stripe webhook not firing:
- Verify
STRIPE_WEBHOOK_SECRETin.env. - Test webhooks locally with
stripe listen --forward-to localhost:3000/api/stripe/webhooks.
- Verify
- Error: Prisma migrate failed:
- Run
npx prisma generateand retry.
- Run
- Need Help? Email support (included with your purchase) or check
README.md.
14. β»οΈ Reusing PeerQuikβ²
To create another project with PeerQuik:
- Copy the
peerquikfolder to a new location. - Create a new database and update
DATABASE_URL. - Generate new API keys for all services.
- Repeat the installation steps (Section 3.1).
Thereβs no limit to how many times you can reuse PeerQuik!
15. π Features at a Glanceβ²
- β Next.js 14 boilerplate (App Router, TypeScript)
- β Prisma database schema (PostgreSQL/Supabase)
- β Register/login for Buyers & Sellers (Email + Google OAuth)
- β Forgot password, change email, email verification
- β Contact form with Resend emails
- β Admin, Buyer, Seller, Listings, and Reviews routes
- β Admin panel for management
- β Footer with newsletter setup
- β Reviews calculations and components
- β Navbar and search listings
- β Custom hooks for reusability
- β Currency converter
- β Cron jobs for automated tasks
- β Forms with CAPTCHA protection
- β Extensive components (modals, buttons, headings, errors, maps)
- β Responsive frontend pages (landing, etc.)
- β Add favorites for Sellers/Listings
- β Premium subscription for Sellers (Stripe + invoices + emails)
- β Sitemap generator, robots.txt, PSEO folder
- β ChatGPT prompts for legal pages
- β README with setup instructions
- β Dockerfile, .dockerignore, docker-compose for VPS/Coolify
Happy building with PeerQuik! π