Cloudflare Workers Data Platform Integration -- Overview

Executive Summary

Company Manager is a multi-tenant SaaS platform (87 packages, 11 apps, 206+ services) running on Next.js 16 + TRPC + Prisma 7 + Neon PostgreSQL. The platform \1 (chat, rate-limiting, gaming, bookings) with Durable Objects and KV. This document set maps every relevant Cloudflare data platform product to concrete integration opportunities.

Current Architecture Snapshot

LayerCurrentCloudflare Replacement/Enhancement
DatabaseNeon PostgreSQL (Prisma 7)**Hyperdrive** (connection pooling + cache)
File StorageAWS S3**R2** (zero egress, S3-compatible)
CacheUpstash Redis (limited)**Workers KV** (global edge cache)
Message QueueBull on Upstash Redis**Queues** (guaranteed delivery, DLQ)
SearchPostgreSQL tsvector**Vectorize + Workers AI** (semantic)
AI InferenceOpenAI API (external)**Workers AI** (edge inference, 50+ models)
Real-time4 Workers + basic WebSocket**Durable Objects** (extend existing)
AnalyticsRaw SQL aggregations**Analytics Engine** (time-series)
Cron JobsShell scripts (3h intervals)**Workflows** (durable execution)
Edge DBNone**D1** (per-tenant edge replicas)
Data LakeNone**Data Platform** (Pipelines + R2 SQL)

Existing Cloudflare Workers


chat-worker        -> https://chat-worker.wd29.workers.dev
rate-limit-worker  -> https://rate-limit-worker.wd29.workers.dev
gaming-worker      -> https://gaming-worker.wd29.workers.dev
bookings-worker    -> https://bookings-worker.wd29.workers.dev

These use Durable Objects, KV, and D1 already. The integration path is well-established.

Document Index

DocProductPriorityImpact
[01-hyperdrive-neon](./01-hyperdrive-neon.md)Hyperdrive**P0**Database latency, connection pooling
[02-r2-media-storage](./02-r2-media-storage.md)R2**P0**File storage cost, zero egress
[03-kv-edge-caching](./03-kv-edge-caching.md)Workers KV**P0**Read latency, DB load reduction
[04-vectorize-semantic-search](./04-vectorize-semantic-search.md)Vectorize + Workers AI**P1**Search quality, recommendations
[05-workers-ai-inference](./05-workers-ai-inference.md)Workers AI**P1**AI cost, latency, autonomy agents
[06-queues-background-jobs](./06-queues-background-jobs.md)Queues**P1**Job reliability, observability
[07-durable-objects-realtime](./07-durable-objects-realtime.md)Durable Objects**P1**Real-time collaboration, state
[08-analytics-engine](./08-analytics-engine.md)Analytics Engine**P2**Metrics pipeline, dashboards
[09-workflows-orchestration](./09-workflows-orchestration.md)Workflows**P2**Durable multi-step processes
[10-d1-edge-database](./10-d1-edge-database.md)D1**P2**Edge-local reads, per-tenant DB
[11-data-platform-lakehouse](./11-data-platform-lakehouse.md)Data Platform**P3**Data lake, cross-cloud analytics
[12-migration-roadmap](./12-migration-roadmap.md)All--Phased rollout plan

Priority Legend

Cost Model (Workers Paid Plan -- $5/mo base)

ProductIncluded FreeOverage
Workers10M requests, 30M CPU-ms$0.30/M req, $0.02/M CPU-ms
KV10M reads, 1M writes, 1 GB$0.50/M reads, $5/M writes, $0.50/GB
R210 GB, 1M Class A, 10M Class B$0.015/GB, $4.50/M writes, $0.36/M reads
D125B rows read, 5 GB$0.001/M rows, $0.75/GB
Durable Objects1M requests, 400K GB-s, 5 GB SQLite$0.15/M req, $12.50/M GB-s, $0.20/GB
QueuesIncluded ops$0.40/M operations
HyperdriveIncludedNo extra charge
VectorizeFree tier (generous)~$0.01/M queried dimensions
Workers AI10K Neurons/day$0.011/1K Neurons
Analytics EngineNot yet billingTBD
WorkflowsIncluded in WorkersStandard Workers pricing

\1: Hyperdrive is free. R2 egress is free. This makes the migration from AWS S3 and direct Neon connections a pure cost win.

Multi-Tenant Considerations

Every integration must respect the existing tenant isolation model:


// TRPC context -- source of truth for tenant scope
ctx.tenantId  // UUID -- REQUIRED in every query
ctx.siteId    // UUID -- optional but recommended
ctx.userId    // UUID -- for user-scoped operations

For Workers:

Integration Architecture


                          Cloudflare Edge
                    ┌─────────────────────────┐
                    │  Workers (compute)       │
                    │  ├─ KV (cache)           │
                    │  ├─ R2 (files)           │
                    │  ├─ D1 (edge SQL)        │
                    │  ├─ DO (state)           │
                    │  ├─ Vectorize (search)   │
                    │  ├─ Workers AI (models)  │
                    │  ├─ Queues (async)        │
                    │  ├─ Analytics Engine      │
                    │  └─ Workflows (durable)   │
                    └──────────┬──────────────┘
                               │ Hyperdrive
                               │ (pooled + cached)
                    ┌──────────▼──────────────┐
                    │  Neon PostgreSQL          │
                    │  (primary database)       │
                    └─────────────────────────┘

    Next.js App (apps/app)
    ├─ TRPC Routers → Workers (via fetch)
    ├─ Service Registry → getService() unchanged
    └─ Prisma → Neon (via Hyperdrive when from Workers)

Risk Assessment

RiskMitigation
Vendor lock-inUse S3-compatible APIs (R2), standard SQL (D1), abstract behind service interfaces
Data consistencyHyperdrive cache TTL tuning, KV eventual consistency awareness
Multi-tenant leakEnforce tenantId in all KV keys, R2 paths, DO IDs, Vectorize namespaces
Migration downtimeFeature flags per integration, gradual rollout per tenant
Cost spikesSet budget alerts, start with free tiers, monitor Analytics Engine

Next Steps

1. Read each design doc for the specific integration you want to implement 2. Follow the \1 for phased rollout 3. Start with P0 items (Hyperdrive, R2, KV) for immediate wins