惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
量子位
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
博客园_首页
博客园 - 【当耐特】
Last Week in AI
Last Week in AI
Martin Fowler
Martin Fowler
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC

DEV Community

Membangun Kompetensi dan Relasi: Mengapa Ekosistem Kampus Itu Penting I Built an AI That Decides Which AI to Talk To — Running 24/7 From My Living Room Codex Team Usage SOP How to Actually Become a Programmer: The Hard Part Nobody Wants to Explain Building a Production-Style Multi-Tool AI Agent with Python, Flask, React & Gemini AI # Building Instagram OSINT Projects with HikerAPI Your AI can read. Gemma 4 can see The Battle of the Senior Dev: Why AI Gives You Wings But Only If You're Ready to Pilot HiDream Raw Output Failed Tried Dev-2604 VRAM Math Killed It Won with a Prompt Enhancer Instead I Finally Finished a Project I Abandoned — And GitHub Copilot Helped Me Ship It SafeSMS: On-Device Threat Detection with Gemma 4 E4B, no internet required I Built OpenKap — A Loom Alternative for Small Teams Who Just Want to Ship Gemma 4 is Here: The Dawn of Local Multimodal Reasoning Offline-First Flutter: How We Built a CRM That Manages 100K+ Leads With No Internet Memory for Agents: When Vectors Meet Graphs, Bugs Drop 4 The Rise of Production-Grade AI Infrastructure I ran my idea-validation product through its own validator. The verdict was PIVOT. We Built an Agent Commerce API. Google I/O 2026 Changed Our 3-Month Roadmap in 24 Hours. "My Partner's Memory Was Full. I Didn't Know — Until We Tried to Talk." I’m a Front End Web Developer Learning Machine Learning From Scratch Laravel Waiting Request I Built a Chrome Extension to Track How Long You Actually Spend on Each Tab Why Google Can't See Your React Breadcrumbs (And the 4-Line Fix) AI Travel Assistant Powered by Gemma 4; With Streaming, Image Input, and Visual Recommendation Cards Microsoft tried to kill the printer driver. Healthcare said no. The Blueprint Beneath the Blueprint: Designing Data Model and Choosing Its Database REST APIs vs Webhooks in Telecom Billing - Which One Actually Makes Sense? Accounting Made Simple: AI-Powered Financial Insights of Japanese Companies with Gemma 4 The append-only AST trick that makes Flutter AI chat actually smooth Designing the Future of Payments — Why XML Still Matters in the Age of APIs From Legacy to Live — Reviving XMLPayments with GitHub Copilot Two Weeks Into Learning Solana XMLPayments — The Hidden Backbone of Modern Financial Orchestration AI Agents in Practice — Read from the beginning Reviving My Gemma Agentic Framework: From Prototype to Polished Repo Smart Contracts Demand Better Infrastructure: Building on contract.dev Self-Hosted LLM Tool Calling: Forge and the Build-vs-Buy Decision ORA-00072 오류 원인과 해결 방법 완벽 가이드 OpenWA for CTOs: Self-Hosted WhatsApp Gateway Trade-Offs NotebookLM Automation With notebooklm-py: Useful, But Classify Data First Docker v29.5.x Operator Upgrade Checklist Coding-Agent Instruction Design: The CLAUDE.md File That Prevents Rework When I Finally Realized My Runtime Was Holding Me Back GnokeOps: Host Your Own AI House Party The Death of Static Rate Limiters: Why Your Java Virtual Threads Need BBR-Style Adaptive Concurrency AI Agents in Practice — Part 2: What Makes Something an Agent Stop scattering LLM SDK/API calls across your codebase. Here is the 2-file rule that fixed mine Beyond Prompts: Structuring AI Workflows for Real Frontend Engineering From an Abandoned Hackathon Project to an AI Study Workspace 🚀 Terraform with AI: Build AWS Infra (Cursor + MCP) What If AI Didn’t Need the Internet? 750,000 Chips, 140 Trillion Tokens: The Math Behind DeepSeek's Permanent Price Cut You're Renting Someone Else's Compute — And It's Costing You More Than You Think CSS :has() Selector: The Layout Trick I Wish I Knew 5 Years Ago Five Clusters. Five Lessons. One Production System. Synaptic: A Local-First AI Dev Companion That Remembers How You Think Revolutionizing Edge MedTech: Building a Sovereign Sleep Apnea Companion ("XiHan Snore Coach") with Gemma 4 HDD Eksternal Tiba-Tiba Tidak Bisa Diakses di Windows? Ini Tiga Lapis Fix-nya DMARC p=none vs p=quarantine vs p=reject: what to use and when DSA Application in Real Life: How Git Diff Works: LCS Intuition, Myers Algorithm, and Real Code Changes I solo-built a reputation layer for AI agents on NEAR — and here's what I learned I built an AI faceless video generator in 2 months — here's the stack Diffusion Language Models: How NVIDIA Nemotron-Labs Diffusion Shatters the Autoregressive Speed Ceiling llm-nano-vm v0.8.0 — deterministic FSM runtime for LLM pipelines, now with output validation and per-step timeouts From the Renaissance to the Quantum Dawn: AI, Computation, and the Next Paradigm Shift How I Built a Review Site with 800+ Articles Using AI I Built a Smart Kitchen AI with Gemma 4 That Turns Fridge Photos Into Recipes Why your vulnerability dashboard is lying to you (and how to fix it) From Abandoned Prototype to Smart AI System: Reviving Trafiq AI with GitHub Copilot Why Country/State/City Pickers Are Weirdly Hard Node.js 22 LTS — EOL Date, Support Timeline, and What Comes Next The 7-Layer Memory Architecture Behind Modern AI Agents I Imagined Hermes Agent Running an Entire Smart City — And It Changed How I See AI One backend, four products: why we bet on platform-per-brand AI's tech debt is invisible — even to AI. I solved it at the architecture layer. Why ROAS 300% Can Still Mean Losses — Gross Margin in 5 Ecommerce Verticals You Don’t Need to Try Every AI Tool to Keep Up NovelPilot: A Novel Writing Agent Powered by Gemma 4 BoxAgnts is an Out-Of-The-Box Secure AI Agent ToolBox in a WASM SandBox Gemma 4 deep dive: why a 1.5 GB model scores 37.5% on competition mathematics, how the MoE routing actually works, and which model fits your hardware. Full breakdown inside. BeeLlama v0.2.0: 164 tok/s on a 27B model, one RTX 3090 Google Just Declared the Chat-Log Interface Dead. Here's What Neural Expressive Actually Signals for Developers. ARCHITECTURE SPECIFICATION & FORMAL SYSTEM REPORT: k501-AIONARC Notes from a Hammock What's Google Antigravity 2.0 ? Here's What the Agent Harness Actually Changes for Developers. Building an E2EE Chat App in Flask - Part 3: Keeping File Uploads Safe Google's Gemini Spark. Here's What It Actually Does for Developers. Microsoft Just Shipped MCP Governance for .NET. Here's What It Actually Enforces. How I Built a Pakistan Internet Speed Test Platform at 16 How to Build a Supervisor Agent Architecture Without Frameworks I Built My Own Corner of the Internet — Here's What It Looks Like How does VuReact compile Vue 3's defineExpose() to React? Neo-VECTR's Rift Ascent Idempotency Keys: The API Safety Net You Probably Aren't Using Building E-Commerce Sites for Niche Products: Technical Lessons from Specialty Outdoor Retailers Audit Logs: The Silent Guardian of Every Serious System Open-source SDS tooling for Japanese MHLW compliance: the gap nobody filled BetAGracevI I Built a Post-Quantum Cryptographic Identity SDK for AI Agents — Here's Why It Needs to Exist Running Claude Code across multiple repos without losing context
The Caretaker Sandbox: An Offline-First Visual Playground & Template Engine powered by Gemma 4
brixtonmavu · 2026-05-23 · via DEV Community

This is a submission for the Gemma 4 Challenge: Build with Gemma 4


What I Built

The Caretaker Sandbox is a lightweight, offline-first developer playground and template deck designed for travel, remote work, and instant visual drafting. Rather than acting as a redundant code IDE, it is designed from the ground up to be a pocket instrument—perfect for crafting visual blocks such as transactional templates, responsive layouts, sign-off slips, forms, and custom web cards.

The Purpose: Design On-The-Go, Healed by AI

We’ve all had those moments on a flight, train ride, or deep in a cafe with spotty Wi-Fi: you want to spin up a quick, highly stylized mock or format a piece of dynamic HTML/CSS, but spinning up heavy development servers or depending on cloud environments fails.

The Caretaker Sandbox solves this with a two-track architecture:

  1. Fully Isolated Offline Core: You can code, inject responsive custom styles, preview in an isolated frame, and toggle boilerplates (like the DHAS Secure Visa or Invoice details) completely offline. It features a custom client-side syntax highlighter, interactive panels, and a custom state difference tracker with full Undo/Redo historical control.
  2. Gemma 4 Cyber-Caretaker (Online-Ready): The moment your device hits a connection, Gemma 4 is unlocked as a powerful structural assistant. Directly inside your sandbox workspace, it can instantly generate responsive designs, auto-diagnose and heal runtime syntax bugs, or manage physical workspace files in your sandboxed filesystem using smart, semantic commands.

Elegant "Cyber Midnight" Theme Palette

To prevent developer eye strain under dark airplane cabins or dimly lit environments, the entire template editing deck is built with a bespoke, Obsidian-inspired premium cyber styling palette utilizing customized hex tokens:

  • Darkest Obsidian Onyx (#060609 / #0c0d12) for background layers and editing panels.
  • Vibrant Lavender & Soft Violet (#a78bfa / #c084fc) for key action items and active visual splits.
  • Vivid Emerald Green (#10b981 / #34d399) for success indicators and string variables.
  • Neon Pink & Cyber Pink (#f472b6) for syntax keywords and UI triggers.
  • Warm Tangerine (#fb923c / #f59e0b) for warnings and structural properties.

Demo

Experience the live visual sandbox environment here:


Code

The application contains zero redundant heavy full-stack frameworks—no React, Express, or Vite compilation scripts blocking start times. It is built as a pure Node.js HTTP command plane and client-side web sandbox.

The backend maps routes with nanosecond response times using standard built-in streams. It routes instructions straight to Google's official @google/genai client.

Inside the Schema-Restricted Core

Here is how we configure the prompt instructions in gemini.ts to guarantee flawless, instant visual renderings:

import { GoogleGenAI, Type } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

export async function generateTemplate(prompt: string) {
  const systemInstruction = `You are a professional Cyberpunk Web Template Generator. Return ONLY a JSON object with keys "html", "css", "js".
Do not wrap your response in markdown fences and do not add any explanation or text outside the JSON. It must be a valid, parsed, complete JSON.`;

  const response = await ai.models.generateContent({
    model: "gemini-3.5-flash",
    contents: `Generate a web template for: ${prompt}`,
    config: {
      systemInstruction,
      responseMimeType: "application/json",
      responseSchema: {
        type: Type.OBJECT,
        properties: {
          html: { type: Type.STRING, description: "HTML layout structure containing components." },
          css: { type: Type.STRING, description: "Beautiful stylesheets and styling properties." },
          js: { type: Type.STRING, description: "Raw JavaScript code adding interactivity and state handlers." }
        },
        required: ["html", "css", "js"]
      }
    }
  });

  return response.text || "{}";
}

Enter fullscreen mode Exit fullscreen mode


How I Used Gemma 4

Integrating highly capable models like Gemma 4 to operate as a physical supervisor over real visual design files involves heavy semantic reasoning. We tailored our setup to accommodate two paths: online high-end compilation and offline edge-computing execution.

Models Chosen

  • Gemma 4 31B Dense (Primary Studio Caretaker): When connected to the network, we leverage the robust, state-of-the-art Gemma 4 31B Dense reasoning path (proxied via the client). The 31B Dense architecture is the ideal fit here. Designing websites requires a holistic understanding of how nested layers relate to class indicators and dynamic DOM query selectors. The 31B model exhibits high spatial layout intelligence, drafting complex multi-column grids and writing pristine vanilla functions that execute without logical collision.
  • Gemma 4 E4B / E2B (Edge & Offline Travel Companions): Because of our travel-first commitment, offline developers can run the lightweight Gemma 4 E4B or E2B models directly on their device via local runners (e.g., llama.cpp or Ollama inside native Terminal environments), using this frontend sandbox as an interactive local editor container.

The Caretaker's Three Modules

  1. The Visual Synthesizer (generateTemplate): Translates standard English prompts into an immediately renderable { html, css, js } JSON block. Enforcing strict JSON outputs prevents annoying markdown code block symbols from clogging up compilation streams.
  2. The Code Caretaker Auto-Healer (fixTemplate): When your layout looks off or throws a standard error, you type a short guideline. Gemma 4 reads the current code bundle alongside your visual critique, refactoring only the buggy segments while reserving the rest.
  3. The Virtual CRUD Filesystem Manager (caretakerCrud): Translates loose instructions like "Save this design in a folder named templates under visa.html" into safe CRUD JSON directives. The Node server executes these securely into process-isolated generated spaces.

Summary Comparison

Whether you are looking for an elegant drafting tool or diving deep into the code underpinnings, here is a quick overview of why the Sandbox stands as a high-craft utility:

For the Technical Developer For the Creative / Non-Technical Reader
Pure Event-Driven Node Server: Leverages the native HTTP server module, eliminating the overhead of bloated modern frameworks. Instant Visual Feedback: Write layout descriptions in plain English and see them turn into operational web blocks immediately.
Strict JSON Schemas: Validated type constraints prevent API text hallucination and ensure 100% stable parser mapping. Zero Setup Work: Start creating in your browser right away without dealing with installations or configurations.
Immutable Undo/Redo Differ: An array-bound history ring captures state snapshots, ensuring zero-loss rollbacks. Aesthetic Dark Mode: A gorgeous Obsidian Onyx color canvas that is gentle on your eyes during long late-night sessions.
Regex-Driven Client-Side Tokenizer: A lightweight syntax highlighter parses and colors tags, classes, properties, and strings instantly in memory. Pre-Loaded Templates: Access preset templates (like interactive invoices or form pads) right out of the box.

Submission authored by Brixton Mavu (@brixtonmavu on DEV.to)