<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: makuna hatata</title>
    <description>The latest articles on DEV Community by makuna hatata (@naavvviiinnnn).</description>
    <link>https://dev.to/naavvviiinnnn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4058475%2F285d248e-c25e-4fb5-a6ed-d34d2a2ad962.png</url>
      <title>DEV Community: makuna hatata</title>
      <link>https://dev.to/naavvviiinnnn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/naavvviiinnnn"/>
    <language>en</language>
    <item>
      <title>How I built a live global scoreboard for $0 using Static HTML and Supabase published: true</title>
      <dc:creator>makuna hatata</dc:creator>
      <pubDate>Sat, 01 Aug 2026 22:15:19 +0000</pubDate>
      <link>https://dev.to/naavvviiinnnn/how-i-built-a-live-global-scoreboard-for-0-using-static-html-and-supabasepublished-true-5apm</link>
      <guid>https://dev.to/naavvviiinnnn/how-i-built-a-live-global-scoreboard-for-0-using-static-html-and-supabasepublished-true-5apm</guid>
      <description>&lt;p&gt;I wanted to see how far I could push a &lt;strong&gt;$0 zero-backend stack&lt;/strong&gt; without spinning up a server, paying for hosting, or melting a free-tier database during a traffic spike.&lt;/p&gt;

&lt;p&gt;The result is &lt;strong&gt;&lt;a href="https://taptheworld.netlify.app/" rel="noopener noreferrer"&gt;Tap The World&lt;/a&gt;&lt;/strong&gt; — a single shared global scoreboard where every visitor on Earth gets ONE tap, attributed to their country in real time via IP geolocation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://taptheworld.netlify.app/" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Ftaptheworld.netlify.app%2Fbanner.png" alt="Tap The World Banner" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  🔴 Try the Live Demo: &lt;a href="https://taptheworld.netlify.app/" rel="noopener noreferrer"&gt;taptheworld.netlify.app&lt;/a&gt;
&lt;/h3&gt;




&lt;h2&gt;
  
  
  The Stack ($0 Total Cost)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Frontend:&lt;/strong&gt; One static &lt;code&gt;index.html&lt;/code&gt; file (HTML, CSS, vanilla JS)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Database:&lt;/strong&gt; Supabase (PostgreSQL on the free tier)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Hosting:&lt;/strong&gt; Netlify (static edge deployment)&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Geolocation:&lt;/strong&gt; &lt;code&gt;ipwho.is&lt;/code&gt; (free client-side IP lookup, CORS-enabled)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Engineering for Zero Servers &amp;amp; Free-Tier Limits
&lt;/h2&gt;

&lt;p&gt;When building a live public counter, the default instinct is to log an event for every tap and use WebSockets to push live updates. &lt;strong&gt;On a free tier, that will kill your database in minutes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is how I designed around those constraints:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. One Row Per Country (Not One Row Per Tap)
&lt;/h3&gt;

&lt;p&gt;Instead of inserting an event row per click, the PostgreSQL table is structured as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="n"&gt;country_counts&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;country_code&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt; &lt;span class="k"&gt;primary&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;country_name&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="k"&gt;count&lt;/span&gt; &lt;span class="nb"&gt;bigint&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The database table stays under ~200 rows forever. Whether the site gets 10 taps or 10,000 taps, query performance and storage remain completely flat.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Polling Instead of Realtime WebSockets
&lt;/h3&gt;

&lt;p&gt;Holding open a persistent WebSocket connection for every concurrent visitor drains Supabase free-tier connection limits rapidly. &lt;/p&gt;

&lt;p&gt;Instead, the frontend polls &lt;code&gt;SELECT * FROM country_counts&lt;/code&gt; every &lt;strong&gt;2 seconds&lt;/strong&gt;. For a dark split-flap departure board aesthetic, a 2-second mechanical tick feels natural and keeps server load predictable.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Locking Down Writes with &lt;code&gt;security definer&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Since there is no backend server, the browser talks directly to Supabase. To prevent anyone from opening the browser console and sending &lt;code&gt;UPDATE country_counts SET count = 999999&lt;/code&gt;, I revoked direct &lt;code&gt;INSERT&lt;/code&gt; and &lt;code&gt;UPDATE&lt;/code&gt; permissions on the table for anonymous users.&lt;/p&gt;

&lt;p&gt;All taps pass through a custom PostgreSQL function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;or&lt;/span&gt; &lt;span class="k"&gt;replace&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;tap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p_country_code&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p_country_name&lt;/span&gt; &lt;span class="nb"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;returns&lt;/span&gt; &lt;span class="nb"&gt;bigint&lt;/span&gt;
&lt;span class="k"&gt;language&lt;/span&gt; &lt;span class="n"&gt;plpgsql&lt;/span&gt;
&lt;span class="k"&gt;security&lt;/span&gt; &lt;span class="k"&gt;definer&lt;/span&gt;
&lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="err"&gt;$$&lt;/span&gt;
&lt;span class="c1"&gt;-- Secure upsert logic increments the country count atomically&lt;/span&gt;
&lt;span class="err"&gt;$$&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The public API key only has &lt;code&gt;EXECUTE&lt;/code&gt; permission on &lt;code&gt;tap()&lt;/code&gt;, making schema corruption impossible from the REST API.&lt;/p&gt;




&lt;h2&gt;
  
  
  What’s Next?
&lt;/h2&gt;

&lt;p&gt;I’m currently exploring lightweight edge-rate-limiting to supplement the client-side &lt;code&gt;localStorage&lt;/code&gt; spam check without adding backend server costs.&lt;/p&gt;

&lt;p&gt;I'd love your feedback on:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The PostgreSQL schema and function design.&lt;/li&gt;
&lt;li&gt;How you handle rate-limiting on pure static/serverless setups!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Drop a tap for your country and let me know what you think in the comments! 👇&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>showdev</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
