← Back to all products
$29
SaaS Boilerplate
SaaS Boilerplate with user management, RBAC, settings, and multi-tenancy in pure Python.
PythonMarkdown
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 10 files
saas-boilerplate/
├── LICENSE
├── README.md
├── examples/
│ └── basic_example.py
├── free-sample.zip
├── guide/
│ ├── 01_features.md
│ ├── 02_quick-start.md
│ ├── 03_configuration.md
│ └── 04_license.md
├── index.html
└── src/
└── main.py
📖 Documentation Preview README excerpt
SaaS Boilerplate
A complete Python SaaS application boilerplate with user management, role-based access control, settings, and multi-tenancy scaffolding. Your starting point for any SaaS product.
Features
- User management — Registration, authentication, password hashing (PBKDF2-HMAC-SHA256)
- Role-based access control — Admin, member, and viewer roles with permission checks
- Multi-tenant scaffolding — Tenant context, per-tenant data isolation
- Application settings — JSON-persisted settings with defaults and validation
- Session management — Token-based sessions with expiration and rotation
- Audit logging — Structured log of all user and system operations
- HTTP server — Built-in routing with middleware pipeline
- Configuration — Environment variables or JSON config file
Requirements
- Python 3.10+
- No external dependencies (stdlib only)
Quick Start
# Start the server with demo data
python src/main.py --init-demo
# Start on a custom port
python src/main.py --port 9000
# Start clean (no demo data)
python src/main.py
Then open http://localhost:8000 and try the API:
# Register a user
curl -X POST http://localhost:8000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email": "admin@example.com", "password": "changeme123", "name": "Admin"}'
# Login
curl -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@example.com", "password": "changeme123"}'
# List users (requires auth token from login response)
curl http://localhost:8000/api/users \
-H "Authorization: Bearer <token>"
API Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /api/auth/register | Register a new user |
| POST | /api/auth/login | Login and receive session token |
| POST | /api/auth/logout | Invalidate session |
| GET | /api/users | List users (admin only) |
| GET | /api/users/:id | Get user details |
... continues with setup instructions, usage examples, and more.
📄 Code Sample .py preview
src/main.py
#!/usr/bin/env python3
"""
SaaS Boilerplate — Complete SaaS Application Foundation
========================================================
A production-ready SaaS application boilerplate with user management,
role-based access control, multi-tenancy scaffolding, settings, session
management, and audit logging. Built entirely on Python's standard library.
Zero dependencies. Just run: python3 main.py
Part of the SaaS Starter collection by DataNest.
License: MIT
"""
from __future__ import annotations
import argparse
import hashlib
import hmac
import json
import logging
import os
import secrets
import time
import uuid
from dataclasses import asdict, dataclass, field
from datetime import datetime, timezone
from http.server import BaseHTTPRequestHandler, HTTPServer
from pathlib import Path
from typing import Any, Optional
from urllib.parse import parse_qs, urlparse
# ---------------------------------------------------------------------------
# Configuration
# ---------------------------------------------------------------------------
DEFAULT_HOST = "0.0.0.0"
DEFAULT_PORT = 8000
SESSION_TTL_SECONDS = 86400 # 24 hours
MAX_USERS_PER_TENANT = 50
DATA_DIR = Path("./data")
# Secret key for session signing — auto-generated if not provided.
# In production, set the SAAS_SECRET environment variable to a stable value
# so sessions survive server restarts.
SECRET_KEY = os.environ.get("SAAS_SECRET", secrets.token_hex(32))
logging.basicConfig(
level=logging.INFO,
# ... 584 more lines ...