Overview
Supabase is a unified platform built from multiple open-source components that work together seamlessly. Each component is independently powerful, but when combined, they provide a complete backend solution.This architecture applies to both the hosted platform and self-hosted deployments. The core components remain the same.
Core Components
PostgreSQL Database
At the heart of Supabase is PostgreSQL - the world’s most advanced open-source relational database.Features
- ACID compliance for data integrity
- Advanced data types (JSON, arrays, ranges)
- Full-text search
- Geospatial queries with PostGIS
- Powerful indexing and query optimization
Extensions
- pgvector for AI/embeddings
- pg_cron for scheduled jobs
- PostGIS for location data
- pg_stat_statements for query analysis
- And 50+ more extensions
- Reliability and data integrity
- Standards compliance
- Extensibility
- Active community and ecosystem
- Battle-tested performance at scale
PostgREST
PostgREST automatically generates a RESTful API from your PostgreSQL database schema. How it works:- PostgREST introspects your database schema
- Creates REST endpoints for each table and view
- Translates HTTP requests to SQL queries
- Respects Row Level Security policies
GoTrue (Authentication)
GoTrue is a JWT-based authentication server that manages users and issues access tokens. Authentication Flow: Key Features:- Multiple Auth Methods
- Security Features
- User Management
- Email/Password - Traditional authentication
- Magic Links - Passwordless email login
- Phone/SMS - Mobile-first authentication
- Social OAuth - Google, GitHub, GitLab, Azure, Facebook, Twitter, Discord, and more
- SAML SSO - Enterprise single sign-on (Enterprise plan)
Realtime
Realtime is an Elixir server that broadcasts database changes and enables presence and broadcast features. Three Modes of Operation:- Database Changes
- Presence
- Broadcast
Listen to INSERT, UPDATE, and DELETE operations:How it works:
- PostgreSQL publishes WAL (Write-Ahead Log) changes
- Realtime server listens to the replication slot
- Filters changes based on RLS policies
- Broadcasts to subscribed clients via WebSockets
Storage
Storage provides S3-compatible object storage with PostgreSQL-based permissions. Features:Storage Capabilities
- Large file uploads (up to 5GB per file)
- Resumable uploads
- Automatic image optimization
- CDN distribution
- Signed URLs for private files
Security
- Row Level Security for file access
- Bucket-level policies
- File size and type restrictions
- Virus scanning (Enterprise)
Edge Functions
Edge Functions are server-side TypeScript functions that run on Deno at the edge, close to your users. Key Characteristics:- TypeScript/JavaScript - Familiar language and syntax
- Deno runtime - Secure by default, modern APIs
- Global distribution - Deploy to regions worldwide
- Fast cold starts - Minimal latency
- HTTP triggers - Invoke via HTTP requests
- Cron triggers - Schedule periodic execution
- Send emails or notifications
- Process payments with Stripe
- Generate PDFs or images
- Call third-party APIs
- Complex validation logic
- Data aggregation and reporting
- Webhooks from external services
pg_graphql
pg_graphql is a PostgreSQL extension that exposes a GraphQL API. Example: GraphQL QueriesKong API Gateway
Kong sits in front of all services, providing:- Request routing - Direct requests to appropriate services
- Rate limiting - Protect against abuse
- API key validation - Verify authentication
- CORS handling - Cross-origin request management
- Request/response transformation - Modify requests as needed
postgres-meta
postgres-meta provides a RESTful API for managing PostgreSQL:- Fetch tables, columns, and relationships
- Create and modify schemas
- Manage roles and permissions
- Run queries
- View database statistics
Studio Dashboard
Supabase Studio is the web-based dashboard that provides:Table Editor
Visual interface to browse and edit data, manage relationships, and view table schemas
SQL Editor
Write and execute SQL queries with autocomplete and saved snippets
Auth Management
Manage users, configure providers, and customize email templates
Storage Browser
Browse buckets, upload files, and manage storage policies
API Documentation
Auto-generated API documentation based on your schema
Database Monitoring
View query performance, connection pools, and resource usage
Request Lifecycle
Let’s trace a typical request through the Supabase stack:1
Client makes request
User application sends a request to query todos:
2
Kong receives request
Kong validates the API key and routes to PostgREST at
/rest/v1/todos3
PostgREST processes
- Parses the request into SQL
- Extracts JWT from headers
- Sets PostgreSQL session variables (
request.jwt.claims)
4
PostgreSQL executes query
- Runs the SQL query
- Evaluates Row Level Security policies using JWT claims
- Returns only rows the user has access to
5
Response returned
- PostgreSQL returns filtered results
- PostgREST formats as JSON
- Kong sends response to client
- Total round trip: ~50-100ms
Deployment Architecture
Hosted Platform
When using supabase.com:- Automatic scaling
- Global distribution
- Managed backups
- Monitoring and alerting
- No operational overhead
Self-Hosted
Using Docker Compose:- Full control
- Deploy anywhere
- No vendor lock-in
- Custom configurations
Security Architecture
Multi-Layer Security
- Network Layer
- API Layer
- Database Layer
- Application Layer
- TLS/SSL - All traffic encrypted in transit
- DDoS protection - Cloudflare protection on hosted platform
- Network isolation - Services in private networks
API Keys
Supabase provides two main keys:- anon (public) key
- service_role key
- Safe to use in browsers and mobile apps
- Has limited permissions
- Used with user JWT for authenticated requests
- RLS policies protect data
Scalability
Supabase components are designed to scale:Horizontal Scaling
- PostgREST - Stateless, can run multiple instances
- GoTrue - Scales horizontally with load balancing
- Realtime - Distributed across multiple nodes
- Storage - S3-compatible, infinitely scalable
- Edge Functions - Automatically scaled and distributed
Database Scaling
- Vertical Scaling
- Read Replicas
- Connection Pooling
Increase compute resources:
- More CPU cores
- More RAM
- Faster storage (NVMe SSDs)
- 64 CPU cores
- 256 GB RAM
- Dedicated resources
Monitoring and Observability
Built-in Monitoring
Supabase provides comprehensive monitoring:- Query Performance - Slow query logs and analysis
- Resource Usage - CPU, memory, disk, and network
- API Analytics - Request rates, response times, errors
- Realtime Connections - Active connections and channels
- Storage Metrics - Bandwidth and storage usage
Logging
Collect logs from all components:- PostgreSQL logs - Query logs, error logs
- API logs - Request/response logs
- Edge Function logs - Console output and errors
- Auth logs - Sign-in attempts and failures
- Logflare for log management
- Webhook destinations
- Custom integrations
Next Steps
Now that you understand Supabase architecture:Database Guide
Deep dive into PostgreSQL features and best practices
Auth Guide
Learn advanced authentication patterns
Realtime Guide
Build real-time collaborative features
Self-Hosting
Deploy Supabase on your infrastructure
