Skip to main content

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

1

Clone the repository

git clone https://github.com/baptistecolle/bap.git
cd bap
2

Install dependencies

bun install
3

Start local services

This starts PostgreSQL, Redis, and MinIO (S3-compatible storage):
docker compose -f docker/compose/dev.yml up -d
4

Configure environment variables

cp .env.example .env
Edit /.env and fill in your API keys and configuration. At minimum you need:
  • DATABASE_URL — PostgreSQL connection string
  • REDIS_URL — Redis connection string
  • ANTHROPIC_API_KEY — For Claude
  • BETTER_AUTH_SECRET — Authentication secret
  • BAP_CLOUD_API_BASE_URL — Bap Cloud base URL for delegated login
  • BAP_CLOUD_INSTANCE_API_KEY — Shared control-plane instance key
5

Set up the database

Push the schema to your database:
bun run --cwd packages/db db:push
Optionally seed with initial data:
bun run --cwd packages/db db:seed
6

Start the app

bun dev
This starts the web app, worker, and WS runtime from the monorepo root. The web app will be available at http://localhost:3000.

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 at docker/compose/selfhost.yml:
cp .env.selfhost.example .env.selfhost
Fill in at least:
  • APP_URL
  • BETTER_AUTH_SECRET
  • ENCRYPTION_KEY
  • BAP_SERVER_SECRET
  • BAP_CLOUD_API_BASE_URL
  • BAP_CLOUD_INSTANCE_API_KEY
  • OPENAI_API_KEY
  • ANTHROPIC_API_KEY
Optionally pin the image tags in /.env.selfhost:
BAP_APP_IMAGE=ghcr.io/baptistecolle/bap-web:main
BAP_WORKER_IMAGE=ghcr.io/baptistecolle/bap-worker:main
Then pull, migrate, and start:
docker compose -f docker/compose/selfhost.yml --env-file .env.selfhost pull
docker compose -f docker/compose/selfhost.yml --env-file .env.selfhost run --rm migrate
docker compose -f docker/compose/selfhost.yml --env-file .env.selfhost up -d
Then open 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_KEY and E2B_DAYTONA_SANDBOX_NAME to use E2B cloud sandboxes.
  • Or set DAYTONA_API_KEY (plus optional DAYTONA_API_URL / DAYTONA_SERVER_URL / DAYTONA_TARGET) to use Daytona sandboxes.
  • Or set SANDBOX_DEFAULT=docker to use local Docker-based sandboxes.
  • Published images also get a daily YYYYMMDD-N tag such as 20260310-1.
  • Use a sha-... tag instead of main if you want to test a specific published build.
  • The published app image does not include custom browser-side VITE_POSTHOG_* values; build docker/images/web/Dockerfile yourself 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:
bun start:worker
This command loads /.env so the worker uses the same local environment as bun dev.

WebSocket server

The WebSocket server still runs separately from the web app:
bun start:ws
This command also loads /.env.

Useful commands

CommandDescription
bun devStart the web app, worker, and WS runtime
bun dev:webStart only the web app
bun dev:workerStart only the worker
bun dev:wsStart only the WS runtime
bun buildProduction build
bun checkRun workspace checks
bun testRun workspace tests
bun start:workerStart the background job worker using /.env
bun start:wsStart the WebSocket server using /.env
bun run --cwd packages/db db:pushPush schema changes to the database
bun run --cwd packages/db db:studioOpen Drizzle Studio (database browser)
bun run --cwd packages/db db:seedSeed the database

Tech stack

LayerTechnology
WebTanStack Start, React 19, Tailwind CSS 4
APIORPC, Better Auth
DatabasePostgreSQL, Drizzle ORM
AIAnthropic Claude, OpenAI, Google Gemini
QueueBullMQ, Redis
StorageS3 / MinIO
SandboxE2B, Daytona, Docker