Back to blog

Supabase Architecture Diagram: Database, Auth, Storage & Realtime (2026)

How to create Supabase architecture diagrams covering PostgreSQL, Auth, Storage, Realtime, and Edge Functions. Includes prompt templates and common patterns for AI-generated diagrams.

R
Ryan·Senior AI Engineer
·

Supabase architecture diagrams visualize the full backend platform that many modern applications are built on — from the PostgreSQL database layer and Row Level Security policies to Auth providers, object Storage, Realtime subscriptions, and Edge Functions. Supabase's architecture is deceptively complex: under the hood, a single Supabase project comprises PostgreSQL, PostgREST, GoTrue (auth), Realtime (Elixir Phoenix), Storage API, and a Kong API gateway — all running together and communicating through well-defined interfaces.

A clear Supabase architecture diagram helps teams understand data flows, security boundaries (especially RLS policies), and where each part of their stack lives — whether they're self-hosting on Kubernetes or using Supabase Cloud.

Core components of a Supabase architecture diagram

  • PostgreSQL database: The heart of every Supabase project — show the database instance, its logical schemas (public, auth, storage, realtime), extensions like pgvector and pg_cron, and any logical replication slots used by the Realtime server
  • PostgREST (auto-generated REST API): The layer that automatically exposes your PostgreSQL schema as a RESTful API. Client libraries use this under the hood for all .from(), .select(), and .insert() calls; show it as the primary CRUD interface between the client and the database
  • GoTrue (Auth service): Handles user registration, login (email/password, magic link, OAuth providers), JWT issuance, and session management. Show the providers (Google, GitHub, Apple, etc.) connecting into GoTrue, which then issues JWTs used by PostgREST to enforce RLS
  • Row Level Security (RLS) policies: PostgreSQL RLS policies that gate data access based on auth.uid() and auth.role() from the JWT. Annotate your tables with the RLS policies that protect them — this is critical for security review diagrams
  • Supabase Storage: Object storage (backed by S3-compatible storage) with a PostgreSQL metadata layer for bucket and object permissions. Storage also uses RLS policies for fine-grained access control
  • Realtime server: An Elixir Phoenix server that subscribes to PostgreSQL logical replication and broadcasts row-level change events (INSERT, UPDATE, DELETE) to subscribed WebSocket clients. Show which tables publish changes and which clients subscribe
  • Edge Functions: Deno-based serverless functions deployed globally at Supabase's edge. Show which functions call external APIs, write to the database, or perform tasks that can't run in the browser (Stripe webhooks, email sending, background jobs)
  • Kong API gateway: The API gateway that routes requests to PostgREST, GoTrue, Storage, or Realtime based on the path prefix. The Supabase client SDK transparently uses the correct path for each service type

Common Supabase architecture patterns

Full-stack SaaS with multi-tenancy

The most common Supabase pattern: a Next.js or React frontend uses the Supabase JS client to authenticate users, query data via PostgREST, and listen for real-time updates. Each user belongs to an organization (tenant), and all tables have RLS policies that filter by organization_id. Edge Functions handle Stripe webhook processing and transactional emails. The architecture diagram should show the client, the Kong gateway, the four main services (Auth, PostgREST, Realtime, Storage), the PostgreSQL database, and the RLS policy layer between PostgREST and the database.

AI application with pgvector

Supabase's pgvector extension makes it a natural fit for AI applications that need vector search alongside relational data. In this pattern, embeddings are stored in a documents table with a vector(1536) column. An Edge Function accepts user queries, calls an embedding API (OpenAI, Cohere, or a self-hosted model), then runs match_documents() — a PostgreSQL function that uses pgvector's cosine similarity operator — to retrieve the most relevant chunks. Results are passed to an LLM for generation. The diagram shows the user query → Edge Function → embedding API → pgvector similarity search → LLM → response flow.

Self-hosted Supabase on Kubernetes

Teams with data residency or compliance requirements self-host Supabase on Kubernetes. The architecture diagram shows the Helm chart components: a PostgreSQL StatefulSet (or CloudNativePG operator), PostgREST Deployment, GoTrue Deployment, Realtime Deployment, Storage API Deployment, Kong Deployment, and the Supabase Studio Deployment. An Ingress or API Gateway routes external traffic to Kong. A persistent volume claim backs the PostgreSQL data directory. This diagram is essential for infrastructure review and DR planning.

Prompt examples for Supabase diagrams

Multi-tenant SaaS backend

"Supabase backend for a multi-tenant project management SaaS. Users authenticate via Supabase Auth (email/password + Google OAuth). The app uses Supabase JS client to call PostgREST for CRUD operations on tables: users, organizations, projects, tasks. All tables have RLS policies enforcing organization isolation using auth.uid() and an organization_members join. Supabase Realtime broadcasts task updates to all organization members subscribed to the tasks channel. File attachments are stored in Supabase Storage with per-organization bucket policies. An Edge Function handles Stripe webhook events (subscription created, cancelled) and updates the organizations table. The Next.js frontend runs on Vercel."

RAG pipeline with pgvector

"Supabase RAG architecture. Documents are uploaded via a Next.js UI → stored in Supabase Storage → an Edge Function processes them: splits text into 512-token chunks, calls OpenAI embeddings API (text-embedding-3-small), stores chunks + embeddings in a document_chunks table with vector(1536) column and pgvector HNSW index. At query time: Edge Function receives user message → generates query embedding → runs match_document_chunks(query_embedding, match_threshold=0.7, match_count=5) RPC → passes retrieved chunks as context to Claude claude-sonnet-4-6 → streams response back to client. All document access is gated by Supabase RLS (users can only search their own documents). Metadata in PostgreSQL, objects in Storage, vectors in pgvector."

Realtime collaborative app

"Supabase Realtime architecture for a collaborative whiteboard app. Users join a room (room_id). The app subscribes to Supabase Realtime Broadcast channel (room:{room_id}) for cursor positions and drawing events — these use Broadcast (not database changes) for low-latency peer-to-peer-style delivery. Persistent canvas state is stored in a canvas_objects table; the app subscribes to Postgres Changes on canvas_objects WHERE room_id = X to sync additions and deletions. User presence (who is in the room) uses Supabase Presence. Authentication via Supabase Auth (anonymous sessions allowed). The diagram shows: React client → Supabase Realtime WebSocket connection → Broadcast channel + Presence + Postgres Changes subscriptions → PostgreSQL canvas_objects table."

Supabase vs other BaaS platforms

PlatformDatabaseAuthSelf-hostable
SupabasePostgreSQL (full SQL, pgvector, RLS)GoTrue — email, OAuth, magic link, phoneYes (Docker, Kubernetes)
FirebaseFirestore (NoSQL document store)Firebase Auth — email, OAuth, phoneNo (Google Cloud only)
AppwriteMariaDB with document abstractionBuilt-in — email, OAuth, magic linkYes (Docker)
PocketBaseSQLite (single file)Built-in — email + OAuthYes (single binary)
NeonPostgreSQL (serverless, branching)None (DB only)No

What to annotate on a Supabase diagram

  • RLS policies per table: Label each table with whether RLS is enabled and the type of policy (owner-only, organization-scoped, public-read). This is the most important security annotation on a Supabase diagram
  • JWT role in each request path: Show whether requests flow through the anon key (unauthenticated) or the service_role key (bypasses RLS) — mixing these accidentally is the most common Supabase security mistake
  • Edge Function triggers: Label what invokes each Edge Function — HTTP request, database webhook, cron schedule, or Stripe event
  • Realtime channel types: Distinguish Postgres Changes (DB-driven), Broadcast (ephemeral client-to-client), and Presence (online status) — they have different latency and persistence characteristics
  • Storage bucket policies: Note whether each bucket is public or private, and whether access is controlled by RLS or bucket-level policies

Related guides: authentication architecture diagrams, vector database architecture, RAG architecture diagrams, and database architecture use cases.

Ready to try it yourself?

Start Creating - Free