Skip to main content
Get up and running with SnackBase in 5 minutes. This guide will walk you through the essential steps to set up your instance, create your first collection, add data, set up permissions, and make API requests.

Prerequisites

Before you begin, ensure you have:
  • Python 3.12+ installed
  • Node.js 18+ installed (for the admin UI)
  • uv package manager installed
    • macOS/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh
    • Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
  • Git installed (for cloning the repository)
Windows Users: If you don’t have Node.js installed, download it from nodejs.org. For Python, use the Microsoft Store or python.org.

Step 1: Install and Start SnackBase

1.1 Clone the Repository

1.2 Install Backend Dependencies

SnackBase uses uv for fast, reliable package management:

1.3 Install Frontend Dependencies

Navigate to the UI directory and install Node.js dependencies:

1.4 Configure Environment

Create a .env file from the example template:
For local development, the default values work fine. However, for production, update at minimum:
  • SNACKBASE_SECRET_KEY - Generate a secure random string
  • SNACKBASE_DATABASE_URL - Switch to PostgreSQL
  • SNACKBASE_CORS_ORIGINS - Add your frontend URL

1.5 Initialize the Database

This command:
  • Creates the database file at ./sb_data/snackbase.db
  • Runs Alembic migrations to set up all tables
  • Creates the system account (ID: SY0000) for superadmin operations
SnackBase requires email configuration for user email verification. Choose one of these options: Option A: Use a Development SMTP Server (Recommended for Testing)
Then update your .env:
Option B: Use Resend (Recommended for Production) Sign up at resend.com and get an API key:
Option C: Use AWS SES

1.7 Create a Superadmin User

You’ll be prompted to enter:
  • Email address (e.g., [email protected])
  • Password (minimum 8 characters, recommended: mix of letters, numbers, symbols)
  • Password confirmation
The superadmin account will require email verification if email is configured. You can verify the email via the API or auto-verify superadmin emails in development mode.

1.8 Start the Backend Server

You should see output indicating the server is running:

1.9 Start the Frontend (New Terminal)

Open a new terminal and start the React development server:
You should see:

1.10 Access the Admin UI

Open your browser and navigate to:

Step 2: Log In to the Admin UI

2.1 Enter Your Credentials

On the login page, enter:
  • Account: system (or SY0000)
  • Email: The superadmin email you created
  • Password: The superadmin password you created
Click Sign In.
The superadmin account is always linked to the system account (ID: SY0000). Use “system” as the account field when logging in.

2.2 Verify Your Email (If Required)

If email verification is enabled, you’ll see a message asking you to verify your email. For Development with MailHog:
  1. Open http://localhost:8025 in your browser
  2. Find the verification email
  3. Click the verification link
To Skip Verification in Development: Use the admin API to verify your email:

2.3 Welcome to the Dashboard

After logging in (and verifying your email if required), you’ll see the main dashboard with:
  • Sidebar navigation on the left
  • Statistics cards (collections, records, users, etc.)
  • Recent activity or quick actions

Step 3: Create Your First Collection

A Collection is like a table in a traditional database. It defines the structure of your data with fields and types.

3.1 Navigate to Collections

Click Collections in the sidebar.

3.2 Create a New Collection

Click the + New Collection button. A modal or form will appear. Enter:
  • Name: posts (this will become the API endpoint: /api/v1/records/posts)
  • Description: Blog posts and articles (optional)
Click Create.

3.3 Add Fields to Your Collection

After creating the collection, you’ll see the collection detail page. Now let’s add fields. Click + Add Field and add the following fields:

Step 4: Add Your First Records

Now that your collection is set up, let’s add some data.

4.1 Navigate to Records

Click Records in the sidebar, then select the posts collection.

4.2 Create a Record

Click + New Record. Fill in the form:
  • title: My First Blog Post
  • content: This is my first post using SnackBase!
  • status: published
  • published_at: Select today’s date
  • views: Leave as 0 (default)
Click Save.

4.3 View Your Record

After saving, you’ll see your record in the data table.

4.4 Add More Records

Create a few more records to have some test data:
  1. “Getting Started with SnackBase” (status: published)
  2. “Draft Post About API Design” (status: draft)
  3. “Archived Announcement” (status: archived)

Step 5: Set Up Roles and Permissions

SnackBase uses Role-Based Access Control (RBAC) to manage who can do what with your data.

5.1 Navigate to Roles

Click Roles in the sidebar.

5.2 Understand Default Roles

By default, you’ll see:
  • admin - Full access to all collections and operations
The superadmin user you created has the admin role.

5.3 Create a New Role

Click + New Role. Enter:
  • Name: editor
  • Description: Can create and edit posts, but cannot delete
Click Create.

5.4 Configure Permissions

On the role detail page for editor:
  1. Click + Add Permission
  2. Configure:
    • Collection: posts
    • Create: Enabled
    • Read: Enabled
    • Update: Enabled
    • Delete: Disabled
Click Save.

5.5 Create a Read-Only Role

Repeat the process to create a viewer role:
  • Name: viewer
  • Collection: posts
  • Read: Enabled only

Step 6: Create Additional Users

Now let’s create users with different roles to test permissions.

6.1 Navigate to Users

Click Users in the sidebar.

6.2 Create an Editor User

Click + New User. Enter: Click Create.

6.3 Create a Viewer User

Repeat to create a viewer user:

Step 7: Make Your First API Request

SnackBase automatically generates REST APIs for your collections. Let’s test it!

7.1 Get Your Access Token

Open your browser’s developer tools:
  • Press F12 or Cmd+Option+I (Mac)
  • Go to the Application or Storage tab
  • Find Local Storagehttp://localhost:5173
  • Copy the value of access_token

7.2 Test the API with curl

Open a new terminal and try fetching all posts:
Replace YOUR_ACCESS_TOKEN with the token you copied.

7.3 Create a Record via API

Create a new post using the API:

7.4 Explore the Interactive API Docs

SnackBase includes auto-generated API documentation powered by Swagger UI. Open in your browser:

Step 8: Test Permissions

Let’s verify that the permission system works correctly.

8.1 Log In as Editor

Open an incognito/private window and navigate to:
Log in as:

8.2 Verify Edit Capabilities

Navigate to Recordsposts. You should see:
  • Edit buttons on existing records
  • No Delete buttons (editor role cannot delete)

8.3 Test Delete Restriction

Try to delete a record using the API with editor credentials:
You should receive a 403 Forbidden error.

Development Commands

Backend Commands

Frontend Commands

Troubleshooting

Database Errors

Problem: sqlite3.OperationalError: unable to open database file Solution: Ensure the sb_data directory exists and is writable:
Windows: Create the folder manually in File Explorer if needed.

Port Conflicts

Problem: Error: listen tcp 0.0.0.0:8000: bind: address already in use Solution: Another process is using port 8000. Find and stop it: macOS/Linux:
Windows:
Alternatively, change the port in .env:

Email Verification Problems

Problem: Users can’t log in due to unverified email Solution: Manually verify the user via API:
Problem: Verification emails not being sent Solution: Check your email configuration:
  1. Verify email settings in .env
  2. If using MailHog, ensure it’s running (mailhog command)
  3. Check server logs for email errors

API Endpoints Reference

SnackBase provides 20+ API routers:

Common Gotchas & Tips

Gotcha 1: Account Context in API Requests

When making API requests, your user is always associated with an account. All data is isolated by account_id, even if you’re using a single account setup. Solution: Be aware that filtering by account happens automatically. You don’t need to specify account_id in your queries.

Gotcha 2: Collection Names Become URL Endpoints

The collection name you choose becomes part of the API URL:
  • Collection blog-posts/api/v1/records/blog-posts
  • Collection posts/api/v1/records/posts
Solution: Use simple, URL-friendly names with lowercase letters, numbers, and hyphens.

Gotcha 3: Built-in Hooks Auto-Set Timestamps

Every record automatically gets created_at and updated_at timestamps. You don’t need to add these as fields. Solution: Don’t create manual timestamp fields—they’re built-in!

Gotcha 4: Superadmin vs Admin

Solution: Use superadmin only for system-level operations. Use admin roles for day-to-day account management.

Gotcha 5: Permission Caching

Permissions are cached for 5 minutes. If you change a role’s permissions, it may take up to 5 minutes to take effect. Solution: Wait 5 minutes or restart the server after permission changes for immediate effect.

Production Considerations

Before deploying to production, review these important security and configuration items:

Security Settings

Database Setup

For production, switch from SQLite to PostgreSQL:

Environment Variables

Key production environment variables:

Next Steps

Congratulations! You’ve completed the SnackBase Quick Start. Here’s what to explore next: