第 1 章 · Supabase 入门与学习路线 章节摘要:Supabase 是建立在 PostgreSQL 之上的开源 BaaS(后端即服务)平台,将关系型数据库、身份认证、行级安全、实时数据订阅、文件存储、边缘函数与向量 AI 能力整合在同一项目中,常被视为 Firebase 的开源替代。本章帮助你建立对 Supabase 的整体认知,理解其与传统后端及 NoSQL 类 BaaS 的差异,并规划一条循序渐进的学习路线,为后续逐章深入打下基础。
章节摘要:Supabase 是建立在 PostgreSQL 之上的开源 BaaS(后端即服务)平台,将关系型数据库、身份认证、行级安全、实时数据订阅、文件存储、边缘函数与向量 AI 能力整合在同一项目中,常被视为 Firebase 的开源替代。本章帮助你建立对 Supabase 的整体认知,理解其与传统后端及 NoSQL 类 BaaS 的差异,并规划一条循序渐进的学习路线,为后续逐章深入打下基础。
阅读本章后,你将能够:
Supabase 的核心价值在于「把一整套生产级后端能力直接交给开发者」。它不是重新发明数据库,而是站在成熟的关系型数据库 PostgreSQL 之上,叠加认证、安全、实时、存储、计算与 AI 等服务层,让你无需自建后端即可交付完整应用。理解这一分层结构,是掌握后续所有章节的前提。
下面的能力全景图展示了 Supabase 的整体架构:中心是一个 Supabase 项目(本质是一个托管的 PostgreSQL 数据库实例),周围环绕着构建在其上的各项服务能力。
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 760 520" font-family="Microsoft YaHei, Arial, sans-serif"> <defs> <radialGradient id="bg" cx="50%" cy="50%" r="60%"> <stop offset="0%" stop-color="#f5f7fa"/> <stop offset="100%" stop-color="#e9eef5"/> </radialGradient> </defs> <rect width="760" height="520" fill="url(#bg)"/> <text x="380" y="36" text-anchor="middle" font-size="22" font-weight="700" fill="#1f2937">Supabase 能力全景架构图</text> <!-- 中心节点:Supabase 项目 / PostgreSQL --> <circle cx="380" cy="280" r="78" fill="#3ecf8e" stroke="#2c8a63" stroke-width="2"/> <text x="380" y="270" text-anchor="middle" font-size="16" font-weight="700" fill="#ffffff">Supabase 项目</text> <text x="380" y="294" text-anchor="middle" font-size="14" fill="#eafff5">PostgreSQL 数据库</text> <!-- 七大能力节点 --> <g font-size="13" font-weight="600" fill="#1f2937"> <!-- 顶部 --> <rect x="310" y="96" width="140" height="48" rx="10" fill="#ffffff" stroke="#3ecf8e" stroke-width="1.6"/> <text x="380" y="116" text-anchor="middle">数据库 / 数据表</text> <text x="380" y="134" text-anchor="middle" font-size="11" fill="#6b7280">PostgreSQL</text> <!-- 右上 --> <rect x="560" y="150" width="150" height="48" rx="10" fill="#ffffff" stroke="#3ecf8e" stroke-width="1.6"/> <text x="635" y="170" text-anchor="middle">身份认证 Auth</text> <text x="635" y="188" text-anchor="middle" font-size="11" fill="#6b7280">JWT / OAuth</text> <!-- 右 --> <rect x="600" y="256" width="150" height="48" rx="10" fill="#ffffff" stroke="#3ecf8e" stroke-width="1.6"/> <text x="675" y="276" text-anchor="middle">行级安全 RLS</text> <text x="675" y="294" text-anchor="middle" font-size="11" fill="#6b7280">行级权限策略</text> <!-- 右下 --> <rect x="560" y="362" width="150" height="48" rx="10" fill="#ffffff" stroke="#3ecf8e" stroke-width="1.6"/> <text x="635" y="382" text-anchor="middle">实时订阅 Realtime</text> <text x="635" y="400" text-anchor="middle" font-size="11" fill="#6b7280">Postgres CDC</text> <!-- 左下 --> <rect x="50" y="362" width="150" height="48" rx="10" fill="#ffffff" stroke="#3ecf8e" stroke-width="1.6"/> <text x="125" y="382" text-anchor="middle">文件存储 Storage</text> <text x="125" y="400" text-anchor="middle" font-size="11" fill="#6b7280">S3 兼容对象存储</text> <!-- 左 --> <rect x="10" y="256" width="150" height="48" rx="10" fill="#ffffff" stroke="#3ecf8e" stroke-width="1.6"/> <text x="85" y="276" text-anchor="middle">边缘函数</text> <text x="85" y="294" text-anchor="middle" font-size="11" fill="#6b7280">Edge Functions / Deno</text> <!-- 左上 --> <rect x="50" y="150" width="150" height="48" rx="10" fill="#ffffff" stroke="#3ecf8e" stroke-width="1.6"/> <text x="125" y="170" text-anchor="middle">向量与 AI</text> <text x="125" y="188" text-anchor="middle" font-size="11" fill="#6b7280">pgvector / RAG</text> </g> <!-- 连线 --> <g stroke="#9bb3c7" stroke-width="1.4" stroke-dasharray="4 4"> <line x1="380" y1="144" x2="380" y2="202"/> <line x1="560" y1="174" x2="450" y2="248"/> <line x1="600" y1="280" x2="458" y2="280"/> <line x1="560" y1="386" x2="450" y2="312"/> <line x1="200" y1="386" x2="310" y2="312"/> <line x1="160" y1="280" x2="302" y2="280"/> <line x1="200" y1="174" x2="310" y2="248"/> </g> <text x="380" y="470" text-anchor="middle" font-size="12" fill="#6b7280">中心:托管的 PostgreSQL 项目 | 外环:构建在数据库之上的七大服务能力</text> <text x="380" y="492" text-anchor="middle" font-size="12" fill="#6b7280">各能力共享同一套身份与安全模型,可灵活组合</text> </svg>
本章从「是什么」到「怎么上手」,分为四个子章节,层层递进:
建议按顺序阅读;若你已熟悉 BaaS 概念,可直接跳到「核心能力全景图」。
本章是全教程的认知起点。第 2 章将深入数据表设计、第 3 章讲解 SQL 操作,二者构成 Supabase 的数据底座;第 4 至 5 章在数据之上叠加身份认证与行级安全;第 6 至 8 章引入实时、存储与计算等高级能力;第 9 章聚焦向量与 AI;最后由第 10 章综合实战串联所有内容。