← Back to Home
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.

SecondBrain iOS
Apple Watch
Claude Desktop
Cursor / VS Code
↓ REST API / MCP ↓
Cloudflare Workers
D1 Database
Vectorize Index
Workers AI

Prerequisites

Step-by-Step Setup

1 Clone the Repository

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

2 Create D1 Database

wrangler d1 create shodh-memory

Note the database_id from the output — you'll need it in the next step.

3 Create Vectorize Index

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

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.

5 Initialize Database Schema

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

6 Set Your API Key

wrangler secret put API_KEY

Choose a strong API key — you'll enter this same key in the SecondBrain iOS app.

7 Deploy

npm install
npm run deploy

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

8 Verify

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

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

Connect 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 securely in the iOS Keychain and never leaves your device unencrypted.

What's 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 — helping you understand patterns in how you feel about different topics.

Costs

Cloudflare Free Tier covers most personal use: 100,000 Worker requests/day, 5GB D1 storage, 5,000 Vectorize vectors, and 10,000 AI inference units/day. No credit card required.

Next Steps