Supabase 101
Supabase gives you a Postgres database, auth, edge functions, and real-time subscriptions — all in one platform. It's the foundation of your stack.
Step 1: Understanding Tables
Every Supabase project is a Postgres database. Data lives in tables. Let's build one interactively.
brain_context
This table stores your AI agent's memory — key-value pairs with metadata.
Step 2: SQL Sandbox
Supabase lets you run raw SQL. Practice querying your brain_context table.
This is a simulation — it runs against sample data in your browser, not a real database. In production, you'd run these same queries in the Supabase SQL Editor against your actual tables.
Step 3: Build It Step by Step
Create the project
Go to supabase.com, create a new project. Pick a region close to your users. Save your project URL and anon key.
Anon Key: eyJhbGciOiJIUzI1NiIs... // public, safe for frontend
Service Key: eyJhbGciOiJIUzI1NiIs... // SECRET, only for backend
Create the brain_context table
Use the SQL editor in your Supabase dashboard. Paste the generated SQL from Step 1 above.
Enable Row Level Security (RLS)
RLS (Row Level Security) is a Postgres feature that controls who can read or write each row. Without it, anyone with your API key could access all data. Think of it like a bouncer for every row in your table.
This SQL turns on RLS and then creates a policy that says "only the service role (your backend) gets full access." Frontend users with the public anon key will be blocked unless you add more policies.
-- Allow service role full access
CREATE POLICY "service_role_all" ON brain_context
FOR ALL
TO service_role
USING (true);
Insert your first record
This SQL adds a single row to your brain_context table — a key called "identity.name" with the value "AI Stack Builder Student". It's like writing a sticky note your AI agent can read later.
VALUES ('identity.name', '"AI Stack Builder Student"');
Why Supabase for AI Apps?
Supabase is Postgres with superpowers: Auth (user management), Edge Functions (serverless code that runs close to your users), Realtime (live subscriptions — your UI updates instantly when data changes), Storage (files/images), and pgvector (a Postgres extension that lets you store AI embeddings — numerical representations of text — so you can do similarity search, like "find memories related to this topic"). One tool covers database + backend + auth. That's why it's the foundation of most modern AI stacks.
Match Supabase Concepts
Tap one on the left, then its match on the right
Supabase Project Setup Order
Arrange these steps in the correct order to set up a new Supabase project