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 β–Ό

  1. Download and Extract:
    • Unzip the peerquik-boilerplate.zip file you received.
    • Navigate to the project folder:
      cd peerquik
  2. Set Up Environment Variables:
    • Copy the example environment file:
      cp .env.example .env
    • Open .env.example and create a .env file, 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"
          
  3. Install Dependencies:
    npm install
  4. Set Up Database:
    • Local PostgreSQL:
      • Install PostgreSQL (instructions).
      • Create a database named peerquik:
        psql -U postgres -c "CREATE DATABASE peerquik;"
      • Update DATABASE_URL in .env with your credentials.
    • Supabase:
      • Sign up at supabase.com.
      • Create a new project and copy the database URL to DATABASE_URL in .env.
    • Apply the database schema:
      npx prisma migrate dev --name init
  5. Run the App:
    npm run dev

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 β–Ό

  1. Logo and Favicon:
    • Replace public/logo.svg with your logo.
    • Update public/favicon.ico with your favicon.
  2. Colors and Fonts:
    • Edit tailwind.config.ts:
      
      theme: {
          extend: {
              colors: {
                  primary: "#123456", // Your brand color
              },
          },
      }
                                    
    • Modify global styles in app/globals.css.
  3. Landing Page:
    • Update text and images in app/page.tsx.
    • Edit site metadata in app/layout.tsx and app/_document.tsx.

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 β–Ό

  1. Go to Google Cloud Console.
  2. Create a new project.
  3. Enable OAuth 2.0 and set:
    • Local URI: http://localhost:3000/api/auth/callback/google
    • Production URI: https://yourdomain.com/api/auth/callback/google
  4. 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:

  1. Edit prisma/schema.prisma.
  2. 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:

  1. Sellers create listings.
  2. Buyers search and contact sellers.
  3. Buyers leave reviews after interactions.
  4. Users can mark favorite listings or sellers.

Form Setup:

  • Forms use react-hook-form and zod for 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:

  1. Update prisma/schema.prisma with new models.
  2. Run:
    npx prisma db push
  3. Create API routes in app/api/route.ts.
  4. 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 ItemCard component in components/ItemCard.tsx for 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:

  1. Create an account at stripe.com.
  2. In the Stripe Dashboard:
    • Go to "Products" β†’ Create a product for your subscription.
    • Add one or more prices (e.g., monthly, annual).
  3. Add to .env:
    
    STRIPE_SECRET_KEY=your_secret_key
    STRIPE_WEBHOOK_SECRET=your_webhook_secret
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_publishable_key                                                    
                                                            

    Note: Find these keys in Stripe Dashboard β†’ "Developers" β†’ "API Keys" and "Webhooks".

  4. Webhooks:
    • Create an endpoint in Stripe for notifications.
    • URL: https://yourapp.com/api/stripe/webhooks
    • Code is in: app/api/stripe/webhooks/route.ts
  5. Subscriptions:
    • When a user subscribes, call the endpoint: app/api/stripe/subscribe-seller/route.ts
  6. Invoicing:
    • Invoices are generated automatically in PDF using jspdf.
    • Sent to users via Resend (see below).

8.2 πŸ“© Emails with Resend β–Ό

What is it? A service for sending emails from your app without complications.

Steps:

  1. Create an account at resend.com.
  2. Important: If you don’t verify your domain, you can only send emails from the registered email.
  3. Add to .env:
    RESEND_API_KEY=your_resend_key
  4. Edit actions/mail.ts to set the sender:
    from: "Your App <noreply@yourapp.com>",

    Change yourapp.com to your domain or use the registered email if unverified.

  5. Test email templates locally:
    npm run email

8.3 πŸ—Ί Maps (Mapbox + OpenStreetMap) β–Ό

What is it? Displays maps for user locations, centers, or searches.

Steps:

  1. Create an account at mapbox.com.
  2. 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:

  1. Create an account at freecurrencyapi.com.
  2. Add to .env:
    FREECURRENCYAPI_KEY=your_api_key
  3. Conversion logic is in: utils/currencyconverter.ts.
  4. 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:

  1. Go to Google reCAPTCHA Admin.
  2. Register your domain (e.g., yourapp.com).
  3. Add keys to .env:
    
    RECAPTCHA_SITE_KEY=your_site_key
    RECAPTCHA_SECRET_KEY=your_secret_key                                                   
                                                            

Used in public forms (registration, contact, etc.).

8.6 πŸ“¬ Newsletter Footer β–Ό

  1. Use Resend to manage newsletter subscriptions.
  2. Edit the footer component in components/footer.tsx.
  3. Add a form to collect emails and save to the Newsletter database model.

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.json to configure cron jobs.

10. 🧠 SEO & Programmatic SEOβ–²

  • Sitemap: Auto-generated in app/sitemap.ts.
  • Robots.txt: Configured in app/robots.ts.
  • PSEO: The /pseo folder 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) β–Ό

  1. Push your project to GitHub.
  2. Connect to vercel.com.
  3. Add .env variables in Vercel Settings.
  4. Deploy the app.
  5. Set up a Supabase database (see Section 3.1).

12.2 🐳 Coolify + VPS β–Ό

  1. Set up a VPS (e.g., DigitalOcean, Hetzner).
  2. Install Docker and Coolify (docs).
  3. Authenticate with GitHub Container Registry:
    echo "your_token" | docker login ghcr.io -u your_username --password-stdin
  4. Build and push:
    
    docker build -t ghcr.io/your_username/peerquik:latest .
    docker push ghcr.io/your_username/peerquik:latest                                                   
                                                            
  5. Deploy via Coolify’s dashboard.
  6. Watch my tutorial on YouTube if you have questions.

13. πŸ›  Troubleshootingβ–²

  • Error: Database connection failed:
    • Check DATABASE_URL in .env.
    • Ensure PostgreSQL/Supabase is running.
  • Error: Stripe webhook not firing:
    • Verify STRIPE_WEBHOOK_SECRET in .env.
    • Test webhooks locally with stripe listen --forward-to localhost:3000/api/stripe/webhooks.
  • Error: Prisma migrate failed:
    • Run npx prisma generate and retry.
  • Need Help? Email support (included with your purchase) or check README.md.

14. ♻️ Reusing PeerQuikβ–²

To create another project with PeerQuik:

  1. Copy the peerquik folder to a new location.
  2. Create a new database and update DATABASE_URL.
  3. Generate new API keys for all services.
  4. 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! πŸš€