laju-go Svelte Themes

Laju Go

High-performance SaaS boilerplate built with Go Fiber + Svelte 5 + Inertia.js + SQLite.

Laju Go

High-performance SaaS boilerplate built with Go Fiber + Svelte 5 + Inertia.js 3 + SQLite.

Build production-ready web applications faster with a clean, layered architecture that combines the speed of Go with the developer experience of modern frontend frameworks.

๐Ÿš€ Quick Start

# Create new project with CLI
npx create-laju-go my-app

# Navigate to project
cd my-app

# Start development
npm run dev:all

Option 2: Clone Repository

# Clone the repository
git clone https://github.com/maulanashalihin/laju-go.git
cd laju-go

# Install dependencies
go mod download && npm install

# Set up environment
cp .env.example .env

# Start development servers
npm run dev:all

Visit http://localhost:8080 to see your application running.

โœจ Features

Authentication & Security

  • Email/Password Authentication - Secure login with bcrypt password hashing
  • Google OAuth 2.0 - One-click social login integration
  • Password Reset - Email-based password recovery with secure tokens
  • Session Management - Database-backed persistent sessions
  • CSRF Protection - Built-in cross-site request forgery prevention
  • Rate Limiting - Configurable request throttling for sensitive endpoints

User Management

  • Role-Based Access Control - Admin/User roles with middleware guards
  • Profile Management - Update profile, change password, avatar upload
  • File Upload - Avatar upload with validation and secure storage

Development Experience

  • Hot Module Replacement - Vite HMR for instant frontend updates
  • Go Hot Reload - Air automatically rebuilds on Go file changes
  • Clean Architecture - Separated layers (handlers, services, repositories)
  • TypeScript Ready - Full type safety in frontend code

Production Ready

  • SQLite Optimized - WAL mode, connection pooling, production-tuned
  • Database Migrations - Goose-based schema version control
  • Docker Support - Multi-stage builds for efficient containerization
  • Systemd Ready - Production deployment with process management

๐Ÿ“š Documentation

Section Description
Getting Started Introduction, installation, and configuration
Architecture Guide Layered architecture, design patterns, and best practices
Routing & Handlers Route definitions, middleware, and request handling
Database SQLite setup, migrations, and query building
Authentication Auth flows, OAuth, sessions, and password reset
Frontend Svelte 5 components and Inertia.js integration
Deployment Development workflow, production deployment, Docker
API Reference Complete endpoint documentation
Troubleshooting Common issues and solutions

๐Ÿ“ Project Structure

laju-go/
โ”œโ”€โ”€ main.go                    # Application entry point
โ”œโ”€โ”€ app/                       # Backend Go code
โ”‚   โ”œโ”€โ”€ handlers/              # HTTP request handlers
โ”‚   โ”œโ”€โ”€ services/              # Business logic layer
โ”‚   โ”œโ”€โ”€ repositories/          # Database access layer
โ”‚   โ”œโ”€โ”€ middlewares/           # Request middleware
โ”‚   โ””โ”€โ”€ models/                # Data structures
โ”œโ”€โ”€ frontend/                  # Svelte 5 frontend
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ”œโ”€โ”€ components/        # Reusable UI components
โ”‚       โ”œโ”€โ”€ pages/             # Page components
โ”‚       โ””โ”€โ”€ lib/               # Utilities and helpers
โ”œโ”€โ”€ routes/                    # Route definitions
โ”œโ”€โ”€ migrations/                # Database migrations
โ”œโ”€โ”€ templates/                 # HTML templates
โ””โ”€โ”€ docs/                      # Documentation

๐Ÿ“– See Project Structure for a complete directory reference.

๐Ÿ› ๏ธ Tech Stack

Layer Technology Purpose
Backend Go 1.26+ Programming language
Web Framework Fiber v2 High-performance HTTP framework (fasthttp)
Database SQLite3 Embedded SQL database
Query Builder Squirrel SQL query construction
Migrations Goose Database schema management
Frontend Svelte 5 Reactive UI framework
Build Tool Vite 5 Fast build tooling and dev server
Styling Tailwind CSS 4 Utility-first CSS framework
SPA Bridge Inertia.js 3 Server-driven single-page apps
Icons Lucide Svelte Beautiful, consistent icons

๐Ÿ“ฆ Installation

Prerequisites

  • Go 1.26 or higher
  • Node.js 18 or higher
  • SQLite3 (usually pre-installed on macOS/Linux)
  • Git for version control

The easiest way to create a new Laju Go project:

# Create new project
npx create-laju-go my-app

# Navigate to project
cd my-app

# Install Air for hot reload (recommended)
go install github.com/air-verse/air@latest

# Start development
npm run dev:all

The CLI will:

  • Check for Go and Git installation
  • Let you choose package manager (npm, yarn, bun)
  • Clone the template from GitHub
  • Install all dependencies
  • Set up environment configuration

Method 2: Manual Installation

  1. Clone the repository

    git clone https://github.com/maulanashalihin/laju-go.git
    cd laju-go
    
  2. Install Go dependencies

    go mod download
    
  3. Install Node.js dependencies

    npm install
    
  4. Configure environment

    cp .env.example .env
    

    Edit .env with your settings. At minimum, set:

    APP_ENV=development
    SESSION_SECRET=your-32-character-secret-key
    
  5. Set up Google OAuth (Optional)

    • Go to Google Cloud Console
    • Create a new project and enable Google+ API
    • Create OAuth 2.0 credentials
    • Add http://localhost:8080/auth/google/callback to authorized redirect URIs
    • Copy Client ID and Secret to .env
  6. Set up Email/SMTP (Optional - for password reset)

    • Configure SMTP settings in .env
    • For Gmail, use an App Password

๐Ÿƒ Development

Start both Vite and Go servers with hot reload:

npm run dev:all

Option 2: Run Servers Separately

Terminal 1 - Vite dev server (frontend HMR):

npm run dev

Terminal 2 - Go server with hot reload:

air
# Or via npm
npm run dev:go

Option 3: Manual Run

# Go server (manual restart after changes)
go run main.go

# Vite dev server
npm run dev

Available Scripts

# Development
npm run dev          # Start Vite dev server
npm run dev:go       # Start Go server with Air hot reload
npm run dev:all      # Run both Vite and Air concurrently

# Production
npm run build        # Build frontend and Go binary
npm run serve        # Run production binary

# Testing
npm run test:run     # Run frontend tests

Development Workflow

You Edit What Happens
.svelte files Vite HMR updates instantly
.go files Air rebuilds and restarts (~1-2 sec)
.css files Hot reload (instant)
migrations/ Auto-run on server start

๐Ÿš€ Production Deployment

Quick Deploy

# Build frontend assets
npm run build

# Build Go binary
go build -o laju-go .

# Run the server
./laju-go

Docker Deployment

# Build the image
docker build -t laju-go .

# Run the container
docker run -p 8080:8080 \
  -v $(pwd)/data:/root/data \
  -v $(pwd)/storage:/root/storage \
  laju-go

Ubuntu/Debian Server

For complete production deployment instructions including systemd service setup, Nginx reverse proxy, and SSL configuration, see Production Deployment Guide.

๐Ÿ” Default Admin Setup

After your first registration, promote your user to admin via SQLite:

sqlite3 data/app.db "UPDATE users SET role = 'admin' WHERE email = '[email protected]';"

๐Ÿ—„๏ธ Database Migrations

Migrations run automatically on startup. Manual commands:

# Install goose
go install github.com/pressly/goose/v3/cmd/goose@latest

# Run all migrations
goose -dir migrations sqlite3 data/app.db up

# Check migration status
goose -dir migrations sqlite3 data/app.db status

# Rollback last migration
goose -dir migrations sqlite3 data/app.db down

๐Ÿงช Testing

# Run all tests
go test ./...

# Run tests with coverage report
go test -cover ./...

๐Ÿ“Š Performance Optimizations

SQLite Production Settings

The application includes these optimizations by default, tuned for Vultr High Frequency 1-2GB RAM:

Setting Value Benefit
journal_mode WAL Better write concurrency
synchronous NORMAL Faster writes with safety
cache_size 16MB Reduced disk I/O (optimized for 1-2GB RAM)
mmap_size 256MB NVMe memory-mapped I/O
temp_store MEMORY Faster temp table operations
busy_timeout 5000ms Automatic retry on locks
Connection Pool 15 max Efficient connection reuse

Tune for Your Server

Different RAM size? See the complete SQLite Configuration Guide for optimal settings:

Server RAM MaxOpenConns cache_size mmap_size
512MB โš ๏ธ 10 8MB 128MB
1-2GB โœ… 15 16MB 256MB
4GB 25 32MB 512MB
8GB 50 256MB 1GB
16GB+ 100 500MB+ 2GB

๐Ÿ“– Full guide: SQLite Configuration Guide - Complete reference for tuning SQLite based on RAM, CPU, storage type, and workload patterns.

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

MIT License - see LICENSE for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

Top categories

Loading Svelte Themes