Architecture
Understand the relay protocol, event flow, and component design.
This guide walks you through setting up a local PizzaPi development environment, running the dev servers, and contributing changes.
You’ll need these installed before you start:
| Tool | Why |
|---|---|
| Bun ≥ 1.1 | Runtime, package manager, test runner, and bundler. PizzaPi uses Bun exclusively — not Node, npm, yarn, or pnpm. |
| Redis | The relay server buffers session events in Redis. Run it locally or via Docker. |
| Docker (optional) | Only needed if you prefer the containerized dev setup, or want to test production builds. |
| Git | Version control. You know this one. |
Clone the repository
git clone https://github.com/Pizzaface/PizzaPi.gitcd PizzaPiInstall dependencies
bun installThis also applies any patches from the patches/ directory automatically.
Run database migrations
bun run migrateThis creates (or updates) the SQLite database at packages/server/auth.db.
Start Redis in one terminal:
redis-serverThen start the dev servers:
bun run devThis launches both servers with hot-reload via concurrently:
| Port | Service | Details |
|---|---|---|
| 7492 | Bun API server | HTTP + WebSocket relay, hot-reloads on save |
| 5173 | Vite UI dev server | React app with HMR |
Open http://localhost:5173 in your browser for the UI (it proxies API calls to :7492).
If you prefer containers, use the dev profile:
docker compose -f docker/compose.yml --profile dev upThis starts Redis, the API server, and the Vite UI server in containers with the repo mounted as a volume. Same ports as above.
packages/ protocol/ Shared TypeScript types for the relay wire protocol tools/ Shared agent tools (bash, read-file, write-file, search) server/ Bun HTTP + WebSocket relay server (auth, sessions, push notifications) ui/ React 19 PWA web interface (Vite, TailwindCSS v4, Radix UI / shadcn) cli/ CLI wrapper — launches pi with PizzaPi extensions and the runner daemon docs/ This documentation site (Astro Starlight) npm/ npm distribution — builds & publishes @pizzapi packages
docker/ Docker Compose (redis + server services)patches/ Bun patches for upstream pi packages (auto-applied on bun install)PizzaPi is a monorepo with ordered package dependencies. The build must follow this sequence:
protocol → tools → server → ui → clidocs and npm are independent and can be built separately.
# Build everything (in correct order)bun run build
# Build individual packagesbun run build:protocolbun run build:toolsbun run build:serverbun run build:uibun run build:cli
# Build the docs sitebun run build:docs
# Type-check all packages at oncebun run typecheck
# Clean all dist/ directoriesbun run clean# Full dev environment (API server + Vite UI, hot-reload)bun run dev
# Run just the server in dev modebun run dev:server
# Run just the UI in dev modebun run dev:ui
# Run the CLI from sourcebun run dev:cli
# Run the runner daemon from sourcebun run dev:runner
# Dev the docs sitebun run dev:docsPizzaPi uses Bun’s built-in test runner — no additional frameworks needed.
# Run all testsbun run test
# Run tests for a specific package (from the repo root)bun test packages/serverbun test packages/toolsbun test packages/uibun test packages/clifoo.ts → foo.test.tspackages/<pkg>/tests/describe, test, and expect from bun:test| Package | What’s tested |
|---|---|
| server | Validation, security, sessions store, attachments, API routes, pruning |
| ui | Message grouping, session viewer utils, path utilities |
| tools | Toolkit helpers, pi compatibility layer |
| cli | Patch application and runtime behavior |
The relay server uses SQLite (via Kysely) for user accounts and session metadata.
# Run pending migrationsbun run migrateThe database file lives at packages/server/auth.db. After schema changes, always run migrations.
PizzaPi patches some upstream pi packages to add relay streaming and other features. Patches live in the patches/ directory and are applied automatically during bun install.
Never edit files in node_modules directly. If you need to change upstream behavior:
bun patchpatches/bun install (the patch is re-applied cleanly)| Layer | Technology |
|---|---|
| Runtime & package manager | Bun |
| Language | TypeScript (strict mode, ESM throughout) |
| Server | Bun.serve, better-auth, Kysely + SQLite, Redis, web-push |
| UI | React 19, Vite 6, TailwindCSS v4, Radix UI, shadcn/ui |
| Agent core | @mariozechner/pi-coding-agent |
| Docs | Astro Starlight |
| Deployment | Docker Compose |
bun run dev. The server restarts on file changes; the UI uses Vite’s HMR.redis-server is up (or docker compose up redis).bun run typecheck to get a full picture across all packages at once.bun run dev:docs at http://localhost:4321/PizzaPi/.protocol or tools, rebuild those before building downstream packages.Architecture
Understand the relay protocol, event flow, and component design.
Environment Variables
Server-side configuration options for development and production.
Self-Hosting
Build and deploy the production Docker image.