Cloudflare · Cloudflare Workers · Diagram as code
Cloudflare Workers architecture diagram
Describe a Worker and the D1, R2 or KV data it touches. ArchLex keeps Cloudflare resources at the edge (not inside a VPC) and validates the connections you declare.
Worker with D1 and R2.
API Worker writing relational state to D1 and objects to R2.
provider cloudflare
direction LR
edge: workers["API Worker"]
db: d1["App DB"]
blob: r2["Uploads"]
edge -[writes]-> db
edge -[writes]-> blobWorker with D1, R2 and KV inside an account.
Group edge resources under a Cloudflare account scope and add KV for session cache.
provider cloudflare
direction LR
account production {
edge: workers["API Worker"]
db: d1["App database"]
files: r2["Uploads"]
cache: kv["Session cache"]
edge -[writes]-> db
edge -[writes]-> files
edge -[reads]-> cache
}Pattern notes for Cloudflare Workers.
Placement and relationship rules ArchLex enforces for this service.
- Placement. Cloudflare resources belong at the document root or inside a logical account. Putting a Worker inside a region, VPC, subnet, cluster or namespace reports CLOUDFLARE-CONTAINMENT-001.
- Valid connections. workers -[writes]-> d1|r2 and workers -[reads]-> r2|kv are the common edges. Add dns, waf and cache nodes when you want the full edge picture from the gallery examples.
- Origins on other clouds. Mix providers with qualified kinds such as cloudflare.workers next to aws.alb or gcp.cloud-run when the Worker proxies to an origin.
Ask an agent to draw it.
Install the ArchLex skill or connect the free MCP server, then paste this prompt.
npx skills add baires/archlexDraw a Cloudflare Workers architecture diagram with a Worker writing to D1 and R2 and reading KV for sessions. Validate placement and give me a playground link.Prefer MCP? Follow the MCP server guide.
Related Cloudflare examples.
Cloudflare Workers diagram questions.
How do I diagram Cloudflare Workers with D1 and R2?
Declare workers, d1 and r2 (optionally under an account scope). Connect with -[writes]-> and -[reads]->. Keep everything out of VPC or Kubernetes scopes.
Why did I get CLOUDFLARE-CONTAINMENT-001?
A Cloudflare resource was placed inside a region, VPC, subnet, cluster or namespace. Move it to the document root or a logical account.
Can Workers talk to AWS or GCP origins in one diagram?
Yes. Use qualified kinds and multiple providers. The Cloudflare public-edge-to-AWS gallery example shows the pattern.
Is ArchLex affiliated with Cloudflare?
No. ArchLex is a community project. Cloudflare names and trademarks remain with their owners. Icons are bundled under CC BY 4.0 attribution.
More Cloudflare service diagrams.
Open source · MIT licensed