Hack #2: Cloudflare · Cloudflare
2 Apr, 09:25
Haven Architect is an autonomous generative ambient audio engine built for deep work and flow states. Users describe their current task, pick a sound world and energy level, and Haven instantly generates a completely original soundscape tuned to that exact context. Every 60 seconds the soundscape evolves on its own. A built-in Pomodoro timer runs 25/5 focus cycles with the sound intensity softening automatically at break time. Mid-session, users can type natural language to the Architect ("more rain," "pump the energy") and the system rebuilds the audio within seconds. Nothing loops. The same sound never exists twice. The problem Haven solves is simple: static music fails deep work. The human brain habituates to repetitive audio in roughly 20 minutes, after which the sound becomes invisible noise and so does the work. Every lo-fi playlist and rain sounds video on YouTube has this flaw because they were built for entertainment, not cognition. Haven fixes this by classifying each task against 9 neuro-acoustic profiles validated by attention restoration theory and environmental psychology. Coding gets tonal drones that support beta brainwaves. Writing gets natural soundscapes that reduce cortisol. Creative work gets abstract spatial textures that induce theta state. The audio environment is built for the person, the task, and the moment. ElevenLabs is the core synthesis engine behind every soundscape. Haven calls the ElevenLabs sound generation API to produce 22-second MP3 chunks on demand, with each prompt generated fresh by Llama 3.3 70B running on Cloudflare AI. These prompts are 15 to 30 word physical sound descriptions built from the user's task context, for example "heavy rain on forest canopy, deep resonant drone beneath ancient trees, distant thunder rolling through undergrowth." A custom Web Audio engine trims the MP3 silence on both ends of every chunk so they loop and crossfade with zero click artifacts, with a 3-second linear gain blend streamed in real time over WebSocket. Two chunks are pre-generated in parallel at session start so playback begins instantly, and three local 108Hz oscillators synthesize audio at boot while the first real chunk loads so there is literally zero silence from the moment the user hits start. Cloudflare powers the entire backend across four services. Cloudflare Workers handles all routing and audio serving at the edge. Cloudflare Durable Objects is the architectural core, with each user session getting its own isolated DO instance that holds complete session state including chat history, prompt evolution, energy parameters and usage limits, surviving WebSocket drops and reconnections without losing context. Cloudflare AI runs Llama 3.3 70B directly at the edge for task classification and prompt engineering. And Cloudflare R2 stores every generated audio chunk for fast global delivery. The result is a fully stateful, real-time, generative audio system running entirely on the edge with no traditional server anywhere in the stack.
