-
-
Notifications
You must be signed in to change notification settings - Fork 39
Setup Guide
Rahil Pirani edited this page May 15, 2026
·
4 revisions
Click the Deploy to Cloudflare button in the README. Cloudflare will fork the repo into your GitHub account, provision a D1 database and Vectorize index, and deploy the Worker automatically.
After deploying, find your Worker URL in Cloudflare Dashboard → Workers & Pages → second-brain. It looks like https://second-brain.<your-subdomain>.workers.dev.
In Cloudflare Dashboard → D1 → second-brain-db → Console, paste and run:
CREATE TABLE IF NOT EXISTS entries (
id TEXT PRIMARY KEY,
content TEXT NOT NULL,
tags TEXT NOT NULL DEFAULT '[]',
source TEXT NOT NULL DEFAULT 'api',
created_at INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_entries_created_at ON entries(created_at DESC);
CREATE INDEX IF NOT EXISTS idx_entries_source ON entries(source);openssl rand -base64 32 # generate a secure token — save this somewhere
wrangler secret put AUTH_TOKENcurl -X POST https://<your-worker-url>/capture \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"content": "second brain is working", "source": "test"}'
# → {"ok":true,"id":"..."}Then open https://<your-worker-url>/ to access the dashboard.
If you prefer to deploy from a local clone:
- Node.js 18+
- A Cloudflare account (free tier works)
- Wrangler CLI (installed via
npm install)
# 1. Clone and install
git clone https://github.com/rahilp/second-brain-cloudflare.git
cd second-brain-cloudflare
npm install
# 2. Authenticate with Cloudflare
npx wrangler login
# 3. Create the D1 database
npm run db:create
# Copy the database_id from the output and paste it into wrangler.toml
# 4. Create the Vectorize index
npm run vectors:create
# 5. Run the schema
npm run db:migrate:remote
# 6. Set your auth token
openssl rand -base64 32
npx wrangler secret put AUTH_TOKEN
# 7. Deploy
npm run deploy| Script | Description |
|---|---|
npm run dev |
Start local dev server |
npm run deploy |
Deploy to Cloudflare |
npm run db:create |
Create the D1 database |
npm run db:migrate |
Run schema against local D1 |
npm run db:migrate:remote |
Run schema against remote D1 |
npm run vectors:create |
Create the Vectorize index |
npm run devVectorize and Workers AI are only available remotely. Embedding calls will fail gracefully during local development — entries will still be stored in D1 without vectors.
To test against your live remote resources:
npx wrangler dev --remote