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/app
2

Install dependencies

bun install
3

Start local services

This starts PostgreSQL, Redis, and MinIO (S3-compatible storage):
docker compose 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
5

Set up the database

Push the schema to your database:
bun db:push
Optionally seed with initial data:
bun db:seed
6

Start the app

bun dev
The app will be available at http://localhost:3000.

Docker Compose (all-in-one)

For a fully containerized setup (app + worker + WS server + DB + Redis + MinIO), save the file below as docker-compose.selfhost.yml in bap/app, then run:
docker compose -f docker-compose.selfhost.yml up -d --build
Then open http://localhost:3000.

docker-compose.selfhost.yml

name: bap-selfhost

services:
  app:
    build: .
    container_name: bap-app
    env_file: .env
    environment:
      NODE_ENV: production
      PORT: "3000"
      HOSTNAME: "0.0.0.0"
    ports:
      - "3000:3000"
    depends_on:
      database:
        condition: service_healthy
      redis:
        condition: service_healthy
      minio:
        condition: service_healthy
    restart: unless-stopped

  worker:
    build: .
    container_name: bap-worker
    env_file: .env
    command: ["bun", "worker"]
    depends_on:
      database:
        condition: service_healthy
      redis:
        condition: service_healthy
    restart: unless-stopped

  ws:
    build: .
    container_name: bap-ws
    env_file: .env
    command: ["bun", "scripts/start-ws.ts"]
    environment:
      WS_PORT: "4097"
    ports:
      - "4097:4097"
    depends_on:
      database:
        condition: service_healthy
    restart: unless-stopped

  database:
    image: postgres
    container_name: bap-postgres
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: bap
    ports:
      - "5432:5432"
    volumes:
      - bap_postgres_data:/var/lib/postgresql/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    image: redis:8-alpine
    container_name: bap-redis
    ports:
      - "6379:6379"
    volumes:
      - bap_redis_data:/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  minio:
    image: minio/minio
    container_name: bap-minio
    command: server /data --console-address ":9001"
    environment:
      MINIO_ROOT_USER: ${S3_ACCESS_KEY_ID}
      MINIO_ROOT_PASSWORD: ${S3_SECRET_ACCESS_KEY}
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - bap_minio_data:/data
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "mc", "ready", "local"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  bap_postgres_data:
  bap_redis_data:
  bap_minio_data:

BYOC daemon (local compute)

The BYOC daemon is meant to run on the user’s local machine, not inside the server Docker stack. This lets the server execute tools and sandbox commands on their device.
  1. Install the daemon using the provided scripts in src/daemon/scripts/.
  2. Authenticate the device:
bap-daemon auth
  1. Start the daemon:
bap-daemon start
If you don’t want BYOC:
  • Set E2B_API_KEY and E2B_TEMPLATE to use E2B cloud sandboxes.
  • Or set DAYTONA_API_KEY (plus optional DAYTONA_SERVER_URL / DAYTONA_TARGET) to use Daytona sandboxes.

Background worker

Bap uses BullMQ for background jobs (e.g., processing integrations). Start the worker in a separate terminal:
bun worker

WebSocket server (BYOC)

The WebSocket server handles daemon connections and runs separately from Next.js:
bun ws:dev

Useful commands

CommandDescription
bun devStart the dev server
bun buildProduction build
bun workerStart the background job worker
bun ws:devStart the BYOC WebSocket server
bun db:pushPush schema changes to the database
bun db:studioOpen Drizzle Studio (database browser)
bun db:seedSeed the database
bun lint:fixFix linting issues
bun typecheckRun the TypeScript type checker
bun testRun unit tests
bun test:e2eRun end-to-end tests

Tech stack

LayerTechnology
WebNext.js 16, React 19, Tailwind CSS 4
APIORPC, Better Auth
DatabasePostgreSQL, Drizzle ORM
AIAnthropic Claude, OpenAI, Google Gemini
QueueBullMQ, Redis
StorageS3 / MinIO
SandboxE2B, Daytona