Prerequisites
- Bun (recommended) or Node.js
- Docker and Docker Compose
- API keys for the AI providers you want to use (Anthropic, OpenAI, or Google)
Setup
Configure environment variables
/.env and fill in your API keys and configuration. At minimum you need:DATABASE_URL— PostgreSQL connection stringREDIS_URL— Redis connection stringANTHROPIC_API_KEY— For ClaudeBETTER_AUTH_SECRET— Authentication secretBAP_CLOUD_API_BASE_URL— Bap Cloud base URL for delegated loginBAP_CLOUD_INSTANCE_API_KEY— Shared control-plane instance key
Docker Compose (all-in-one)
For a fully containerized setup backed by published GHCR images (app + worker + DB + Redis + MinIO), use the bundled compose file atdocker/compose/selfhost.yml:
APP_URLBETTER_AUTH_SECRETENCRYPTION_KEYBAP_SERVER_SECRETBAP_CLOUD_API_BASE_URLBAP_CLOUD_INSTANCE_API_KEYOPENAI_API_KEYANTHROPIC_API_KEY
/.env.selfhost:
http://localhost:8114.
Self-hosted end-user login is delegated to Bap Cloud. Configure the same
BAP_CLOUD_INSTANCE_API_KEY on the cloud deployment and on each self-hosted deployment
that should trust it.
- Set
E2B_API_KEYandE2B_DAYTONA_SANDBOX_NAMEto use E2B cloud sandboxes. - Or set
DAYTONA_API_KEY(plus optionalDAYTONA_API_URL/DAYTONA_SERVER_URL/DAYTONA_TARGET) to use Daytona sandboxes. - Or set
SANDBOX_DEFAULT=dockerto use local Docker-based sandboxes. - Published images also get a daily
YYYYMMDD-Ntag such as20260310-1. - Use a
sha-...tag instead ofmainif you want to test a specific published build. - The published
appimage does not include custom browser-sideVITE_POSTHOG_*values; builddocker/images/web/Dockerfileyourself if you need them.
Background worker
Bap uses BullMQ for generation execution and background jobs. Chat and coworker runs are executed by the worker, so start it in a separate terminal:/.env so the worker uses the same local environment as bun dev.
WebSocket server
The WebSocket server still runs separately from the web app:/.env.
Useful commands
| Command | Description |
|---|---|
bun dev | Start the web app, worker, and WS runtime |
bun dev:web | Start only the web app |
bun dev:worker | Start only the worker |
bun dev:ws | Start only the WS runtime |
bun build | Production build |
bun check | Run workspace checks |
bun test | Run workspace tests |
bun start:worker | Start the background job worker using /.env |
bun start:ws | Start the WebSocket server using /.env |
bun run --cwd packages/db db:push | Push schema changes to the database |
bun run --cwd packages/db db:studio | Open Drizzle Studio (database browser) |
bun run --cwd packages/db db:seed | Seed the database |
Tech stack
| Layer | Technology |
|---|---|
| Web | TanStack Start, React 19, Tailwind CSS 4 |
| API | ORPC, Better Auth |
| Database | PostgreSQL, Drizzle ORM |
| AI | Anthropic Claude, OpenAI, Google Gemini |
| Queue | BullMQ, Redis |
| Storage | S3 / MinIO |
| Sandbox | E2B, Daytona, Docker |
