Skip to content
Veltoryx Technologies
ArchitectureCloudflareNext.jsAIWebGPU·6 min read

Building Veltoryx: Next.js 16, OpenNext, and In-Browser WebGPU AI on Cloudflare Workers for $0/mo

How we architected a full-stack engineering platform serving 500+ interactive lessons, 25 developer tools, and an AI suite entirely on Cloudflare edge isolates with zero cloud infrastructure spend.

V

Vivek Adarsh

Founder & Systems Architect, Veltoryx Technologies · Published November 5, 2026

Most engineering startups die before reaching profitability not because their product failed, but because their AWS cloud bill outpaced their customer acquisition. When we founded Veltoryx Technologies, we established a strict financial invariant: zero cloud spend until the business is organically profitable.

Every architecture decision was evaluated against that single constraint. If a service charged a $20/month base fee before we served a single user, it was disqualified.

Today, Veltoryx Technologies operates a production platform featuring:

  • Learn: 8 comprehensive engineering tracks spanning 500+ lessons (Java, DSA with step-by-step visualizers, System Design Case Studies, Microservices, Kafka).
  • Free Developer Tools: 25 in-browser developer utilities (JWT decoders, consistent hashing visualizers, Kafka partition calculators, SQL formatters).
  • AI Architecture Suite: 37 specialized system design and code reasoning agents.

Our monthly infrastructure invoice across compute, edge routing, storage, and AI inference is exactly $0.00.

Here is the exact technical breakdown of how we built it, the edge constraints we navigated, and the trade-offs we accepted.

The Edge Compute Stack: Next.js 16 and OpenNext

Running modern React Server Components (RSC) outside of Vercel has historically been fragile. Next.js has deep hooks into server runtimes that assume a Node.js process environment with long-lived memory and local disk access.

To achieve zero compute cost with global sub-50ms latency, we targeted Cloudflare Workers. Unlike traditional container platforms (Docker on ECS or Kubernetes), Cloudflare Workers execute code inside lightweight V8 isolates:

  • Cold start time: 0 to 5 milliseconds (compared to 800ms–2s on container cold starts).
  • Free tier allowance: 100,000 requests per day on the Cloudflare Free Plan.
  • Global distribution: Code runs automatically across 300+ edge data centers worldwide.
text
[ Incoming Browser Request ]
            │
            ▼
[ Cloudflare Global Anycast Network ]
            │
            ▼
[ V8 Isolate Worker (OpenNext Bundle) ]
            │
            ├─► Static Content & Assets (Cloudflare Global Edge Cache)
            ├─► Dynamic Auth / Checkout (Neon Serverless Postgres via WebSocket)
            └─► Heavy AI Reasoning (Offloaded to Client WebGPU Runtime)

The bridge that makes Next.js 16.4 with Turbopack run smoothly inside Cloudflare Workers is OpenNext (@opennextjs/cloudflare). OpenNext compiles the Next.js build output into a single optimized worker script that conforms to Cloudflare's workerd runtime.

The Bundle Size Trap

Cloudflare's free tier enforces a strict 3 MB compressed worker script limit. If you naively import heavy markdown libraries, syntax highlighters (like Shiki or Prism), and large SDKs into your Next.js server components, your worker bundle will easily exceed 15 MB and fail deployment.

We solved this with a strict architectural separation: everything heavy must happen at build time.

The Build-Time Static Content Engine

Our Learn platform contains over 500 lessons, complete with syntax-highlighted Java snippets, UML architectural diagrams, interactive quiz blocks, and step-by-step algorithmic tracers.

If we parsed Markdown and highlighted code on demand inside the Cloudflare Worker:

  1. Every cold start would spend CPU cycles compiling ASTs.
  2. The Worker bundle would exceed Cloudflare limits by including the full Shiki tokenizer and Grammar language files.

Instead, we built an ahead-of-time compiler script: scripts/build-learn-content.mjs.

text
[ Markdown Content: content/learn/ ]
            │
            ▼ (Executed at Build Time via Node.js)
[ unified + remark-parse + remark-gfm ]
            │
            ▼
[ Shiki Syntax Highlighting (github-dark theme) ]
            │
            ▼
[ HAST AST Serialized to .generated/learn/*.json ]
            │
            ▼
[ Production Deployment ]
(Cloudflare Worker bundle contains 0 Markdown parsers and 0 Shiki libraries)

During build time:

  • Markdown files are converted to an abstract syntax tree (HAST).
  • Code snippets are tokenized and highlighted into static HTML elements.
  • Algorithmic tracers execute in Node.js, and their visual execution frames are embedded directly into the lesson JSON.

At runtime, the Cloudflare Worker simply reads the pre-compiled JSON and renders it into React components using hast-util-to-jsx-runtime. The runtime CPU overhead is virtually zero, and our Worker bundle size shrank by 82 percent.

Zero-Cost AI: Client-Side WebGPU Inference

Building an AI-assisted developer suite typically incurs crippling cloud bills. Providing OpenAI or Anthropic API tokens to thousands of free visitors can easily cost hundreds of dollars every week.

Instead of running an expensive GPU cluster in AWS or paying per-token API fees, we implemented an in-browser WebGPU inference pipeline.

typescript
// Client-side WebGPU Engine Initialization
import { CreateMLCEngine } from "@mlc-ai/web-llm";

export async function initializeLocalModel(onProgress: (p: number) => void) {
  // Leverages the viewer's local GPU (Apple Silicon M-series, Nvidia RTX, etc.)
  const engine = await CreateMLCEngine("Llama-3.1-8B-Instruct-q4f16_1-MLC", {
    initProgressCallback: (report) => onProgress(report.progress),
  });
  return engine;
}

How the In-Browser AI Pipeline Operates:

  1. When a user opens an AI tool (such as the Architecture Reviewer or Kafka Topology Designer), the browser downloads the quantized model weights (Llama-3.1-8B at 4-bit quantization, roughly 4.3 GB) directly into the browser's persistent CacheStorage.
  2. The model weights are cached permanently on the user's device. Subsequent tool visits load in under 200 milliseconds directly from local storage.
  3. WebGPU compiles shaders directly to the user's hardware GPU (Apple Metal on macOS, DirectX 12/Vulkan on Windows/Linux).
  4. Prompt evaluations and token generations happen entirely client-side at speeds exceeding 40 tokens per second on an Apple M2 or M3 laptop.

The Server Cost: Exactly $0. We pay zero dollars for API tokens, maintain zero GPU servers, and the user enjoys complete privacy because their code and architecture prompts never leave their device.

Serverless Database Architecture: Neon PostgreSQL

For user authentication, Pro subscriptions, and course progress tracking, we use Neon Serverless PostgreSQL.

Traditional PostgreSQL instances (such as AWS RDS) require an active instance running 24/7, costing a minimum of $15 to $30 per month even when idle.

Neon provides:

  • Serverless Compute Autoscaling: Scales to zero when no active queries are executing.
  • WebSocket Protocol Connection Pooling: Cloudflare Workers cannot maintain standard stateful TCP socket pools. Neon provides a specialized serverless driver (@neondatabase/serverless) that tunnels SQL queries over WebSockets with pooled transactions.
  • Generous Free Tier: 0.5 GB of storage with 100 hours of active compute per month—more than sufficient to serve initial user traffic with zero infrastructure spend.
text
[ Cloudflare Worker ]
          │
          ▼ (Encrypted WebSocket Tunnel)
[ Neon Edge Connection Pooler ]
          │
          ▼ (Zero-Compute Scale-Down)
[ PostgreSQL Storage Layer ]

Summary of the Veltoryx Zero-Spend Matrix

text
Component           Traditional Stack              Veltoryx Architecture       Cost
-----------------   -----------------------------  --------------------------  ------
Edge Hosting        Vercel Pro ($20/seat/mo)       Cloudflare Workers          $0.00
Compute Runtime     AWS ECS / Fargate ($35/mo)     V8 Edge Isolates            $0.00
AI Inference        OpenAI API ($150 - $400/mo)    Client-Side WebGPU          $0.00
Relational DB       AWS RDS PostgreSQL ($25/mo)    Neon Serverless Postgres    $0.00
Static CDN Assets   CloudFront / Fastly ($15/mo)   Cloudflare Global Anycast   $0.00
Syntax Engine       Runtime Shiki / SSR RAM        Build-Time HAST Compilation $0.00
-------------------------------------------------------------------------------------
Total Monthly Infrastructure Spend:                                            $0.00

What We Learned

Building under a hard financial constraint forces superior engineering discipline:

  1. You eliminate bloat before it starts. You cannot afford bulky npm packages or lazy runtime dependencies when your edge bundle must stay below 3 MB.
  2. You leverage the client's hardware. Modern laptops and smartphones possess immense compute capability. Moving AI inference and visualizers to the client delivers a faster, zero-latency user experience while completely shielding your balance sheet.
  3. Simplicity scales. By pre-compiling 500+ lessons and relying on static edge caching, traffic spikes from Reddit or Hacker News cannot take down our servers—because there are no origin servers to crash.

In our next engineering post, we explore a core distributed systems challenge: The Dual-Write Problem, and how to reliably implement the Transactional Outbox pattern using PostgreSQL and Apache Kafka.

Interactive Engineering Platform

Run System Design AI Agents Locally in Your Browser

Review architecture, estimate capacities, and design distributed systems with client-side WebGPU agents.

Written by Vivek Adarsh, Founder & Systems Architect, Veltoryx Technologies.

Related Engineering Articles