Developer Getting Started
This guide walks you through setting up the StudioBrain development environment for contributing to the backend, frontend, or SDK.
Prerequisites
| Tool | Version | Purpose |
|---|---|---|
| Rust | 1.96.0 (pinned by rust-toolchain.toml) | Backend server (sb-server) |
| Node.js | 20.19+ | Frontend (Next.js), TypeScript SDK |
| npm | 10+ | Package manager (npm workspaces; no pnpm lockfile) |
| SQLite dev headers | 3.40+ | libsqlite3-dev on Debian/Ubuntu |
| Git | 2.30+ | Version control |
Optional:
| Tool | Version | Purpose |
|---|---|---|
| Docker | 24+ | 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-coreBackend (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 backendThe 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 sqliteThe 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
| Variable | Default | Description |
|---|---|---|
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 |
PORT | 8000 | Listen 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_FORMAT | text (debug) / json (release) | json or text |
CORS_ORIGINS | http://localhost:3000,http://localhost:1420 | Comma-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=frontendThe 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:8000TypeScript 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/sdkThe 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:
- Add the pure function to the SDK first
- Write tests in the SDK
- Consume it from the frontend via import
- 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 type | Location | Build |
|---|---|---|
| New API endpoint | crates/sb-server/src/routes/ | cargo build |
| Entity type logic | crates/sb-core/src/ | cargo build |
| Storage queries | crates/sb-storage/src/ | cargo build |
| Frontend page/component | frontend/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=frontendOpen http://localhost:3100 in your browser.
Docker (Self-Hosted)
cp .env.example .env
docker compose -f docker/docker-compose.yml up -dThis 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.
| Area | Path / setup | Notes |
|---|---|---|
| Cloud SaaS | packages/cloudflare-worker/sb-server-worker/; see its README.md | The live API is the Cloudflare sb-server-worker; enterprise Rust code lives in crates/sb-enterprise* |
| Desktop and mobile | clients/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 AI | crates/ai/; use Cargo with that directory’s Cargo.toml | Commercial Rust AI crates for native desktop/enterprise use |
| SaaS AI | packages/cloudflare-worker/sb-ai-worker/ and packages/ai-sdk/ | TypeScript Cloudflare Worker and shared provider adapters |
| Accounts | cd packages/accounts-frontend && npm install && npm run dev | Fenced accounts UI; the TypeScript sb-accounts-worker API lives in packages/cloudflare-worker/worker/, with billing in packages/cloudflare-worker/accounts-billing/ |
Next Steps
- REST API Reference — Full endpoint documentation
- Layout System Architecture — How entity forms are rendered
- Widget Registry Reference — Available form widgets
- Template Authoring — Creating custom entity types