Cloudflare and Neon Deployment
Plan for deploying PermitGraph with Cloudflare Workers, a static dashboard, Fumadocs, and Neon Postgres.
What this is
This page explains how to host the PermitGraph proof of concept without changing the scanner.
The hosted stack keeps the scanner local and deterministic. Cloudflare serves the API, dashboard, and docs. Neon stores shared run state.
No live Cloudflare, Neon, DNS, or paid infrastructure is created by this page.
When to use it
Use this plan when you want a public demo where:
- the CLI can write scan results to shared Postgres
- the dashboard can show current runs and findings
- the Worker can serve flat API endpoints
- the docs can explain how to run and review PermitGraph
Command or example
The current database bootstrap path is already implemented:
export DATABASE_URL="postgresql://USER:PASSWORD@HOST/DB?sslmode=require"
uv run --extra db agent-permit db migrateSeed the database by running deterministic fixture scans. The public demo export is curated for docs and does not include every file required by agent-permit ingest.
uv run --extra db agent-permit scan tests/fixtures/safe-agent --ci --run-id neon-seed-safe-agent
uv run --extra db agent-permit scan tests/fixtures/risky-ci-agent --ci --run-id neon-seed-risky-ci-agent || true
uv run --extra db agent-permit scan tests/fixtures/risky-mcp-agent --ci --run-id neon-seed-risky-mcp-agent || trueProcess a dashboard-queued repository scan from the local repo root:
set -a; source .env; set +a
uv run --extra db --extra deep-agent agent-permit runner --once --deep-agent auto --agent-recursion-limit 20The Worker only creates the queue record. The dashboard should queue GitHub repository URLs first. The local runner claims the job from Neon, clones GitHub URLs into .agent-permit/runner-worktrees, runs the scanner, writes artifacts, and updates the shared database. Absolute local paths still work for advanced local scans.
Check the Worker:
cd worker
bun run check
bun testCheck docs and dashboard builds:
cd dashboard
bun run build
cd ../docs-site
bun run buildOutput to expect
The deployable units are:
| Unit | Artifact | Host |
|---|---|---|
| CLI | dist/agent_permit_office-0.1.0-py3-none-any.whl | GitHub release, PyPI later |
| Worker API | worker/ | Cloudflare Workers |
| Dashboard | dashboard/dist/ | Cloudflare static assets or Pages |
| Docs | docs-site/ | Cloudflare Workers with OpenNext |
| Shared state | Postgres schema in src/agent_permit/db.py | Neon Postgres |
| Demo proof | docs/demo-artifacts/public-fixture-scans/ | GitHub and docs |
How to interpret it
Use Neon first because the product already speaks Postgres.
D1 is cheaper for simple SQLite applications, but using it now would require a separate migration sprint. Current code depends on Postgres features and libraries:
JSONBTIMESTAMPTZ- identity columns
- Python
psycopg - Worker
pg
Use Hyperdrive for the production Worker after the first smoke test. Hyperdrive supports Postgres databases and lets Workers use existing drivers through a pooled connection layer.
The first production Worker change should be small:
- keep
DATABASE_URLfor local dev - add optional
HYPERDRIVEbinding support for production - prefer
env.HYPERDRIVE.connectionStringwhen present - fall back to
env.DATABASE_URL
Common mistakes
- Creating a D1 database before rewriting the Postgres schema.
- Putting the Neon connection string in committed config.
- Deploying the dashboard before the Worker
/api/snapshotroute is live. - Treating public fixture artifacts as customer audit evidence.
- Moving scanner execution into the Worker. The local runner should execute scans.
Execution checklist
1. Verify release artifacts
python3 tools/release_check.py
cd worker && bun run check && bun test2. Create shared database
Requires explicit infrastructure approval.
- Create Neon project.
- Copy the Postgres connection string.
- Store it locally in
.env. - Run
agent-permit db migrate. - Run the three fixture seed scans.
- Query
/api/snapshotlocally through Wrangler.
3. Deploy Worker API
Requires explicit hosting approval.
- Add Hyperdrive binding or
DATABASE_URLsecret. - Deploy
worker/. - Verify
/api/health. - Verify
/api/snapshot. - Verify
POST /api/jobswith a GitHub repository URL.
4. Deploy dashboard
Requires explicit hosting approval.
- Build
dashboard/dist. - Configure dashboard API base URL.
- Deploy static app.
- Verify search, filtering, drilldown, and live snapshot data.
5. Deploy docs
Requires explicit hosting approval.
- Add OpenNext Cloudflare adapter.
- Preview docs through
wrangler dev. - Deploy docs app.
- Verify
/docs, search, public demo artifact links, and AI-readable docs.