I've been working on MirageUI with my team, and I wanted to share the project and some of the engineering behind it.
Live: https://mirageui.vercel.app/
Source: https://github.com/Veer1778/Mirage
The idea was to explore an alternative to prompt-based website generation.
Instead of describing a webpage to an AI, you draw a rough wireframe using rectangles, and the editor interprets the layout and generates frontend code.
How it works
The interesting part is the layout interpretation engine.
I deliberately avoided using an LLM for component recognition. Instead, Mirage uses geometric heuristics to infer what the user is trying to build.
It considers four main signals:
- Position: A full-width rectangle at the top is likely a navbar; the same rectangle at the bottom is likely a footer.
- Aspect ratio: Tall and narrow shapes can indicate rails, while wider shapes suggest horizontal sections.
- Spatial relationships: Multiple similarly sized rectangles sharing a row can indicate a card grid.
- Width and alignment: Elements snap to a 12-column grid before being interpreted.
One implementation decision I'm particularly happy with is storing sketches as integer grid coordinates rather than raw pixel positions.
Each box is represented using its column, row, width and height. This makes snapping, collision detection and layout calculations much more predictable.
Boxes that overlap vertically are grouped into horizontal bands, which are then translated into CSS grid layouts.
The editor also prevents overlapping boxes. When a drag is blocked, movement is retried along individual axes so elements can slide around obstacles.
Component detection
Mirage currently supports 19 component types, with nine detected automatically.
When the classifier isn't confident, it flags the element instead of silently guessing. Users can manually override classifications, and manually overridden elements aren't reclassified.
Code generation
The same sketch can be exported into three targets:
- HTML: Semantic markup with a token-driven stylesheet.
- React: Component-based output with props.
- Tailwind: Utility classes with mobile-first breakpoints.
Sketches can also be saved and reloaded through a JSON format.
I kept styling separate from structure using design tokens. This means switching themes doesn't require changing the underlying markup.
Tech stack and architecture
One thing worth mentioning is that the entire application is built using:
- Vanilla JavaScript
- HTML
- CSS
- Vercel for deployment
There are no external dependencies, no build step and no backend. Everything runs in the browser as static files.
The repository is structured around separate editor, engine, theme and landing-page files.
What I learned
A few things I found interesting while building this:
- Geometry alone can communicate a surprising amount of layout intent.
- Using a consistent coordinate system simplifies several seemingly unrelated problems.
- Automatic classification needs a manual override mechanism. You can't expect heuristics to understand every possible layout.
- Generating valid code is one thing; generating code that developers would actually want to maintain is another.
This is still an evolving project, and I'd particularly appreciate feedback from people who have worked on frontend tooling, visual editors or code generation.
A few things I'd love opinions on:
- Would you approach component recognition differently?
- Are there better ways to handle ambiguous spatial relationships?
- What would make the generated React output more useful in a real development workflow?
Demo: https://mirageui.vercel.app/
GitHub: https://github.com/Veer1778/Mirage
It's MIT licensed and free to use. Would love to hear your thoughts!