Spec‑first GitHub‑hosted · Supabase‑powered · Agent‑implementable

Turn any static site or game into a live, realtime canvas bound to Supabase.

This page is a self‑contained implementation contract. Any developer or autonomous agent can read it, wire it up to Supabase, and ship a fully dynamic, realtime‑synchronized UI or game world from a static GitHub Pages frontend.

No backend servers · Supabase only Safe for GitHub Pages (no secrets) Designed for agents & human devs
Architecture snapshot
Frontend: Static GitHub Pages
Backend: Supabase (Postgres + Realtime + Edge Functions)
Every element or game object is bound to a row in: ui_elements, game_objects, events.
Realtime WebSockets RLS‑safe Agent‑friendly schema
Binding contract
Each DOM element or game object has a stable ID.
That ID maps directly to a Supabase row.
Realtime subscriptions keep all clients in sync:
// UI
channel('ui-sync') → ui_elements

// Game
channel('game-sync') → game_objects

// Events
channel('events') → events
Implementation spec · Dynamic Realtime Supabase‑Bound UI/Game System
Mode: READ‑ONLY SPEC

1. Overview

This system converts any static website or game into a fully dynamic, realtime‑synchronized environment where every UI element or game object is bound to a Supabase variable.

The frontend is hosted on GitHub Pages (or any static host). All state is stored, updated, and broadcast through Supabase Postgres + Realtime + Edge Functions.

Implementations must ensure:

  • All UI/game elements are data‑driven
  • All state changes propagate instantly
  • All clients stay synchronized
  • All updates respect Row Level Security (RLS)
  • No secrets are exposed in the frontend

2. High‑level architecture

  • Frontend: Static HTML/JS/CSS on GitHub Pages
  • Backend: Supabase (Postgres, Realtime, Edge Functions)
  • Transport: WebSockets via Supabase Realtime
  • State: Tables ui_elements, game_objects, events
Intent: This spec is meant to be agent‑implementable. Any GitHub Agent, Supabase Edge Agent, or human developer can follow it to wire up a live system without needing additional context from the original author.
Frontend starter · GitHub Pages + Supabase client
Drop‑in snippet: <script>…</script>

Minimal Supabase client wiring

Replace SUPABASE_URL and SUPABASE_ANON_KEY with your project values. Keep the anon key only; never expose the service role key.

HTML · Script include
<!-- Supabase client (ESM) -->
<script type="module">
  import { createClient } from "https://esm.sh/@supabase/supabase-js@2";

  const SUPABASE_URL = "https://YOUR-PROJECT.supabase.co";
  const SUPABASE_ANON_KEY = "YOUR_PUBLIC_ANON_KEY";

  export const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);

  // Example: initial fetch of UI elements
  async function bootstrapUi() {
    const { data, error } = await supabase
      .from("ui_elements")
      .select("*");

    if (error) {
      console.error("Failed to load ui_elements", error);
      return;
    }

    (data || []).forEach(row => {
      renderElement(row.id, row.type, row.value || {});
    });
  }

  // Implement renderElement as per spec
  function renderElement(id, type, value) {
    const el = document.getElementById(id);
    if (!el) return;

    if (type === "text" && typeof value.text === "string") {
      el.textContent = value.text;
    }

    if (value.style && typeof value.style === "object") {
      Object.entries(value.style).forEach(([k, v]) => {
        el.style[k] = v;
      });
    }
  }

  // Realtime subscription for UI
  const uiChannel = supabase
    .channel("ui-sync")
    .on(
      "postgres_changes",
      { event: "*", schema: "public", table: "ui_elements" },
      payload => {
        const row = payload.new;
        renderElement(row.id, row.type, row.value || {});
      }
    )
    .subscribe();

  bootstrapUi();
</script>

Example: binding DOM to Supabase

Give your elements IDs that match ui_elements.id:

<h1 id="hero-title">Placeholder title</h1>
<p id="hero-subtitle">Placeholder subtitle</p>

Once the Supabase project is wired and seeded, these values will be overwritten by the data in ui_elements.

How to use this page

  • 1. Fork the repo / copy this HTML into your own GitHub Pages site.
  • 2. Create a Supabase project and run the schema SQL.
  • 3. Replace the Supabase URL + anon key in the client snippet.
  • 4. Implement any custom rendering logic for your game or UI.
  • 5. Extend the spec as needed, keeping the core contract intact.
Funding note: This page is intentionally lightweight and static. It’s designed so that other developers and agents can pick it up, wire Supabase, and build on top of it without requiring additional infrastructure or paid services beyond Supabase itself.