SecondBrain Pro

Cloudflare setup guide

Deploy your own AI-powered memory backend.

Overview

SecondBrain Pro can connect to your own Cloudflare Workers backend, giving you full control over your data with global edge performance (<50ms latency). The backend is powered by shodh-cloudflare, an open-source distributed AI memory system.

Clients

SecondBrain iOS, Apple Watch, Claude Desktop, Cursor / VS Code

Cloudflare Workers

Receives requests over the REST API and MCP.

Storage and AI

D1 database, Vectorize index, Workers AI

Prerequisites

Premium is required for the custom backend and MCP integration. Local capture and free iCloud sync work without this setup. Connected MCP clients can access backend memories under their own provider policies. Read the data handling details.

Step-by-step setup

Step 1: Clone the repository

git clone https://github.com/doobidoo/shodh-cloudflare.git
cd shodh-cloudflare

Step 2: Create the D1 database

wrangler d1 create shodh-memory

Note the database_id from the output. You need it in the next step.

Step 3: Create the Vectorize index

wrangler vectorize create shodh-vectors --dimensions=384 --metric=cosine

Step 4: Configure wrangler.toml

cp worker/wrangler.toml.example worker/wrangler.toml

Edit worker/wrangler.toml and replace the database_id with your value from step 2.

Step 5: Initialize the database schema

cd worker
wrangler d1 execute shodh-memory --file=../schema.sql --remote

Step 6: Set your API key

wrangler secret put API_KEY

Choose a strong API key. You enter the same key in the SecondBrain iOS app.

Step 7: Deploy

npm install
npm run deploy

Your worker is deployed to https://shodh-memory.YOUR-SUBDOMAIN.workers.dev

Step 8: Verify

curl https://shodh-memory.YOUR-SUBDOMAIN.workers.dev/

You should see: {"message":"SHODH Memory API is running"}

Connect the SecondBrain iOS app

  1. Open SecondBrain Pro → Profile tab
  2. Tap Not Configured under API Configuration
  3. Enter your API Key (from step 6)
  4. Enter your Base URL: https://shodh-memory.YOUR-SUBDOMAIN.workers.dev
  5. Tap Save & Validate

Your API key is stored in the iOS Keychain and never leaves your device unencrypted.

What is included

AI-powered features

Temporal queries

Search with natural language time expressions:

Emotional metadata

Each memory can track emotional context with valence, arousal and emotion labels. This helps you understand patterns in how you feel about different topics.

Costs

Cloudflare usage is separate from the one-time Premium app purchase. Check current Workers, D1, Vectorize and Workers AI plans and limits before deploying. Free allowances do not guarantee zero cost for your workload.

Next steps