DeveloperDeveloper Getting Started

Developer Getting Started

This guide walks you through setting up the StudioBrain development environment for contributing to the backend, frontend, or SDK.


Prerequisites

ToolVersionPurpose
Rust1.96.0 (pinned by rust-toolchain.toml)Backend server (sb-server)
Node.js20.19+Frontend (Next.js), TypeScript SDK
npm10+Package manager (npm workspaces; no pnpm lockfile)
SQLite dev headers3.40+libsqlite3-dev on Debian/Ubuntu
Git2.30+Version control

Optional:

ToolVersionPurpose
Docker24+Self-hosted compose stack (docker/docker-compose.yml)

Core is SQLite-only. There is no Postgres or Python backend to install.


Clone the Repo

git clone https://github.com/BiloxiStudios/studiobrain-core.git
cd studiobrain-core

Backend (Rust)

The backend is a Rust workspace. The main crates are:

crates/
  sb-core/     — Pure types (Entity, Template, etc.)
  sb-server/   — Axum HTTP server (~100 endpoints)
  sb-storage/  — SQLite storage backend

The workspace also contains sb-thumbnails, sb-inference-client, the plugin crates (sb-plugin-trait, sb-plugin-storage, sb-plugin-wasmtime) and sb-r2-poc (see the root Cargo.toml).

Build

# Build the self-hosted server (SQLite backend)
cargo build -p sb-server --features sqlite
 
# Run tests
cargo test --workspace
 
# Run the server
JWT_SECRET=dev-secret \
DATABASE_URL='sqlite:/tmp/studiobrain-dev.db?mode=rwc' \
cargo run -p sb-server --features sqlite

The server starts on http://localhost:8000 (override with PORT or --port). First-run creates an empty SQLite database. Register the admin user with POST /api/auth/register.

Verify

# Health check
curl http://localhost:8000/health
 
# Register first user (creates admin)
curl -X POST http://localhost:8000/api/auth/register \
  -H 'Content-Type: application/json' \
  -d '{"email": "admin@local.dev", "password": "devpass123"}'
 
# Login
curl -X POST http://localhost:8000/api/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"email": "admin@local.dev", "password": "devpass123"}'

Key Environment Variables

VariableDefaultDescription
JWT_SECRET(none)HS256 signing key for self-hosted mode (set this or a JWT public key)
DATABASE_URL(required)SQLite URL, e.g. sqlite:./data.db?mode=rwc
PORT8000Listen port (or --port); bind address defaults to 0.0.0.0, set --host to change
CONTENT_BASE_PATH(see --content-path)Markdown content root
LOG_FORMATtext (debug) / json (release)json or text
CORS_ORIGINShttp://localhost:3000,http://localhost:1420Comma-separated allowed origins

Frontend (Next.js)

The frontend is a Next.js 15 app with React 19, TypeScript, and Tailwind CSS.

# From the repo root (npm workspaces; private @biloxistudios packages
# need NODE_AUTH_TOKEN with packages:read)
npm ci --workspace frontend --workspace packages/sdk --include-workspace-root
 
# Start dev server
npm run dev --workspace=frontend

The frontend starts on http://localhost:3100 and proxies API routes to BACKEND_URL (falls back to NEXT_PUBLIC_API_URL, then http://localhost:8201). Set it to http://localhost:8000 when running sb-server with its default port.

Configure API URL

The frontend connects to the backend via BACKEND_URL / NEXT_PUBLIC_API_URL:

# frontend/.env.local
BACKEND_URL=http://localhost:8000
NEXT_PUBLIC_API_URL=http://localhost:8000

TypeScript SDK

The SDK (@biloxistudios/studiobrain-sdk) contains all shared business logic. It lives at packages/sdk/.

# After the root install above
npm test --workspace packages/sdk
npm run build --workspace packages/sdk

The frontend consumes the SDK as the @biloxistudios/studiobrain-sdk workspace package.

SDK Rules

The SDK is the canonical source of truth for pure business logic. When adding new logic:

  1. Add the pure function to the SDK first
  2. Write tests in the SDK
  3. Consume it from the frontend via import
  4. Backend (Rust) implementations must produce identical output for the same input

See the TypeScript SDK reference for the full module list.


Project Structure

studiobrain-core/
  crates/
    sb-core/          — Rust: pure types, no framework deps
    sb-server/        — Rust: Axum HTTP server
    sb-storage/       — Rust: SQLite backend
    (plus sb-thumbnails, sb-inference-client, sb-plugin-*, sb-r2-poc)
  docker/             — Self-hosted Dockerfiles + compose
  frontend/           — Next.js 15 web frontend
  packages/
    sdk/              — TypeScript SDK (@biloxistudios/studiobrain-sdk)
    sync-contract/    — Sync contract package
    plugin-sdk/       — Plugin SDK (WIT)

What lives where

Change typeLocationBuild
New API endpointcrates/sb-server/src/routes/cargo build
Entity type logiccrates/sb-core/src/cargo build
Storage queriescrates/sb-storage/src/cargo build
Frontend page/componentfrontend/src/npm run dev --workspace=frontend
Business logic (validation, formatting)packages/sdk/src/npm run build --workspace packages/sdk

Running the Full Stack Locally

# Terminal 1: Backend
JWT_SECRET=dev-secret \
DATABASE_URL='sqlite:/tmp/studiobrain-dev.db?mode=rwc' \
cargo run -p sb-server --features sqlite
 
# Terminal 2: Frontend
BACKEND_URL=http://localhost:8000 npm run dev --workspace=frontend

Open http://localhost:3100 in your browser.


Docker (Self-Hosted)

cp .env.example .env
docker compose -f docker/docker-compose.yml up -d

This builds docker/Dockerfile.selfhosted (Rust sb-server + SQLite, port 8201) and the Next.js frontend (port 3100). Open http://localhost:3100.


Commercial Development

Cloud, desktop/mobile, AI, and accounts development lives in studiobrain-cloud. The former studiobrain-app, studiobrain-ai, and studiobrain-accounts repositories are archived. Use the paths below within your studiobrain-cloud checkout; there is no active Python backend to install.

AreaPath / setupNotes
Cloud SaaSpackages/cloudflare-worker/sb-server-worker/; see its README.mdThe live API is the Cloudflare sb-server-worker; enterprise Rust code lives in crates/sb-enterprise*
Desktop and mobileclients/desktop/ (see README.md) and clients/mobile/ (see dev:android / dev:ios in package.json)Tauri 2.0 desktop and Tauri Mobile (iOS + Android), with a Rust desktop sidecar
Native AIcrates/ai/; use Cargo with that directory’s Cargo.tomlCommercial Rust AI crates for native desktop/enterprise use
SaaS AIpackages/cloudflare-worker/sb-ai-worker/ and packages/ai-sdk/TypeScript Cloudflare Worker and shared provider adapters
Accountscd packages/accounts-frontend && npm install && npm run devFenced accounts UI; the TypeScript sb-accounts-worker API lives in packages/cloudflare-worker/worker/, with billing in packages/cloudflare-worker/accounts-billing/

Next Steps