DEV Community

Cover image for Under the Hood of HYNA-Stage: How We Built a Serverless Ephemeral Cloud CLI on a $150 Phone 🐯☁️
Harun - solo dev
Harun - solo dev

Posted on Edited on

Under the Hood of HYNA-Stage: How We Built a Serverless Ephemeral Cloud CLI on a $150 Phone 🐯☁️

Yesterday, we announced that KODA Code Jam Season 3: Hacker Stage is officially LIVE.

Since then, I’ve gotten incredible questions from senior engineers asking: "How does this actually work under the hood? Is it secure? How do you handle the infrastructure?"

Today, I’m pulling back the curtain. Here is the exact technical architecture of HYNA-Stage.

πŸ—οΈ The Core Stack

  • CLI: Node.js (ES Modules), distributed via NPM (@hynaweb/stage). Uses commander for routing and ora for beautiful terminal spinners.
  • Backend Orchestration: Supabase Edge Functions (Deno runtime) + PostgreSQL.
  • Compute Provider: E2B SDK (provisioning secure Firecracker MicroVMs).
  • Frontend Dashboard: Vanilla JS + TailwindCSS, hosted on Netlify.

πŸ”’ Security & Access Control (The Hard Part)

We take security seriously, especially when AI agents are executing code.

  1. Row Level Security (RLS): Enabled on all tables. The environments table is strictly locked so SELECT is restricted to auth.uid() = user_id. You can only see your own sandboxes.
  2. API Gateway Bypass: Supabase’s default API Gateway pattern-matches standard apikey headers, which can cause false rejections for custom Edge Functions. We solved this by passing authentication via a custom x-hyna-key header, which the Deno function validates before executing any E2B logic.
  3. Ephemeral Isolation: Every hyna-stage up command spins up a single-tenant Firecracker MicroVM. When the TTL expires, the entire machine is permanently wiped. No residual data.

⚑ The Execution Flow (hyna-stage up)

  1. CLI reads your local file (e.g., index.html or app.py).
  2. Sends a secure POST request to the /deploy-stage Edge Function with your JWT.
  3. Edge Function calls Sandbox.create() via the E2B SDK.
  4. Code is injected into /home/user/, and a lightweight web server starts automatically.
  5. The Edge Function logs the environment to the environments database table.
  6. CLI outputs your live, globally accessible URL in ~5 seconds.

πŸ“– Full Documentation & User Guidelines ( TL;DR : ⚠️ the auth flow has been changed so the docs is outdated we will change it in a bit)

We believe that for a CLI product, the documentation is the product.

We’ve published our full Technical Report and User Guidelines, including database schemas, security policies, and a complete troubleshooting FAQ.

πŸ‘‰ Read the Full Docs & Try It: https://hyna-stagetemp.netlify.app/

🎯 Join the Hacker Stage Jam

The sandbox is warm, the architecture is solid, and the AI-powered leaderboard is waiting for your submissions.

Install the CLI: npm install -g @hynaweb/stage
Submit your build: https://hackerstage.netlify.app/

Let’s build the future, securely and transparently. πŸ―β˜οΈπŸš€

Top comments (0)