Documentation

Everything you need to build and ship your SaaS with Go.

Introduction

The Go SaaS Kit is a production-ready boilerplate designed to save you weeks of setup time. It combines the performance of Go with the simplicity of HTMX and Tailwind CSS, giving you a powerful stack without the complexity of modern JS frameworks.

Tip: This documentation assumes you have basic familiarity with Go and command-line tools.

Quick Start

1. Prerequisites

  • Go 1.22+
  • Docker (optional)
  • PostgreSQL
  • Stripe CLI

2. Installation

Terminal
# Set up environment
cp .env.example .env
# Start database (Docker)
docker-compose up -d
# Run the application
go run cmd/api/main.go

Project Structure

  • cmd/
    • api/main.go // Application entry point
  • internal/
    • handlers/ // HTTP request handlers
    • models/ // Database structs (GORM)
    • email/ // Resend integration
  • views/
    • home/ // Landing page templates
    • layout/ // Base HTML structure
  • static/ // CSS, JS, Images
  • docs/ // Documentation files
  • Taskfile.yml // Task runner config
  • docker-compose.yml // Local DB setup
  • Dockerfile.prod // Production build file

Features Deep Dive

Authentication

Pre-configured Email/Password flow and Google OAuth using Goth. Session management uses secure HTTP-only cookies.

ENABLE_GOOGLE_AUTH=true

Payments

Full Stripe integration including Subscriptions, Checkout Sessions, Customer Portal, and Webhook handling for status updates.

STRIPE_SECRET_KEY=sk_test_...

Email System

Integrated Resend for reliable email delivery. Includes beautiful HTML templates for Welcome emails and Password resets.

AI-Friendly Documentation

The kit includes a specially formatted `README.md` and project structure that is optimized for AI coding assistants (like Cursor, Copilot, or ChatGPT). You can simply paste the README into your AI context to get better, more accurate code generation.

Configuration & Environment Variables

Configure the application using environment variables. Below are guides on how to obtain the critical keys.

Getting your Resend API Key

  1. Sign up at Resend.com.
  2. Go to API Keys in the dashboard.
  3. Create a new API Key (Full Access recommended for dev).
  4. Copy the key (starts with `re_`) into your `.env` file as `RESEND_API_KEY`.

Setting up Google OAuth

To enable "Continue with Google":

  1. Go to Google Cloud Console.
  2. Create a new Project and configure the OAuth Consent Screen (External).
  3. Go to Credentials → Create Credentials → OAuth Client ID.
  4. Application Type: Web Application.
  5. Authorized Redirect URIs: `http://localhost:3000/auth/google/callback` (and your production URL).
  6. Copy Client ID and Client Secret to your `.env`.

Setting up Stripe Payments

  1. Register at Stripe.com.
  2. Go to DevelopersAPI keys.
  3. Copy `Publishable key` (pk_test_...) and `Secret key` (sk_test_...) to `.env`.
  4. For Local Development: Use the Stripe CLI to listen for webhooks: `stripe listen --forward-to localhost:3000/webhook`. Copy the signing secret (`whsec_...`) to `.env` as `STRIPE_WEBHOOK_SECRET`.
  5. For Production: Add a Webhook Endpoint URL (`https://your-domain.com/webhook`) in the dashboard and copy that signing secret.
  6. Create a Product and Price in the Dashboard, and copy the Price ID to `STRIPE_PRICE_ID`.

Variable Reference

VariableDescriptionExample
APP_NAMEApp name in emails"Acme Corp"
COMPANY_NAMELegal company name"Acme Inc."
EMAIL_LOGO_URLHeader logo URL"https://.../logo.png"
SUPPORT_EMAILReply-To address"support@gosaaskit.io"

Database Schema

The kit uses GORM (Go Object Relational Mapper) with PostgreSQL. Here is the core `User` model structure which handles Auth, Billing, and Admin roles.

internal/models/user.go
type User struct {
    gorm.Model
    Email    string `gorm:"uniqueIndex;not null" json:"email"`
    Name     string `json:"name"`
    Password string `json:"-"` // Hashed

    // Email verification
    VerificationToken string
    IsVerified        bool `gorm:"default:false"`

    // OAuth social login fields
    AvatarURL  string `json:"avatar_url"`
    Provider   string `json:"provider"`    // e.g., "google"
    ProviderID string `json:"provider_id"` 

    // Stripe billing integration
    StripeCustomerID string `json:"stripe_customer_id"`
    SubscriptionID   string `json:"subscription_id"`
    IsPremium        bool   `json:"is_premium"`

    // Admin privileges
    IsAdmin bool `json:"is_admin"`
}

Deployment Platforms

We include step-by-step guides for the most popular Go hosting platforms.

RenderRecommended
RailwayEasiest
Fly.ioAdvanced