Dibas Kumar Borborah

Full Stack Engineer | AI/ML Enthusiast

Demo working preview

🧠 Building an AI-Powered Web Code Editor from a Screenshot or Prompt

Using Multimodal LLMs, Monaco Editor, and Real-Time Code Generation

Turning ideas into working web code has always felt a bit clunky to me β€” so I decided to build something fun: an AI-powered web code editor you can run right in the browser.

You can start with a blank canvas, upload a screenshot of a website you like, or just type a prompt. Then the AI takes over.

I used LLaMA-4 Maverick to convert screenshots into code, and GPT-4o to handle prompts and assist with edits. It’s all about making web development feel smooth, creative, and kinda magical β€” even if you're just experimenting on a weekend. Turn screenshots into HTML/CSS/JS, help you edit live code with context-aware chat, and even preview your changes in real-time.

πŸ”— Project Links

βš™οΈ Tech Stack

Here's a peek into the technologies powering this AI-first editor:

🧠 AI Models

  • LLaMA-4 Maverick β€” Multimodal model for screenshot-to-code
  • GPT-4o β€” Prompt-based code generation and context-aware chat

🧰 Frameworks & SDKs

  • Next.js β€” React-based frontend framework
  • Vercel AI SDK β€” Real-time streaming of AI responses
  • Mastra AI β€” AI orchestration and agent management
  • Netlify API - Instant deployment of the website

πŸ’» Code & UI

  • Monaco Editor β€” The same editor behind VS Code
  • Iframe β€” Live rendering of HTML/CSS/JS output
  • Console Interceptor β€” Integrated debugging console

☁️ Storage

  • Amazon S3 β€” For image uploads and access

Let’s dive into how it works πŸ‘‡


πŸ› οΈ How It Works

1. πŸš€ Getting Started

You can begin your coding journey in one of three ways:

  • Start with an empty template
  • Upload a screenshot of a website
  • Upload an image and generate render code

Once you provide an input, the editor spins into action β€” powered by LLaMA-4 Maverick (for screenshots) or GPT-4o (for prompts) β€” and generates clean, semantic HTML, CSS, and JavaScript.


2. 🧠 Screenshot-to-Code with LLaMA-4 Maverick

When a screenshot is uploaded, we use LLaMA-4 Maverick, a multimodal model capable of visually understanding and interpreting layout, components, and design cues. It produces:

  • The full HTML structure
  • Relevant styling (CSS)
  • Any interactive behaviors (JavaScript)

This is especially useful when replicating existing website designs or UI inspiration from dribbble/Behance mockups.


3. πŸ§‘β€πŸ’» Code Editing with Monaco + Live Preview

The generated code is loaded into a Monaco Editor (the same code engine behind VS Code). This gives you:

  • IntelliSense
  • Syntax highlighting
  • Autocompletion

As you modify the code, the output is rendered live in an iframe-based preview window, allowing for immediate visual feedback.


4. πŸͺ΅ Console Window: See Logs in Action

To make debugging seamless, we built a console window that captures:

  • console.log() output
  • Warnings
  • Errors

Everything you’d see in a typical browser dev console, now integrated right into your workspace.


5. πŸ€– Context-Aware AI Chat Assistant

Just like GitHub Copilot or Cursor, users can:

  • Select a portion of the code
  • Ask a question or give an instruction

The AI assistant (GPT-4o) understands the selected context and responds with accurate suggestions or code snippets. The output can be directly injected into the editor β€” no manual copy-pasting required.

And thanks to the Vercel AI SDK, the responses are streamed in real-time, making the experience feel incredibly responsive.


6. πŸ–ΌοΈ Upload and Use Images Easily

Users can upload custom images, which are stored securely on Amazon S3. From the image window, they can:

  • Preview uploaded images
  • Copy pre-generated HTML code to embed those images
  • Paste directly into the HTML editor

Perfect for designing web pages that include assets like icons, logos, or product images.


7. 🌐 One-Click Deploy with Netlify

Once your website looks good in the preview, you can hit a "Deploy" button β€” and boom πŸ’₯ β€” it's live!

I hooked it up with the Netlify API, so with a single click, your project gets deployed and you instantly get a shareable live link. No need to fiddle with configs or hosting β€” it’s just part of the fun.

Perfect for showing off to friends, testing something real quick, or sharing a prototype with someone.

✨ Wrapping Up

This editor brings together the best of AI, developer UX, and modern web tooling β€” letting creators and devs go from idea β†’ screenshot β†’ working website in minutes.

No extensions, no heavy IDEs. Just pure AI magic in your browser.