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"
- macOS/Linux:
- 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 usesuv 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:
SNACKBASE_SECRET_KEY- Generate a secure random stringSNACKBASE_DATABASE_URL- Switch to PostgreSQLSNACKBASE_CORS_ORIGINS- Add your frontend URL
1.5 Initialize the Database
- Creates the database file at
./sb_data/snackbase.db - Runs Alembic migrations to set up all tables
- Creates the
systemaccount (ID:SY0000) for superadmin operations
1.6 Configure Email (Optional but Recommended)
SnackBase requires email configuration for user email verification. Choose one of these options: Option A: Use a Development SMTP Server (Recommended for Testing).env:
1.7 Create a Superadmin User
- 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
1.9 Start the Frontend (New Terminal)
Open a new terminal and start the React development server: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(orSY0000) - Email: The superadmin email you created
- Password: The superadmin password you created
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:- Open
http://localhost:8025in your browser - Find the verification email
- Click the verification link
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)
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)
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:- “Getting Started with SnackBase” (status:
published) - “Draft Post About API Design” (status:
draft) - “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
admin role.
5.3 Create a New Role
Click + New Role. Enter:- Name:
editor - Description:
Can create and edit posts, but cannot delete
5.4 Configure Permissions
On the role detail page foreditor:
- Click + Add Permission
- Configure:
- Collection:
posts - Create: Enabled
- Read: Enabled
- Update: Enabled
- Delete: Disabled
- Collection:
5.5 Create a Read-Only Role
Repeat the process to create aviewer 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:- Email:
[email protected] - Password:
EditorPass123! - Role:
editor - Active: Yes
6.3 Create a Viewer User
Repeat to create a viewer user:- Email:
[email protected] - Password:
ViewerPass123! - Role:
viewer
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
F12orCmd+Option+I(Mac) - Go to the Application or Storage tab
- Find Local Storage →
http://localhost:5173 - Copy the value of
access_token
7.2 Test the API with curl
Open a new terminal and try fetching all posts: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:- Account:
system - Email:
[email protected] - Password:
EditorPass123!
8.2 Verify Edit Capabilities
Navigate to Records → posts. 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: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:
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:
.env:
Email Verification Problems
Problem: Users can’t log in due to unverified email Solution: Manually verify the user via API:- Verify email settings in
.env - If using MailHog, ensure it’s running (
mailhogcommand) - 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 byaccount_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
Gotcha 3: Built-in Hooks Auto-Set Timestamps
Every record automatically getscreated_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:- Deployment Guide - Deploy SnackBase in development and production
- Authentication Model - Deep dive into auth, multi-account users, and tokens
- Multi-Tenancy Model - How accounts and data isolation work
- Hooks System - Automate workflows with event-driven hooks
- API Examples - Practical API usage examples