// Memory Bytes
engineering

Deleting Ardan Verse: The Architectural Post-Mortem and Code Salvage Masterclass

A forensic teardown of an air-gapped 3D production suite, exploring the Tooling Illusion, headless microservices, and the immortal engineering logic salvaged from the ashes.

16 min read

Every mature software engineering career eventually arrives at the same uncomfortable milestone: the necessity of deleting a system that once represented months or years of ambitious work. The true value of a complex codebase is rarely proportional to the sheer volume of features it accumulates. Sophisticated architectures often collapse not from a lack of technical ambition, but from strategic misalignments, scope creep, and the subtle trap of over-engineering.

Ardan Verse Architecture TeardownArdan Verse Architecture Teardown

Ardan Verse Studio began as an ambitious attempt to build an automated, browser-based media production suite. The goal was radical: shift expensive video rendering and AI generation pipelines directly into the browser, achieving infinite video scalability at a zero marginal cost.

However, the system fell into one of the most pervasive anti-patterns in software product development: The Tooling Illusion. Building frictionless, enterprise-grade production tooling does not automatically instill creative discipline or operational consistency in the end-user. Developers often spend months polishing edge-case UI controls for workflows that have not yet proven viable manually.

As technical debt mounted, the application suffered from severe architectural bloating. Recognized as a strategic liability, the repository was permanently purged. What remains is not broken code, but a refined collection of high-leverage architectural patterns salvaged from the wreckage.

The Architectural Odyssey: System Evolution

The architecture evolved through five distinct paradigms, reflecting a continuous shift from cloud API dependencies down to bare-metal mathematics, local neural models, and modern framework monoliths.

Evolution PhaseCore Technology StackPrimary Operational BottleneckArchitectural Outcome
Phase I: Cloud WrapperGemini 3 Pro, Imagen 4API Rate Limits & Token TruncationDeterministic Multimodal Mega-Schemas
Phase II: Bare-Metal MathFastAPI, Headless Blender CLIManual Hex Buffer HeadersZero-Dependency SFX & Mesh Shrinkwrapping
Phase III: "Iron Man" ProtocolOllama, Local Python TTS, R3FLong CPU Inference Latency & CORSVite Reverse Proxies & AbortSignal Overrides
Phase IV: Local Neural AudioPyTorch, AudioLDM2, FlaskCPU float32 Latency & Throttling"Iron Lung" Hardware Throttling (24 FPS)
Phase V: Framework MonolithNext.js 15, React Three FiberPostCSS Drift & Memory ExhaustionWebGL SSR Evasion & Pure Canvas Export
Products Die. Architecture Compounds.

Deleting the monolith is not an admission of failure, but a tactical system optimization. By killing the product, we prioritize the compounding value of architecture over the transience of a specific UI.


Phase I: Cloud Wrappers & The Mega-Schema

Unstructured text output from Large Language Models is inherently probabilistic and poorly suited for rigid production pipelines. We forced gemini-3-pro-preview into a deterministic logic engine role by enforcing strict JSON Schemas at the API transport layer.

The system returned screenplay monologues wrapped in semantic HTML tags, 16:9 visual prompts, and continuityData in a single atomic API call.

View the Deterministic Mega-Schema (geminiService.ts)
import { Type } from "@google/genai";
 
// Strict Multimodal JSON Mega-Schema forcing deterministic AI responses
export const ardanSchema = {
  type: Type.OBJECT,
  properties: {
    title: { type: Type.STRING },
    script: { type: Type.STRING },
    videoDescription: { type: Type.STRING },
    tags: { type: Type.ARRAY, items: { type: Type.STRING } },
    continuityData: { type: Type.STRING },
    scenes: {
      type: Type.ARRAY,
      items: {
        type: Type.OBJECT,
        properties: {
          sceneNumber: { type: Type.INTEGER },
          description: { type: Type.STRING },
          cameraAngle: { type: Type.STRING },
          visualPrompt16x9: { type: Type.STRING }
        },
        required: ["sceneNumber", "description", "visualPrompt16x9"]
      }
    },
    socials: {
      type: Type.OBJECT,
      properties: {
        instagramPost: { type: Type.STRING },
        shortsScript: { type: Type.STRING },
        coverImagePrompt: { type: Type.STRING }
      },
      required: ["instagramPost", "shortsScript", "coverImagePrompt"]
    }
  },
  required: ["title", "script", "scenes", "socials", "continuityData"]
};

To prevent AI amnesia across multi-episode arcs, a Series Bible Engine dynamically concatenated past context into the active prompt. Connecting this generation to automated video renderers required a robust compilation step: the Lizy Engine, which acted as an in-browser transpiler microservice mapping [AUDIO_ID] and [CAMERA] tags sequentially.


Phase II: Headless 3D Orchestration & Bare-Metal Math

To eliminate third-party cloud costs, we stripped the GUI from Blender and deployed it as a headless microservice managed by FastAPI. Auto-rigging user-uploaded 3D meshes typically fails due to poor topology. We solved this by importing a pristine Master Template containing 52 ARKit blendshapes and applying Blender's Shrinkwrap modifier via CLI commands to warp the template over the input mesh.

# Headless Blender Asset Refinery Pipeline (refinery.py)
import bpy
 
def process_wrapping(input_mesh_path, template_rig_path, output_glb_path):
    bpy.ops.wm.read_factory_settings(use_empty=True)
    bpy.ops.import_scene.gltf(filepath=input_mesh_path)
    raw_mesh = bpy.context.selected_objects
    
    # Import 52-ARKit humanoid template
    bpy.ops.import_scene.gltf(filepath=template_rig_path)
    template_mesh = bpy.context.selected_objects
    
    # Apply Shrinkwrap Modifier for procedural rigging
    shrink_mod = template_mesh.modifiers.new(name="Shrinkwrap", type='SHRINKWRAP')
    shrink_mod.target = raw_mesh
    shrink_mod.wrap_method = 'SURFACE_PROJECT'
    bpy.ops.object.modifier_apply(modifier="Shrinkwrap")
    
    bpy.ops.export_scene.gltf(filepath=output_glb_path, export_draco_mesh_compression_enable=True)

Concurrently, we engineered sfx-engine.js, a zero-dependency procedural synthesizer. It generated sound effects by manipulating raw sine and square waves and manually writing RIFF/WAV binary headers directly in memory using ArrayBuffer, bypassing Node.js entirely.

Deep Dive: Bare-Metal Audio Math (sfx-engine.js)
// Byte-level binary file construction for pure PCM audio in memory
function createWAV(samples, sampleRate) {
  const buffer = Buffer.alloc(44 + samples.length * 2);
  const view = new DataView(buffer.buffer);
 
  // RIFF/WAVE Header
  buffer.write('RIFF', 0);
  view.setUint32(4, 36 + samples.length * 2, true);
  buffer.write('WAVE', 8);
 
  // Format Chunk
  buffer.write('fmt ', 12);
  view.setUint32(16, 16, true);          // Subchunk1Size (16 for PCM)
  view.setUint16(20, 1, true);           // AudioFormat (1 = PCM)
  view.setUint16(22, 1, true);           // NumChannels (1 = Mono)
  view.setUint32(24, sampleRate, true);  // SampleRate
  view.setUint32(28, sampleRate * 2, true); // ByteRate
  view.setUint16(32, 2, true);           // BlockAlign
  view.setUint16(34, 16, true);          // BitsPerSample
 
  // Data Chunk
  buffer.write('data', 36);
  view.setUint32(40, samples.length * 2, true);
 
  for (let i = 0; i < samples.length; i++) {
    const intSample = Math.max(-1, Math.min(1, samples[i])) * 0x7FFF;
    view.setInt16(44 + i * 2, intSample, true);
  }
  return buffer;
}

Phase III & IV: The "Iron Man" Protocol & Local Neural Audio

Phase III marked the transition to a fully air-gapped local stack. We routed LLM requests to local Ollama instances (localhost:11434) and voice synthesis to a Python FastAPI service (localhost:8002). Browser CORS restrictions were bypassed using Vite reverse proxies.

View the Air-Gapped Vite Proxy Configuration
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
 
// Bypassing browser CORS for local air-gapped AI microservices
export default defineConfig({
  plugins: [react()],
  server: {
    port: 3000,
    host: '0.0.0.0',
    proxy: {
      '/api/ollama': {
        target: 'http://localhost:11434',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/ollama/, ''),
      },
      '/api/tts': {
        target: 'http://localhost:8002',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api\/tts/, ''),
      }
    }
  }
});

To achieve studio-quality sound without cloud APIs, we integrated HuggingFace AudioLDM2 diffusion models via PyTorch.

The CPU Float32 Bottleneck

Because local models experience severe CPU float32 generation latency, standard fetch requests would timeout. We engineered custom overrides (AbortSignal.timeout(600000)) allowing 10-minute generation windows.

Running local neural audio alongside WebGL rendering stretched consumer hardware to its breaking point. To prevent thermal throttling on mid-tier CPUs, we implemented the "Iron Lung Protocol," capping MediaRecorder canvas captures strictly to 24/30 FPS and throttling video bitrates to 8 Mbps.


Phase V: Next.js SSR Evasion & Zero-Latency Compilers

In the final evolution, we migrated the entire toolchain into a Next.js 15 App Router utilizing React Three Fiber. Next.js natively attempts to Server-Side Render (SSR) the WebGL canvas, which crashes the build when window or WebGLRenderingContext are undefined on the server. We isolated the canvas to the client using SSR Evasion:

// Using dynamic imports to bypass Next.js SSR WebGL crashes
import dynamic from 'next/dynamic';
 
const Scene = dynamic(() => import('@/components/Studio/Scene'), { 
  ssr: false 
});

To sync the 3D avatar's mouth to the generated audio without native API viseme analysis, the system decomposed audio signals into Bass, Mid, and High channels using Fast Fourier Transform (FFT), mapping them directly to WebGL mesh matrices.

For audio synthesis, we engineered a zero-latency client-side PCM-to-WAV compiler that intercepted raw Base64 PCM bytes from Gemini TTS, wrote the headers into an ArrayBuffer, and converted them into playable blobs, bypassing Node.js entirely.

View the Zero-Latency PCM-to-WAV Compiler
const pcmToWav = (base64PCM: string): string => {
  const cleanBase64 = base64PCM.replace(/[^A-Za-z0-9+/=]/g, "");
  const binaryString = atob(cleanBase64);
  const len = binaryString.length;
  
  const buffer = new ArrayBuffer(44 + len);
  const view = new DataView(buffer);
 
  const writeString = (v: DataView, offset: number, str: string) => {
    for (let i = 0; i < str.length; i++) v.setUint8(offset + i, str.charCodeAt(i));
  };
 
  writeString(view, 0, 'RIFF');
  view.setUint32(4, 36 + len, true);
  writeString(view, 8, 'WAVE');
  writeString(view, 12, 'fmt ');
  view.setUint32(16, 16, true);
  view.setUint16(20, 1, true); // Raw format
  view.setUint16(22, 1, true); // Mono channel
  view.setUint32(24, 24000, true); // 24kHz Sample Rate
  view.setUint32(28, 24000 * 2, true); // Byte rate
  view.setUint16(32, 2, true); // Block align
  view.setUint16(34, 16, true); // 16 bits per sample
  writeString(view, 36, 'data');
  view.setUint32(40, len, true);
 
  const pcmData = new Uint8Array(buffer, 44);
  for (let i = 0; i < len; i++) pcmData[i] = binaryString.charCodeAt(i);
 
  return URL.createObjectURL(new Blob([view], { type: 'audio/wav' }));
};

Forensic Audit: Fatal Anti-Patterns

Identifying these anti-patterns is what allows the architect to safely delete the code and avoid repeating catastrophic bottlenecks in future ventures.

The "LLM Hammer" & The Audio Routing Paradox

The system fell victim to the "LLM Hammer"—using probabilistic LLMs for deterministic tasks like incrementing counters, which led to index failures. A simple JavaScript .map() function is infinitely more reliable.

More fatally, we discovered the Audio Routing Paradox: native browser TTS (window.speechSynthesis) operates outside the Web Audio API context. This meant that while the UI appeared audio-reactive, the MediaRecorder resulted in silent video exports whenever the fallback voice was used.

Ecosystem Decay & Dependency Drift

The transition to Tailwind CSS v4 shattered the Vite build pipeline. The system attempted to use tailwindcss as a direct PostCSS plugin instead of the required @tailwindcss/postcss package. Furthermore, a misconfigured content array (./**/*.ts) accidentally ingested the entire node_modules folder, grinding build times to a halt and forcing the ultimate migration to Next.js.

Bikeshedding and Scope Creep

Documentation reveals 25 distinct iterations of the 3D avatar. Massive amounts of time were wasted on digital geometry—moving from the V6 Low Poly head to the V25 Modern Human. The latter was engineered specifically to fix "Circus/Clown" feedback regarding skin tone and eye proportions. The tech stack became the product, rather than the content it was meant to produce.


Final Verdict: Exception Handled

The autopsy of Ardan Verse serves as a definitive case study in over-engineering. While the product is dead, the engineering logic is preserved and archived. A technical post-mortem is a far more valuable artifact than a broken monolith.

This deletion proves two defining traits of senior engineering: the elite technical depth to push WebGL, bare-metal math, and local LLMs to their hardware limits, and the senior-level maturity to recognize scope creep and kill a project that no longer serves a strategic purpose.


📚 IELTS Goldmine: Words & Phrases

Word/PhraseMeaning (in English)Example from this post
Tooling IllusionThe mistaken belief that better tools automatically create better outcomes."This post-mortem is necessitated by the 'Tooling Illusion'..."
Sunk Cost FallacyContinuing a behavior or endeavor as a result of previously invested resources."The 'ruthless' decision to burn the repository required a cold assessment of the sunk cost fallacy."
Air-gappedPhysically isolated from external or unsecured networks for security or independence."...reflecting a strategic shift from total cloud dependency to an air-gapped 'local-first' philosophy..."
Bare-metalExecuting directly on hardware or using fundamental mathematical instructions without abstraction layers."...integrated raw mathematical generation and bare-metal math."
OrchestrationCoordinating multiple independent systems or software containers."...despite its high-fidelity WebGL interfaces and sophisticated AI orchestration..."
DeterministicProducing the exact same output for the exact same input without randomness."...forcing the LLM into a deterministic logic engine role."
DecoupledDesigned so that individual components operate independently."...are immortal and have been successfully decoupled from the monolith..."
TranspilerA tool that reads source code written in one programming language and produces equivalent code in another."The 'Lizy Engine' Transpiler translated human-readable scripts..."
BikesheddingSpending excessive effort on low-impact, trivial details."Bikeshedding and Scope Creep (The 25 Avatar Iterations)"
Post-mortemA structured review after a project's completion or failure."This post-mortem is necessitated by the 'Tooling Illusion'..."