











supabase
后端即服务 (BaaS) 是一种云服务,开发人员在使用BaaS进行Web或移动应用开发时,只需编写和维护前端代码。BaaS提供商为开发者提供了开发应用所需要的后端服务,例如用户身份验证、数据库管理、推送通知(针对移动应用程序),以及云存储和托管等。BaaS使开发人员能够专注于前端应用程序代码的编写。通过 BaaS 供应商提供的 API和 SDK,他们可以集成所需的所有后端功能,而无需自行构建后端。他们也不必管理服务器、虚拟机或容器,即可保持应用程序运行。因此,开发者可以更快地构建和启动移动应用程序和 Web 应用程序。
Supabase 和 Firebase 都是BaaS领域的知名品牌,可以为开发者提供后端功能服务,以帮助其更快地构建产品。其中,Supabase 是一个开源的 Firebase 替代品,而 Firebase 是 Google 提供的云服务。Supabase 和 Firebase两者之间存在竞争的关系。
Supabase凭借其开源特性与全栈能力,已成为开发者构建现代应用的热门选择。作为Firebase的替代方案,Supabase以PostgreSQL为核心,整合了实时数据库、身份认证、文件存储等关键功能,为开发者提供了兼具灵活性与高性能的后端解决方案。
https://gitcode.com/GitHub_Trending/supa/supabase?source_module=search_result_repo
https://github.com/supabase/supabase
Supabase围绕PostgreSQL整合了一系列开源工具,以实现BaaS所需的用户认证、实时数据库、对象存储和REST API接口等功能。在整合这些工具的同时,为开发者封装了统一的SDK,方便开发者以统一的方式调用这些能力。官方提供了JavaScript和Flutter的SDK,社区贡献了Python、C#、Swift和Kotlin的SDK,开发者在开发移动端和Web应用时,可以方便地调用Supabase提供的后端功能。
下面是Supabase整体架构图:

Supabase SDK
如上所述,SupaBase官方及社区贡献了目前主流的移动端和Web端的SDK,帮助开发者更容易的开发应用。Supabase SDK由众多子项目构成,通常以supabase-*命名,例如supabase-js和supabase-dart。
Supabase Studio
Studio是Supabase的管理界面,即Supabase的官方网站和项目管理控制台,这些Web及后端服务均由Studio工具实现。studio的代码在supabase的主仓库里。
Supabase CLI
Supabase的命令行管理工具,可方便地在命令行上管理项目。
postgres是一个历史比较悠久的开源组件,能够将postgresql以REST接口暴露给开发者,开发者可以直接通过HTTP接口操作数据库。
storage api
提供对象存储功能,解决开发者需要上传、下载文件的需求,比如图片、文档等。Storage API将数据存储在S3存储服务上。
用户登录认证模块可帮助用户简化其应用的用户管理流程,允许开发者使用邮箱和手机号进行注册和登录模块的开发,同时支持通过OAuth协议接入GitHub、Google和Apple等平台的账号。
realtime
Realtime利用PostgreSQL的listen/notify机制,实现了Postgres数据库的实时数据变更通知功能。
在此基础上,Supabase还提供了如下一些能力
云函数(edge function)
postgrest本身提供了调用postgresql function的能力,开发者可以在pg中用sql或者JavaScript编写函数,然后通过rpc接口调用pg的函数。pg的函数能在一定程度上解决部分业务场景的需求,但是仍旧存在一些不方便或者不直观的地方。
云函数(edge function)可以更灵活的适配一些场景,比如支付等需要跟第三方系统进行对接的场景,使用云函数可以让开发者编写后端代码并运行在服务端。
graphql是通过postgresql插件实现的,开发者在postgres建表之后,可以直接通过graphql进行数据库操作。
Web hook为开发者提供了事件触发能力,开发者可以设定满足某个条件时,自动触发外部接口的调用,从而跟第三方系统进行集成。比如跟飞书机器人集成。
PostgreSQL
一切的核心。SupaBase整个服务是围绕PostgreSQL构建的。
kong
API网关。负责将API请求路由到目标服务组件,并转发结果给用户。
postgres-meta
PostgreSQL的元数据管理组件,主要为studio提供服务,可以用来查询数据库中的表、角色,执行SQL等。
由于SupaBase组合非常多的开源组件,因此其后端服务(不包括SDK)的整体技术栈也相对复杂。使用到的开发语言和框架有:
Javascript/Typescript
Tailwind
Go
Elixir
Haskell
React
Nextjs
Phoenix
fastify
knex
chi
rust
。。。
Supabase的SDK也是通过组合多个客户端库实现的,以JavaScript SDK为例:

如上图所示,supabase-js实际上是粘合了多个不同的组件的sdk客户端,这样做的好处:
开发者不需要关注某个具体的组件如何工作,全部统一使用supabase-js的接口访问后端服务。
supabase-js帮助开发者完成了各个组件间用户认证鉴权的统一处理。
Self-Hosting with Docker | Supabase Docs
supabase/DEVELOPERS.md at master · supabase/supabase
Install dependencies
pnpm install # install dependencies
cp apps/www/.env.local.example apps/www/.env.local
pnpm dev # start all the applications
Then visit, and edit, any of the following sites:
Running sites individually
You can run any of the sites individually by using the scope name. For example:
pnpm dev:www
Note: Particularly for www make sure you have copied apps/www/.env.local.example to apps/www/.env.local
Shared components
The monorepo has a set of shared components under /packages:
https://supabase.com/docs/guides/database/
https://supabase.com/docs/guides/auth
https://supabase.com/docs/guides/storage
https://supabase.com/docs/guides/functions
https://supabase.com/docs/guides/realtime
https://supabase.com/docs/guides/ai
https://supabase.com/docs/guides/cron
https://supabase.com/docs/guides/queues
Supabase的架构模块和实现语言
Architecture | Supabase Docs https://supabase.com/docs/guides/getting-started/architecture
Postgres is the core of Supabase. We do not abstract the Postgres database—you can access it and use it with full privileges. We provide tools which make Postgres as easy to use as Firebase.
An open source Dashboard for managing your database and services.
A JWT-based API for managing users and issuing access tokens. This integrates with PostgreSQL's Row Level Security and the API servers.
A standalone web server that turns your Postgres database directly into a RESTful API.
We use this with our pg_graphql extension to provide a GraphQL API.
A scalable WebSocket engine for managing user Presence, broadcasting messages, and streaming database changes.
An S3-compatible object storage service that stores metadata in Postgres.
A modern runtime for JavaScript and TypeScript.
A RESTful API for managing your Postgres. Fetch tables, add roles, and run queries.
A cloud-native, multi-tenant Postgres connection pooler.
A cloud-native API gateway, built on top of NGINX.
https://github.com/PostgREST/postgrest
PostgREST Documentation — PostgREST 14 documentation
Supabase provides a RESTful API using PostgREST. This is a very thin API layer on top of Postgres.
It exposes everything you need from a CRUD API at the URL https://<project_ref>.supabase.co/rest/v1/.
Postgres 自动生成的 GraphQL API。
Supabase GraphQL API 使用pg_graphql.它支持:
所有请求都在一次往返中解决,从而实现快速响应时间和高吞吐量。
supabase/pg_graphql: GraphQL support for PostgreSQL https://github.com/supabase/pg_graphql
https://github.com/supabase/supabase/tree/master/apps/studio
这是个前端项目,使用 Next.js Tailwind 实现
https://github.com/supabase/supabase 这个仓库使用pnpm管理了一个monorepo的代码仓【 Turborepo 管理】
There are four major layers to Supabase Auth:

Client layer#
The client layer runs in your app. This could be running in many places, including:
The client layer provides the functions that you use to sign in and manage users. We recommend using the Supabase client SDKs, which handle:
But at its core, this layer manages the making of HTTP calls, so you could write your own client layer if you wanted to.
See the Client SDKs for more information:
Auth service#
The Auth service is an Auth API server written and maintained by Supabase. It is a fork of the GoTrue project, originally created by Netlify.
supabase/auth源码分析 | go空间 Next-Blogger
supabase/auth采用golang实现
Elixir /erlang语言实现
发送临时消息,跟踪和同步共享状态,并在 WebSockets 上监听 Postgres 更改。
目前的代码库状态
supabase/storage: S3 compatible object storage service that stores metadata in Postgres

基于deno的javascript运行时
Edge Functions | Supabase Docs
Edge Functions are server-side TypeScript functions, distributed globally at the edge—close to your users. They can be used for listening to webhooks or integrating your Supabase project with third-parties like Stripe. Edge Functions are developed using Deno, which offers a few benefits to you as a developer:
函数的工作过程
管理pg数据库的rest API
A RESTful API for managing your Postgres. Fetch tables, add roles, and run queries (and more).
typescript语言实现
supabase/supavisor: A cloud-native, multi-tenant Postgres connection pooler.
Elixir /erlang语言实现
pg数据库多租户的云原生连接池管理

这个就是比较常见的了API网关了,在nginx基础上构建
从以上可见,作为BAAS的Supabase是在pg数据库基础上,深度绑定pg数据库,通过集成了大量的开源项目来实现的
【
低代码 - Oracle APEX 这个思路的商业产品oralce apex和这个有很大的类似性。如其官网的说明“Oracle APEX 可以帮助开发人员构建出色的应用并解决实际问题。您无需精通各种各样的 Web 技术。您只需关注要解决的问题,其他繁重的工作都可以交给 Oracle APEX 来为您处理。”
】
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。