Bỏ qua

Supabase là gì?

Định nghĩa

Supabase là một open-source Backend-as-a-Service (BaaS) platform, được xây dựng trên nền tảng PostgreSQL.

"The Open Source Firebase Alternative"


Thành phần chính

┌─────────────────────────────────────────────────────────────────┐
│                         SUPABASE                                 │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐              │
│  │  Database   │  │    Auth     │  │   Storage   │              │
│  │ (PostgreSQL)│  │   (GoTrue)  │  │   (S3-like) │              │
│  └─────────────┘  └─────────────┘  └─────────────┘              │
│                                                                  │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐              │
│  │  REST API   │  │  Realtime   │  │    Edge     │              │
│  │ (PostgREST) │  │ (WebSocket) │  │  Functions  │              │
│  └─────────────┘  └─────────────┘  └─────────────┘              │
│                                                                  │
│  ┌─────────────┐  ┌─────────────┐                               │
│  │   Queue     │  │    Cron     │                               │
│  │   (pgmq)    │  │  (pg_cron)  │                               │
│  └─────────────┘  └─────────────┘                               │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

So sánh với Firebase

Feature Firebase Supabase
Database NoSQL (Firestore) PostgreSQL (SQL)
Open Source
Self-host
Realtime
Auth
Storage
Edge Functions ✅ (Cloud Functions) ✅ (Deno)
Pricing Pay-per-use Generous free tier
Vendor lock-in High Low

Tại sao chọn Supabase?

1. PostgreSQL Power

  • Full SQL support
  • Transactions, joins, constraints
  • Extensions (PostGIS, pgvector, pg_cron)
  • Mature ecosystem

2. Auto-generated REST API

// Không cần viết API endpoints
const { data } = await supabase
  .from('users')
  .select('id, name, posts(title)')
  .eq('active', true);

3. Built-in Auth

// OAuth trong vài dòng code
await supabase.auth.signInWithOAuth({
  provider: 'google',
});

4. Realtime out of the box

// Subscribe to changes
supabase
  .channel('posts')
  .on('postgres_changes', { event: '*', schema: 'public', table: 'posts' },
    (payload) => console.log(payload)
  )
  .subscribe();

Kiến trúc Supabase

┌──────────────────────────────────────────────────────────────┐
│                         CLIENT                                │
│  ┌────────────────────────────────────────────────────────┐  │
│  │                   supabase-js                           │  │
│  └────────────────────────────────────────────────────────┘  │
└────────────────────────────┬─────────────────────────────────┘
┌──────────────────────────────────────────────────────────────┐
│                      SUPABASE GATEWAY                         │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐     │
│  │ Kong API │  │ GoTrue   │  │ Storage  │  │ Realtime │     │
│  │ Gateway  │  │  Auth    │  │   API    │  │  Server  │     │
│  └────┬─────┘  └────┬─────┘  └────┬─────┘  └────┬─────┘     │
└───────┼─────────────┼─────────────┼─────────────┼────────────┘
        │             │             │             │
        ▼             ▼             ▼             ▼
┌──────────────────────────────────────────────────────────────┐
│                       POSTGRESQL                              │
│  ┌──────────────────────────────────────────────────────────┐│
│  │  Tables │ Functions │ Triggers │ RLS Policies │ Extensions││
│  └──────────────────────────────────────────────────────────┘│
└──────────────────────────────────────────────────────────────┘

Pricing

Free Tier (rất generous)

Resource Limit
Database 500 MB
Storage 1 GB
Bandwidth 2 GB
Edge Function invocations 500K/month
Auth MAU 50,000
Realtime 200 concurrent

Pro Tier ($25/month)

Resource Limit
Database 8 GB
Storage 100 GB
Bandwidth 250 GB
Edge Functions 2M/month
Daily backups
Email support

Use Cases phù hợp

Ideal cho

  • PoC / MVP projects
  • Startups
  • Internal tools
  • CRUD applications
  • Real-time apps (chat, notifications)
  • Side projects

Cân nhắc kỹ khi

  • Enterprise với compliance requirements
  • Extremely high throughput (> 10K req/s)
  • Complex microservices architecture
  • Specific database needs (MongoDB, Redis primary)

Tổng kết

Supabase = Backend in a Box

  1. Database - PostgreSQL với REST API tự động
  2. Auth - Email, OAuth, Magic Links
  3. Storage - File uploads với CDN
  4. Realtime - WebSocket subscriptions
  5. Edge Functions - Serverless Deno functions
  6. Queue & Cron - Background processing

Perfect for Light Development Stack

  • Giảm 80% backend code
  • Free tier đủ cho PoC
  • Open source, không vendor lock-in

Q&A

  1. Bạn đã dùng Firebase chưa? So sánh thế nào?
  2. PostgreSQL experience của bạn?
  3. Concerns nào về Supabase?