<?xml version="1.0" encoding="utf-8" standalone="yes"?><rssversion="2.0"xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Eric X. Liu's Personal Page</title><link>/</link><description>Recent content on Eric X. Liu's Personal Page</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 03 Aug 2025 08:37:28 -0700</lastBuildDate><atom:linkhref="/index.xml"rel="self"type="application/rss+xml"/><item><title>A Deep Dive into PPO for Language Models</title><link>/posts/a-deep-dive-into-ppo-for-language-models/</link><pubDate>Sat, 02 Aug 2025 00:00:00 +0000</pubDate><guid>/posts/a-deep-dive-into-ppo-for-language-models/</guid><description><p>Large Language Models (LLMs) have demonstrated astonishing capabilities, but out-of-the-box, they are simply powerful text predictors. They don&rsquo;t inherently understand what makes a response helpful, harmless, or aligned with human values. The technique that has proven most effective at bridging this gap is Reinforcement Learning from Human Feedback (RLHF), and at its heart lies a powerful algorithm: Proximal Policy Optimization (PPO).</p>
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rssversion="2.0"xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Eric X. Liu's Personal Page</title><link>/</link><description>Recent content on Eric X. Liu's Personal Page</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 04 Aug 2025 03:59:37 +0000</lastBuildDate><atom:linkhref="/index.xml"rel="self"type="application/rss+xml"/><item><title>Supabase Deep Dive: It's Not Magic, It's Just Postgres</title><link>/posts/supabase-deep-dive/</link><pubDate>Sun, 03 Aug 2025 00:00:00 +0000</pubDate><guid>/posts/supabase-deep-dive/</guid><description><p>In the world of Backend-as-a-Service (BaaS), platforms are often treated as magic boxes. You push data in, you get data out, and you hope the magic inside scales. While this simplicity is powerful, it can obscure the underlying mechanics, leaving developers wondering what&rsquo;s really going on.</p>
<p>Supabase enters this space with a radically different philosophy: <strong>transparency</strong>. It provides the convenience of a BaaS, but it’s built on the world&rsquo;s most trusted relational database: PostgreSQL. The &ldquo;magic&rdquo; isn&rsquo;t a proprietary black box; it&rsquo;s a carefully assembled suite of open-source tools that enhance Postgres, not hide it.</p></description></item><item><title>A Deep Dive into PPO for Language Models</title><link>/posts/a-deep-dive-into-ppo-for-language-models/</link><pubDate>Sat, 02 Aug 2025 00:00:00 +0000</pubDate><guid>/posts/a-deep-dive-into-ppo-for-language-models/</guid><description><p>Large Language Models (LLMs) have demonstrated astonishing capabilities, but out-of-the-box, they are simply powerful text predictors. They don&rsquo;t inherently understand what makes a response helpful, harmless, or aligned with human values. The technique that has proven most effective at bridging this gap is Reinforcement Learning from Human Feedback (RLHF), and at its heart lies a powerful algorithm: Proximal Policy Optimization (PPO).</p>
<p>You may have seen diagrams like the one below, which outlines the RLHF training process. It can look intimidating, with a web of interconnected models, losses, and data flows.</p></description></item><item><title>Mixture-of-Experts (MoE) Models Challenges & Solutions in Practice</title><link>/posts/mixture-of-experts-moe-models-challenges-solutions-in-practice/</link><pubDate>Wed, 02 Jul 2025 00:00:00 +0000</pubDate><guid>/posts/mixture-of-experts-moe-models-challenges-solutions-in-practice/</guid><description><p>Mixture-of-Experts (MoEs) are neural network architectures that allow different parts of the model (called &ldquo;experts&rdquo;) to specialize in different types of inputs. A &ldquo;gating network&rdquo; or &ldquo;router&rdquo; learns to dispatch each input (or &ldquo;token&rdquo;) to a subset of these experts. While powerful for scaling models, MoEs introduce several practical challenges.</p>
<aclass=titlehref=/posts/supabase-deep-dive/>Supabase Deep Dive: It's Not Magic, It's Just Postgres</a></li><li><spanclass=date>August 2, 2025</span>
<aclass=titlehref=/posts/a-deep-dive-into-ppo-for-language-models/>A Deep Dive into PPO for Language Models</a></li><li><spanclass=date>July 2, 2025</span>
<aclass=titlehref=/posts/mixture-of-experts-moe-models-challenges-solutions-in-practice/>Mixture-of-Experts (MoE) Models Challenges & Solutions in Practice</a></li><li><spanclass=date>June 1, 2025</span>
<aclass=titlehref=/posts/t5-the-transformer-that-zigged-when-others-zagged-an-architectural-deep-dive/>An Architectural Deep Dive of T5</a></li><li><spanclass=date>May 1, 2025</span>
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rssversion="2.0"xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on Eric X. Liu's Personal Page</title><link>/posts/</link><description>Recent content in Posts on Eric X. Liu's Personal Page</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 03 Aug 2025 08:37:28 -0700</lastBuildDate><atom:linkhref="/posts/index.xml"rel="self"type="application/rss+xml"/><item><title>A Deep Dive into PPO for Language Models</title><link>/posts/a-deep-dive-into-ppo-for-language-models/</link><pubDate>Sat, 02 Aug 2025 00:00:00 +0000</pubDate><guid>/posts/a-deep-dive-into-ppo-for-language-models/</guid><description><p>Large Language Models (LLMs) have demonstrated astonishing capabilities, but out-of-the-box, they are simply powerful text predictors. They don&rsquo;t inherently understand what makes a response helpful, harmless, or aligned with human values. The technique that has proven most effective at bridging this gap is Reinforcement Learning from Human Feedback (RLHF), and at its heart lies a powerful algorithm: Proximal Policy Optimization (PPO).</p>
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rssversion="2.0"xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on Eric X. Liu's Personal Page</title><link>/posts/</link><description>Recent content in Posts on Eric X. Liu's Personal Page</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 04 Aug 2025 03:59:37 +0000</lastBuildDate><atom:linkhref="/posts/index.xml"rel="self"type="application/rss+xml"/><item><title>Supabase Deep Dive: It's Not Magic, It's Just Postgres</title><link>/posts/supabase-deep-dive/</link><pubDate>Sun, 03 Aug 2025 00:00:00 +0000</pubDate><guid>/posts/supabase-deep-dive/</guid><description><p>In the world of Backend-as-a-Service (BaaS), platforms are often treated as magic boxes. You push data in, you get data out, and you hope the magic inside scales. While this simplicity is powerful, it can obscure the underlying mechanics, leaving developers wondering what&rsquo;s really going on.</p>
<p>Supabase enters this space with a radically different philosophy: <strong>transparency</strong>. It provides the convenience of a BaaS, but it’s built on the world&rsquo;s most trusted relational database: PostgreSQL. The &ldquo;magic&rdquo; isn&rsquo;t a proprietary black box; it&rsquo;s a carefully assembled suite of open-source tools that enhance Postgres, not hide it.</p></description></item><item><title>A Deep Dive into PPO for Language Models</title><link>/posts/a-deep-dive-into-ppo-for-language-models/</link><pubDate>Sat, 02 Aug 2025 00:00:00 +0000</pubDate><guid>/posts/a-deep-dive-into-ppo-for-language-models/</guid><description><p>Large Language Models (LLMs) have demonstrated astonishing capabilities, but out-of-the-box, they are simply powerful text predictors. They don&rsquo;t inherently understand what makes a response helpful, harmless, or aligned with human values. The technique that has proven most effective at bridging this gap is Reinforcement Learning from Human Feedback (RLHF), and at its heart lies a powerful algorithm: Proximal Policy Optimization (PPO).</p>
<p>You may have seen diagrams like the one below, which outlines the RLHF training process. It can look intimidating, with a web of interconnected models, losses, and data flows.</p></description></item><item><title>Mixture-of-Experts (MoE) Models Challenges & Solutions in Practice</title><link>/posts/mixture-of-experts-moe-models-challenges-solutions-in-practice/</link><pubDate>Wed, 02 Jul 2025 00:00:00 +0000</pubDate><guid>/posts/mixture-of-experts-moe-models-challenges-solutions-in-practice/</guid><description><p>Mixture-of-Experts (MoEs) are neural network architectures that allow different parts of the model (called &ldquo;experts&rdquo;) to specialize in different types of inputs. A &ldquo;gating network&rdquo; or &ldquo;router&rdquo; learns to dispatch each input (or &ldquo;token&rdquo;) to a subset of these experts. While powerful for scaling models, MoEs introduce several practical challenges.</p>
<!doctype html><htmllang=en><head><title>Supabase Deep Dive: It's Not Magic, It's Just Postgres · Eric X. Liu's Personal Page</title><metacharset=utf-8><metaname=viewportcontent="width=device-width,initial-scale=1"><metaname=color-schemecontent="light dark"><metaname=authorcontent="Eric X. Liu"><metaname=descriptioncontent="In the world of Backend-as-a-Service (BaaS), platforms are often treated as magic boxes. You push data in, you get data out, and you hope the magic inside scales. While this simplicity is powerful, it can obscure the underlying mechanics, leaving developers wondering what’s really going on.
Supabase enters this space with a radically different philosophy: transparency. It provides the convenience of a BaaS, but it’s built on the world’s most trusted relational database: PostgreSQL. The “magic” isn’t a proprietary black box; it’s a carefully assembled suite of open-source tools that enhance Postgres, not hide it."><metaname=keywordscontent="software engineer,performance engineering,Google engineer,tech blog,software development,performance optimization,Eric Liu,engineering blog,mountain biking,Jeep enthusiast,overlanding,camping,outdoor adventures"><metaname=twitter:cardcontent="summary"><metaname=twitter:titlecontent="Supabase Deep Dive: It's Not Magic, It's Just Postgres"><metaname=twitter:descriptioncontent="In the world of Backend-as-a-Service (BaaS), platforms are often treated as magic boxes. You push data in, you get data out, and you hope the magic inside scales. While this simplicity is powerful, it can obscure the underlying mechanics, leaving developers wondering what’s really going on.
Supabase enters this space with a radically different philosophy: transparency. It provides the convenience of a BaaS, but it’s built on the world’s most trusted relational database: PostgreSQL. The “magic” isn’t a proprietary black box; it’s a carefully assembled suite of open-source tools that enhance Postgres, not hide it."><metaproperty="og:url"content="/posts/supabase-deep-dive/"><metaproperty="og:site_name"content="Eric X. Liu's Personal Page"><metaproperty="og:title"content="Supabase Deep Dive: It's Not Magic, It's Just Postgres"><metaproperty="og:description"content="In the world of Backend-as-a-Service (BaaS), platforms are often treated as magic boxes. You push data in, you get data out, and you hope the magic inside scales. While this simplicity is powerful, it can obscure the underlying mechanics, leaving developers wondering what’s really going on.
Supabase enters this space with a radically different philosophy: transparency. It provides the convenience of a BaaS, but it’s built on the world’s most trusted relational database: PostgreSQL. The “magic” isn’t a proprietary black box; it’s a carefully assembled suite of open-source tools that enhance Postgres, not hide it."><metaproperty="og:locale"content="en"><metaproperty="og:type"content="article"><metaproperty="article:section"content="posts"><metaproperty="article:published_time"content="2025-08-03T00:00:00+00:00"><metaproperty="article:modified_time"content="2025-08-04T03:59:37+00:00"><linkrel=canonicalhref=/posts/supabase-deep-dive/><linkrel=preloadhref=/fonts/fa-brands-400.woff2as=fonttype=font/woff2crossorigin><linkrel=preloadhref=/fonts/fa-regular-400.woff2as=fonttype=font/woff2crossorigin><linkrel=preloadhref=/fonts/fa-solid-900.woff2as=fonttype=font/woff2crossorigin><linkrel=stylesheethref=/css/coder.min.6445a802b9389c9660e1b07b724dcf5718b1065ed2d71b4eeaf981cc7cc5fc46.cssintegrity="sha256-ZEWoArk4nJZg4bB7ck3PVxixBl7S1xtO6vmBzHzF/EY="crossorigin=anonymousmedia=screen><linkrel=stylesheethref=/css/coder-dark.min.a00e6364bacbc8266ad1cc81230774a1397198f8cfb7bcba29b7d6fcb54ce57f.cssintegrity="sha256-oA5jZLrLyCZq0cyBIwd0oTlxmPjPt7y6KbfW/LVM5X8="crossorigin=anonymousmedia=screen><linkrel=icontype=image/svg+xmlhref=/images/favicon.svgsizes=any><linkrel=icontype=image/pnghref=/images/favicon-32x32.pngsizes=32x32><linkrel=icontype=image/pnghref=/images/favicon-16x16.pngsizes=16x16><linkrel=apple-touch-iconhref=/images/apple-touch-icon.png><linkrel=apple-touch-iconsizes=180x180href=/images/apple-touch-icon.png><linkrel=manifesthref=/site.webmanifest><linkrel=mask-iconhref=/images/safari-pinned-tab.svgcolor=#5bbad5></head><bodyclass="preload-transitions colorscheme-auto"><divclass=float-container><aid=dark-mode-toggleclass=colorscheme-toggle><iclass="fa-solid fa-adjust fa-fw"aria-hidden=true></i></a></div><mainclass=wrapper><navclass=navigation><sectionclass=container><aclass=navigation-titlehref=/>Eric X. Liu's Personal Page
</a><inputtype=checkboxid=menu-toggle>
<labelclass="menu-button float-right"for=menu-toggle><iclass="fa-solid fa-bars fa-fw"aria-hidden=true></i></label><ulclass=navigation-list><liclass=navigation-item><aclass=navigation-linkhref=/posts/>Posts</a></li><liclass=navigation-item><aclass=navigation-linkhref=https://chat.ericxliu.me>Chat</a></li><liclass=navigation-item><aclass=navigation-linkhref=https://git.ericxliu.me/user/oauth2/Authenitk>Git</a></li><liclass=navigation-item><aclass=navigation-linkhref=https://coder.ericxliu.me/api/v2/users/oidc/callback>Coder</a></li><liclass=navigation-item><aclass=navigation-linkhref=https://rss.ericxliu.me/oauth2/oidc/redirect>RSS</a></li><liclass=navigation-item><aclass=navigation-linkhref=/>|</a></li><liclass=navigation-item><aclass=navigation-linkhref=https://sso.ericxliu.me>Sign in</a></li></ul></section></nav><divclass=content><sectionclass="container post"><article><header><divclass=post-title><h1class=title><aclass=title-linkhref=/posts/supabase-deep-dive/>Supabase Deep Dive: It's Not Magic, It's Just Postgres</a></h1></div><divclass=post-meta><divclass=date><spanclass=posted-on><iclass="fa-solid fa-calendar"aria-hidden=true></i>
8-minute read</span></div></div></header><divclass=post-content><p>In the world of Backend-as-a-Service (BaaS), platforms are often treated as magic boxes. You push data in, you get data out, and you hope the magic inside scales. While this simplicity is powerful, it can obscure the underlying mechanics, leaving developers wondering what’s really going on.</p><p>Supabase enters this space with a radically different philosophy: <strong>transparency</strong>. It provides the convenience of a BaaS, but it’s built on the world’s most trusted relational database: PostgreSQL. The “magic” isn’t a proprietary black box; it’s a carefully assembled suite of open-source tools that enhance Postgres, not hide it.</p><p>This deep dive will deconstruct that suite. We will move beyond the basics to explore the architectural patterns, security models, and development workflows that allow you to build robust, scalable applications. We will cover:</p><ul><li><strong>The Supabase Blueprint:</strong> A procedural guide to designing your application.</li><li><strong>The Pillars of Supabase:</strong> A detailed look at Auth, Storage, Functions, and Realtime.</li><li><strong>Transactional Realtime:</strong> How Supabase guarantees data consistency in a live environment.</li><li><strong>Best Practices:</strong> The practical knowledge you need before writing a single line of code.</li></ul><h3id=the-guiding-philosophy-your-database-as-the-source-of-truth>The Guiding Philosophy: Your Database as the Source of Truth
<aclass=heading-linkhref=#the-guiding-philosophy-your-database-as-the-source-of-truth><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h3><p>The most critical shift when adopting Supabase is to see your database as more than just a data store. It is your <strong>single source of truth</strong>. This means your database schema is responsible for:</p><ul><li><strong>Structure:</strong> The tables and columns that define your data.</li><li><strong>Relationships:</strong> The foreign keys that link tables together.</li><li><strong>Integrity:</strong> The constraints (<code>NOT NULL</code>, <code>UNIQUE</code>) that ensure your data is always valid.</li><li><strong>Security:</strong> The access control rules that define who can do what.</li></ul><p>By leveraging PostgreSQL’s native power, you get <strong>full ACID compliance</strong> (Atomicity, Consistency, Isolation, Durability) out of the box. You don’t need to worry about application-level code to prevent orphan records or inconsistent states; the database guarantees it for you.</p><h3id=the-supabase-design-blueprint-a-procedural-guide>The Supabase Design Blueprint: A Procedural Guide
<aclass=heading-linkhref=#the-supabase-design-blueprint-a-procedural-guide><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h3><p>To build a scalable application, follow a structured design process that moves from abstract ideas to concrete implementation.</p><h4id=phase-1-conceptual-modeling-the-blueprint>Phase 1: Conceptual Modeling (The Blueprint)
<aclass=heading-linkhref=#phase-1-conceptual-modeling-the-blueprint><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h4><p>Before touching the Supabase dashboard, map out your application on paper.</p><ol><li><strong>Identify the “Nouns”:</strong> These are your core data objects, which will become your database tables. For a project management app, they are <code>projects</code>, <code>tasks</code>, <code>users</code>, <code>comments</code>.</li><li><strong>Define the “Verbs”:</strong> These are the user actions. “A user <em>creates</em> a task.”“A user <em>assigns</em> a task to another user.” These actions will inform your security policies and APIs.</li><li><strong>Map Relationships:</strong> How do the nouns connect? A <code>task</code> belongs to one <code>project</code>. A <code>user</code> can have many <code>tasks</code>. A <code>project</code> can have many <code>users</code> (a many-to-many relationship, requiring a <code>project_users</code> join table).</li></ol><h4id=phase-2-the-foundation-schema--migrations>Phase 2: The Foundation (Schema & Migrations)
<aclass=heading-linkhref=#phase-2-the-foundation-schema--migrations><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h4><p>Translate your model into SQL. For any serious project, use the <strong>Supabase CLI</strong> to manage this process.</p><ol><li><strong>Develop Locally:</strong> Run a full Supabase stack on your machine with <code>supabase start</code>.</li><li><strong>Create Migration Files:</strong> Write your <code>CREATE TABLE</code> statements in SQL files. Define columns, data types, and foreign key <code>REFERENCES</code> to enforce your relationships.</li><li><strong>Version Control:</strong> Commit these migration files to Git. Your database schema is now version-controlled alongside your application code.</li><li><strong>Deploy:</strong> Use <code>supabase db push</code> to apply your migrations to your live production database. This workflow is safe, repeatable, and professional.</li></ol><h4id=phase-3-the-security-layer-row-level-security>Phase 3: The Security Layer (Row Level Security)
<aclass=heading-linkhref=#phase-3-the-security-layer-row-level-security><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h4><p>This is not an optional step. RLS is the cornerstone of Supabase security.</p><ol><li><strong>Deny by Default:</strong> For any table holding user data, immediately enable RLS. This blocks all access until you explicitly grant it.</li></ol><divclass=highlight><pretabindex=0style=color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-sqldata-lang=sql><spanstyle=display:flex><span><spanstyle=color:#ff7b72>ALTER</span><spanstyle=color:#6e7681></span><spanstyle=color:#ff7b72>TABLE</span><spanstyle=color:#6e7681></span>tasks<spanstyle=color:#6e7681></span>ENABLE<spanstyle=color:#6e7681></span><spanstyle=color:#ff7b72>ROW</span><spanstyle=color:#6e7681></span><spanstyle=color:#ff7b72>LEVEL</span><spanstyle=color:#6e7681></span><spanstyle=color:#ff7b72>SECURITY</span>;<spanstyle=color:#6e7681>
</span></span></span></code></pre></div><olstart=2><li><strong>Write “Allow” Policies:</strong> Create policies based on your user stories. Policies are SQL rules that the database enforces on every single query.</li></ol><divclass=highlight><pretabindex=0style=color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-sqldata-lang=sql><spanstyle=display:flex><span><spanstyle=color:#8b949e;font-style:italic>-- Users can see tasks in projects they are a member of.
</span></span></span><spanstyle=display:flex><span><spanstyle=color:#8b949e;font-style:italic></span><spanstyle=color:#ff7b72>CREATE</span><spanstyle=color:#6e7681></span>POLICY<spanstyle=color:#6e7681></span><spanstyle=color:#a5d6ff>"Allow read access to tasks in user's projects"</span><spanstyle=color:#6e7681>
</span></span></span><spanstyle=display:flex><span><spanstyle=color:#6e7681></span><spanstyle=color:#8b949e;font-style:italic>-- Users can only insert tasks for themselves.
</span></span></span><spanstyle=display:flex><span><spanstyle=color:#8b949e;font-style:italic></span><spanstyle=color:#ff7b72>CREATE</span><spanstyle=color:#6e7681></span>POLICY<spanstyle=color:#6e7681></span><spanstyle=color:#a5d6ff>"Allow users to create their own tasks"</span><spanstyle=color:#6e7681>
</span></span></span></code></pre></div><p>The <code>auth.uid()</code> function is a special Supabase utility that securely returns the ID of the logged-in user making the request.</p><h4id=phase-4-the-apis-data-access>Phase 4: The APIs (Data Access)
<aclass=heading-linkhref=#phase-4-the-apis-data-access><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h4><p>With your data structured and secured, you can now build the access points.</p><ul><li><strong>For Simple CRUD:</strong> Use Supabase’s auto-generated API. It’s convenient, respects all your RLS policies, and is perfect for simple reads and writes on a single table.</li></ul><divclass=highlight><pretabindex=0style=color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javascriptdata-lang=javascript><spanstyle=display:flex><span><spanstyle=color:#ff7b72>const</span> { data, error } <spanstyle=color:#ff7b72;font-weight:700>=</span><spanstyle=color:#ff7b72>await</span> supabase.from(<spanstyle=color:#a5d6ff>'tasks'</span>).select(<spanstyle=color:#a5d6ff>'*'</span>);
</span></span></code></pre></div><ul><li><strong>For Complex Logic:</strong> Use PostgreSQL Functions (RPC). Encapsulate complex <code>JOIN</code>s or multi-step transactions into a single, callable function. This reduces network chattiness and keeps your business logic secure on the server.</li></ul><divclass=highlight><pretabindex=0style=color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-sqldata-lang=sql><spanstyle=display:flex><span><spanstyle=color:#8b949e;font-style:italic>-- A function to get a task and its project name in one call
</span></span></span></code></pre></div><divclass=highlight><pretabindex=0style=color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javascriptdata-lang=javascript><spanstyle=display:flex><span><spanstyle=color:#8b949e;font-style:italic>// Called simply from the frontend
</span></span></code></pre></div><h3id=a-tour-of-the-core-services>A Tour of the Core Services
<aclass=heading-linkhref=#a-tour-of-the-core-services><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h3><p>Beyond the database, Supabase provides a suite of essential tools.</p><h4id=authentication>Authentication
<aclass=heading-linkhref=#authentication><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h4><p>A complete user management system that integrates directly with your database. When a user signs up, a corresponding entry is created in the managed <code>auth.users</code> table, which you can then reference in your own tables.</p><divclass=highlight><pretabindex=0style=color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javascriptdata-lang=javascript><spanstyle=display:flex><span><spanstyle=color:#8b949e;font-style:italic>// Sign up a new user and handle social logins with ease
<aclass=heading-linkhref=#storage><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h4><p>A simple, S3-compatible object store for managing files like user avatars or documents. It’s integrated with Postgres and RLS, allowing you to write fine-grained access policies on files and folders (buckets).</p><divclass=highlight><pretabindex=0style=color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javascriptdata-lang=javascript><spanstyle=display:flex><span><spanstyle=color:#8b949e;font-style:italic>// Upload a user avatar to a public 'avatars' bucket
</span></span></code></pre></div><h4id=edge-functions-vs-database-functions>Edge Functions vs. Database Functions
<aclass=heading-linkhref=#edge-functions-vs-database-functions><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h4><p>It’s critical to know when to use which.</p><ul><li><strong>Database Functions (SQL):</strong> For data-intensive logic <em>inside</em> your database.</li><li><strong>Edge Functions (TypeScript/Deno):</strong> For connecting to the outside world. Use them to call third-party APIs (like Stripe for payments) or run computations that are not well-suited for SQL. This is where you use your secret <code>service_role</code> key, as the function runs in a trusted server environment.</li></ul><h3id=the-realtime-engine-a-pubsub-system-for-postgres>The Realtime Engine: A Pub/Sub System for Postgres
<aclass=heading-linkhref=#the-realtime-engine-a-pubsub-system-for-postgres><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h3><p>Supabase’s Realtime engine is a powerful feature for building live, interactive experiences.</p><h4id=how-it-works-logical-replication>How it Works: Logical Replication
<aclass=heading-linkhref=#how-it-works-logical-replication><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h4><p>It’s not magic; it leverages a core PostgreSQL feature.</p><ol><li>When you enable Realtime on a table, Supabase creates a <strong>Publication</strong> for it.</li><li>The Realtime server subscribes to this publication via a <strong>Logical Replication Slot</strong>.</li><li>When a transaction is <strong>successfully committed</strong> to your database, the change is written to Postgres’s Write-Ahead Log (WAL).</li><li>The WAL change is then sent to the Realtime server through the replication slot.</li><li>The server converts this database event into a JSON payload and broadcasts it over a WebSocket to all subscribed clients.</li></ol><h4id=transactional-integrity>Transactional Integrity
<aclass=heading-linkhref=#transactional-integrity><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h4><p>The most important guarantee of this system is its relationship with database transactions. An event is <strong>only broadcast <em>after</em> a transaction is fully and successfully committed.</strong> If a transaction is rolled back due to an error, the replication slot receives nothing, and no Realtime event is ever sent. This means you can trust that every Realtime message you receive corresponds to data that is permanently and consistently stored in your database.</p><h4id=use-cases-and-limitations>Use Cases and Limitations
<aclass=heading-linkhref=#use-cases-and-limitations><iclass="fa-solid fa-link"aria-hidden=truetitle="Link to heading"></i>
<spanclass=sr-only>Link to heading</span></a></h4><ul><li><strong>Use For:</strong> Small, JSON-based messages like chat messages, live notifications, activity feeds, and presence indicators (“who’s online”). Use the <code>broadcast</code> feature for ephemeral data like cursor positions that you don’t need to save.</li><li><strong>Do NOT Use For:</strong> Large, continuous data streams. It is <strong>not</strong> a replacement for WebRTC for video/audio calls. The system is designed for small, infrequent payloads.</li></ul><divclass=highlight><pretabindex=0style=color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4><codeclass=language-javascriptdata-lang=javascript><spanstyle=display:flex><span><spanstyle=color:#ff7b72>const</span> channel <spanstyle=color:#ff7b72;font-weight:700>=</span> supabase.channel(<spanstyle=color:#a5d6ff>'public:messages'</span>);
</span></span><spanstyle=display:flex><span>
</span></span><spanstyle=display:flex><span><spanstyle=color:#8b949e;font-style:italic>// Subscribe to new rows in the 'messages' table
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.