<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Viraj Sheoran</title>
    <description>The latest articles on DEV Community by Viraj Sheoran (@mevirajsheoran).</description>
    <link>https://dev.to/mevirajsheoran</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3974108%2Fb69ac148-b120-4328-96b9-f63a55e7f471.png</url>
      <title>DEV Community: Viraj Sheoran</title>
      <link>https://dev.to/mevirajsheoran</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mevirajsheoran"/>
    <language>en</language>
    <item>
      <title>I replaced a language model with geometry: building a deterministic UI compiler that runs in your browser in 300ms</title>
      <dc:creator>Viraj Sheoran</dc:creator>
      <pubDate>Mon, 08 Jun 2026 12:02:14 +0000</pubDate>
      <link>https://dev.to/mevirajsheoran/i-replaced-a-language-model-with-geometry-building-a-deterministic-ui-compiler-that-runs-in-your-44go</link>
      <guid>https://dev.to/mevirajsheoran/i-replaced-a-language-model-with-geometry-building-a-deterministic-ui-compiler-that-runs-in-your-44go</guid>
      <description>&lt;p&gt;I Built a Deterministic UI Compiler&lt;/p&gt;

&lt;p&gt;Most AI UI generators have the same three problems:&lt;/p&gt;

&lt;p&gt;Slow — often taking 15–30 seconds per generation&lt;br&gt;
Expensive — API costs, credits, and rate limits&lt;br&gt;
Non-deterministic — the same input can produce different outputs every time&lt;/p&gt;

&lt;p&gt;The third problem bothered me the most.&lt;/p&gt;

&lt;p&gt;I wanted a system that behaved like a compiler, not a slot machine. If I gave it the same wireframe twice, I wanted the exact same result twice.&lt;/p&gt;

&lt;p&gt;So I built D2D — a deterministic wireframe-to-React compiler that runs entirely in the browser.&lt;/p&gt;

&lt;p&gt;The Core Idea&lt;/p&gt;

&lt;p&gt;Most UI generation tools treat interface design as a language problem.&lt;/p&gt;

&lt;p&gt;I think it's primarily a geometry problem.&lt;/p&gt;

&lt;p&gt;A rectangle that's 200×40 pixels is probably an input field.&lt;/p&gt;

&lt;p&gt;A rectangle that's 80×36 pixels is probably a button.&lt;/p&gt;

&lt;p&gt;A large text element near the top of the page is probably a heading.&lt;/p&gt;

&lt;p&gt;These aren't ambiguous language patterns. They're spatial patterns.&lt;/p&gt;

&lt;p&gt;Geometry doesn't hallucinate.&lt;/p&gt;

&lt;p&gt;Compilers don't guess.&lt;/p&gt;

&lt;p&gt;How It Works&lt;/p&gt;

&lt;p&gt;D2D transforms a hand-drawn wireframe into production-ready React and Tailwind code through a six-stage pipeline.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Extraction&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The system collects all shapes inside the selected frame, normalizes coordinates, and creates a consistent spatial representation of the layout.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Classification&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Elements are assigned semantic roles using a combination of direct mappings, heuristics, and exclusion rules.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;Large rectangles become inputs&lt;br&gt;
Small rectangles become buttons&lt;br&gt;
Decorative arrows and annotations are ignored&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Spatial Understanding&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hand-drawn wireframes are messy.&lt;/p&gt;

&lt;p&gt;Nothing is perfectly aligned.&lt;/p&gt;

&lt;p&gt;A strict pixel-based approach breaks immediately.&lt;/p&gt;

&lt;p&gt;To handle this, D2D builds a spatial graph that measures alignment strength using Gaussian decay scoring.&lt;/p&gt;

&lt;p&gt;Elements that are "close enough" form alignment groups, allowing the system to understand rows, columns, and layout intent even when sketches are imperfect.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Layout Architecture&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The compiler constructs a parent-child hierarchy using containment analysis.&lt;/p&gt;

&lt;p&gt;Containers, sections, cards, and nested groups emerge from the geometry itself.&lt;/p&gt;

&lt;p&gt;Additional pattern-detection rules identify common structures such as:&lt;/p&gt;

&lt;p&gt;Hero sections&lt;br&gt;
Feature grids&lt;br&gt;
Cards&lt;br&gt;
Forms&lt;br&gt;
Navigation bars&lt;br&gt;
Call-to-action blocks&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Design Identity&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A simple style selection expands into a complete design system.&lt;/p&gt;

&lt;p&gt;A single preset generates:&lt;/p&gt;

&lt;p&gt;Color tokens&lt;br&gt;
Typography scales&lt;br&gt;
Spacing systems&lt;br&gt;
Shadows&lt;br&gt;
Animations&lt;br&gt;
Component styling rules&lt;/p&gt;

&lt;p&gt;Current presets include:&lt;/p&gt;

&lt;p&gt;Startup Modern&lt;br&gt;
Corporate Clean&lt;br&gt;
Bold Creative&lt;br&gt;
Minimal Elegant&lt;br&gt;
Dashboard Dense&lt;br&gt;
Glass Gradient&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Code Generation&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The final stage assembles React and Tailwind components.&lt;/p&gt;

&lt;p&gt;The output is production-ready code, typically ranging from 100 to 700 lines depending on complexity.&lt;/p&gt;

&lt;p&gt;Determinism&lt;/p&gt;

&lt;p&gt;The entire pipeline is deterministic.&lt;/p&gt;

&lt;p&gt;There is no randomness.&lt;/p&gt;

&lt;p&gt;No AI model.&lt;/p&gt;

&lt;p&gt;No API calls.&lt;/p&gt;

&lt;p&gt;No hidden probability distributions.&lt;/p&gt;

&lt;p&gt;Content selection uses stable hashing, ensuring identical inputs always produce identical outputs.&lt;/p&gt;

&lt;p&gt;To verify this, I built a test suite that runs the same wireframe through the compiler 100 times and compares every generated character.&lt;/p&gt;

&lt;p&gt;The output is always identical.&lt;/p&gt;

&lt;p&gt;The Recipe System&lt;/p&gt;

&lt;p&gt;Sometimes you don't want to draw a wireframe.&lt;/p&gt;

&lt;p&gt;You just want a starting point.&lt;/p&gt;

&lt;p&gt;D2D includes a recipe system that generates complete layouts from a page type and industry combination.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;SaaS + Technology&lt;br&gt;
Landing Page + Healthcare&lt;br&gt;
Portfolio + Creative Agency&lt;br&gt;
Dashboard + Finance&lt;/p&gt;

&lt;p&gt;With 8 page types and 10 industries, the system currently supports 80 unique combinations.&lt;/p&gt;

&lt;p&gt;If a wireframe is present, your sketch takes priority and the recipe fills in missing sections.&lt;/p&gt;

&lt;p&gt;Results&lt;br&gt;
Generation Time: &amp;lt;300ms&lt;br&gt;
API Calls: 0&lt;br&gt;
Cost Per Generation: ₹0&lt;br&gt;
Runs Entirely in Browser&lt;br&gt;
Deterministic Output: Guaranteed&lt;br&gt;
Try It&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tryd2d.xyz" rel="noopener noreferrer"&gt;https://tryd2d.xyz&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;No signup required.&lt;/p&gt;

&lt;p&gt;I'm especially interested in feedback on the spatial graph.&lt;/p&gt;

&lt;p&gt;If you've worked on layout engines, compilers, or design tooling, I'd love to hear how you'd approach the problem of hand-drawn alignment and geometric ambiguity.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
