upgrade your
saas boilerplate
bastion
noun /ˈbastɪən/A strong defense or fortification; a stronghold or fortress.
Battle tested and ready for production.
BastionKit contains Svelte UI Components and pre-built Supabase backends.
Working with BastoinKit is easy, just follow the docs and complete SAAS setup guides.
Discord community access for support.
project template
AI Chatbot With Authentication And Payments
7 Database Tables
15 Website Routes
project template
E-commerce Platform
10 Database Tables
20 Website Routes
project template
Social Media Dashboard
8 Database Tables
12 Website Routes
social media starter - db template
Auth ready, profiles, follow system, and user roles
Rich text, media, comments
Real-time, customizable alerts
and much more functionality included...
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
username VARCHAR(50) UNIQUE NOT NULL,
-- Personal Information
first_name VARCHAR(50),
last_name VARCHAR(50),
full_name VARCHAR(100) GENERATED ALWAYS AS (
CASE
WHEN first_name IS NULL AND last_name IS NULL THEN NULL
WHEN first_name IS NULL THEN last_name
WHEN last_name IS NULL THEN first_name
ELSE first_name || ' ' || last_name
END
) STORED,
date_of_birth DATE,
phone_number VARCHAR(20),
-- Profile & Preferences
avatar_url TEXT,
bio TEXT,
preferred_language VARCHAR(10) DEFAULT 'en',
timezone VARCHAR(50) DEFAULT 'UTC',
theme_preference VARCHAR(20) DEFAULT 'light',
email_notifications BOOLEAN DEFAULT true,
push_notifications BOOLEAN DEFAULT true,
-- Address Information
country_code CHAR(2),
state_province VARCHAR(100),
city VARCHAR(100),
postal_code VARCHAR(20),
-- Account Status
is_verified BOOLEAN DEFAULT false,
is_active BOOLEAN DEFAULT true,
is_admin BOOLEAN DEFAULT false,
email_verified_at TIMESTAMP WITH TIME ZONE,
last_login_at TIMESTAMP WITH TIME ZONE,
login_count INTEGER DEFAULT 0,
failed_login_attempts INTEGER DEFAULT 0,
-- Security
two_factor_enabled BOOLEAN DEFAULT false,
two_factor_secret VARCHAR(255),
password_changed_at TIMESTAMP WITH TIME ZONE,
recovery_email VARCHAR(255),
-- Social
referral_code VARCHAR(50) UNIQUE,
referred_by BIGINT REFERENCES users(id),
-- Timestamps
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
-- Premium Features
subscription_tier VARCHAR(50) DEFAULT 'free',
subscription_ends_at TIMESTAMP WITH TIME ZONE,
is_premium BOOLEAN DEFAULT false,
);
-- Basic user details with active subscription status
SELECT
id,
username,
email,
full_name,
subscription_tier,
CASE
WHEN subscription_ends_at > CURRENT_TIMESTAMP THEN true
ELSE false
END as has_active_subscription,
created_at
FROM users
WHERE is_active = true
AND deleted_at IS NULL
ORDER BY created_at DESC
LIMIT 10;
-- User engagement metrics
SELECT
DATE_TRUNC('month', created_at) as month,
COUNT(*) as new_users,
COUNT(*) FILTER (WHERE email_verified_at IS NOT NULL) as verified_users,
COUNT(*) FILTER (WHERE last_login_at > CURRENT_TIMESTAMP - INTERVAL '30 days') as active_users,
ROUND(AVG(login_count)::numeric, 2) as avg_logins
FROM users
WHERE deleted_at IS NULL
GROUP BY DATE_TRUNC('month', created_at)
ORDER BY month DESC;
-- Many more queries included in the full template :)
-- Indexes for better query performance
CREATE INDEX users_email_idx ON users (email) WHERE deleted_at IS NULL;
CREATE INDEX users_username_idx ON users (username) WHERE deleted_at IS NULL;
CREATE INDEX users_created_at_idx ON users (created_at);
CREATE INDEX users_subscription_ends_at_idx ON users (subscription_ends_at)
WHERE subscription_tier != 'free';
template preview
social media starter