How androidpoet/supabase-kmp works
1. Repository shape
This is a Kotlin Multiplatform SDK monorepo for Supabase, organized as a set of publishable Gradle modules rather than a single app. The root build wires together shared Kotlin source, platform-specific implementations, tests, samples, docs, and release automation.
2. Core foundation layer
supabase-core is the lowest shared dependency. It defines the project-wide result/error model (SupabaseResult, SupabaseError), typed IDs, filter-building utilities, and common response models. Most higher-level modules depend on this layer for consistent error handling and type safety.
3. HTTP client and transport boundary
supabase-client is the transport backbone. It wraps Ktor with a SupabaseClient abstraction, request interceptors, logging, retry policy, and platform-specific engines for Android/JVM, Apple, Linux/Windows, and Wasm. This module is the main boundary between the SDK and Supabase’s HTTP APIs.
4. Feature modules sit on top of the client
supabase-auth, supabase-database, supabase-storage, and supabase-functions all build on supabase-client plus supabase-core. They expose feature-specific client interfaces, factories, path helpers, and typed models while reusing the same transport, result, and serialization conventions.
5. Authentication and session management
supabase-auth handles email/password, OAuth, MFA, PKCE, native sign-in, and session lifecycle. It includes a SessionManager with StateFlow-based state, auto-refresh, and pluggable session storage. Persistence is abstracted through SessionStorage, with in-memory and key-value implementations; platform apps are expected to bind key-value storage to secure stores.
6. Platform-native identity providers
supabase-auth-google and supabase-auth-apple are optional adapter modules that bridge platform SDKs into a common NativeAuthProvider flow. They are intentionally isolated so the core auth module does not depend on Google/Apple SDKs unless the app opts in.
7. Database, storage, and functions data paths
supabase-database maps to PostgREST CRUD and RPC endpoints, with typed query extensions built on the shared filter DSL. supabase-storage covers bucket/file APIs, signed URLs, public URLs, and resumable upload support. supabase-functions invokes Supabase Edge Functions over HTTP with typed request/response helpers. All three use the common client transport and report outcomes through SupabaseResult.
8. Realtime subsystem
supabase-realtime is the WebSocket layer. It manages Phoenix protocol channels, connection state, reconnection/backoff, presence, broadcast, typed events, and subscription filtering. It depends on the shared client for networking but is architecturally separate from the HTTP request/response modules because its lifecycle is long-lived and stateful.
9. External systems and runtime boundaries
The SDK talks to Supabase over three main channels: HTTP for auth/database/storage/functions, WebSocket for realtime, and platform-native sign-in SDKs for Google/Apple flows. Ktor engines provide the runtime-specific networking implementation, so the same API surface works across Android, iOS/macOS/tvOS/watchOS, JVM, Linux, Windows, and Wasm.
10. Samples and integration examples
samples/chat-compose is an Android/Compose sample that demonstrates end-to-end use of auth, database, realtime, and UI state. samples/desktop-demo shows a minimal desktop entry point. These are useful architecture references because they show how the modules are composed from an app’s perspective.
11. End-to-end test boundary
e2e-tests validates the SDK against a real or local Supabase backend. The presence of supabase/ with migrations, seed data, and an example Edge Function shows that the repository includes a test backend environment, not just client code.
12. Documentation and release pipeline
docs/ and website/ are separate documentation systems, while GitHub Actions handles build, API checks, docs publishing, dependency submission, and release attestation. buildSrc, API dumps under each module, detekt config, and the version catalog are part of the engineering boundary that keeps the public surface stable across multiplatform targets.
Main entry points: auth Auth · client Client · core Core · database Database
Components 17
Core SDK
Shared foundation and client transport
- Core · Shared result, error, filter, ID, and response model layer used across the SDK.
supabase-core/src/commonMain/kotlin/io/github/androidpoet/supabase/core - Client · Ktor-backed Supabase client abstraction with interceptors, logging, retry, and platform engines.
supabase-client/src/commonMain/kotlin/io/github/androidpoet/supabase/client - HTTP transport · Shared request pipeline and transport boundary for Supabase HTTP APIs.
supabase-client/src/commonMain/kotlin/io/github/androidpoet/supabase/client/transport - Platform engines · Platform-specific Ktor engine implementations for Android, Apple, JVM, Linux, Windows, and Wasm.
supabase-client/src/androidMain/kotlin/io/github/androidpoet/supabase/client/transport
Feature modules
HTTP-facing Supabase features built on the shared client
- Auth · Email/password, OAuth, MFA, PKCE, native sign-in hooks, and session lifecycle management.
supabase-auth/src/commonMain/kotlin/io/github/androidpoet/supabase/auth - Sessions · Session manager, storage abstraction, in-memory and key-value persistence, and auto-refresh state flow.
supabase-auth/src/commonMain/kotlin/io/github/androidpoet/supabase/auth/session - Database · CRUD and RPC access for Supabase/PostgREST, built on shared filters and result handling.
supabase-database/src/commonMain/kotlin/io/github/androidpoet/supabase/database - Storage · Bucket, file, URL, and resumable upload APIs over the shared HTTP client.
supabase-storage/src/commonMain/kotlin/io/github/androidpoet/supabase/storage - Functions · Supabase Edge Function invocation with typed request and response helpers.
supabase-functions/src/commonMain/kotlin/io/github/androidpoet/supabase/functions - Realtime · Phoenix channel WebSocket layer with connection state, reconnection, presence, broadcast, and typed events.
supabase-realtime/src/commonMain/kotlin/io/github/androidpoet/supabase/realtime
Native auth adapters
Optional platform-specific sign-in bridges
- Google sign-in · Optional Android Google sign-in bridge that feeds the shared native auth flow.
supabase-auth-google/src/commonMain/kotlin/io/github/androidpoet/supabase/auth/google - Apple sign-in · Optional Apple sign-in bridge for iOS, macOS, and shared Apple targets.
supabase-auth-apple/src/commonMain/kotlin/io/github/androidpoet/supabase/auth/apple
Runtime and examples
Samples, docs, and backend validation
- Chat sample · Compose sample wiring auth, database, realtime, and UI state into an end-to-end app.
samples/chat-compose/src/main/java/io/github/androidpoet/supabase/sample/chat - Desktop demo · Minimal desktop entry point demonstrating SDK composition outside Android.
samples/desktop-demo/src/main/kotlin/io/github/androidpoet/supabase/sample/desktop - E2E tests · Backend-backed verification against a real or local Supabase environment, including migrations and seed data.
e2e-tests/src/test/kotlin/io/github/androidpoet/supabase/e2e - Docs site · MkDocs and website content covering architecture, guides, API docs, and tutorials.
docs
Tooling
Build and release infrastructure
- Build tooling · Root Gradle wiring, buildSrc conventions, version catalog, and CI/release workflow automation.
buildSrc/src/main/kotlin/io/github/androidpoet/supabase/Configuration.kt
Connections 28
- Client → Core: uses · Transport reuses the shared result and error model.
- HTTP transport → Client: implements · The transport layer powers the client abstraction.
- Platform engines → HTTP transport: plugs in · Platform engines provide runtime-specific HTTP execution.
- Auth → Client: built on · Auth API calls go through the shared client.
- Auth → Core: uses · Auth returns shared result and response types.
- Sessions → Auth: supports · Session management is part of the auth subsystem.
- Sessions → Core: uses · Session state and errors align with core types.
- Database → Client: built on · Database requests flow through the shared HTTP client.
- Database → Core: uses · Database APIs report through the shared result model.
- Storage → Client: built on · Storage requests use the common transport.
- Storage → Core: uses · Storage APIs share response and result conventions.
- Functions → Client: built on · Functions invocation is implemented over HTTP transport.
- Functions → Core: uses · Functions responses and failures use shared core types.
- Realtime → Client: depends on · Realtime leverages the shared networking layer but remains a separate lifecycle.
- Realtime → Core: uses · Realtime events and outcomes reuse common types.
- Google sign-in → Auth: adapts · Google sign-in feeds the shared native auth flow.
- Apple sign-in → Auth: adapts · Apple sign-in feeds the shared native auth flow.
- Chat sample → Auth: composes · Sample app exercises authentication.
- Chat sample → Database: composes · Sample app reads and writes chat data.
- Chat sample → Realtime: composes · Sample app subscribes to live updates.
- Desktop demo → Client: demonstrates · Desktop demo shows basic SDK usage from a non-Android runtime.
- E2E tests → Auth: validates · End-to-end tests cover auth flows.
- E2E tests → Database: validates · End-to-end tests cover database behavior.
- Docs site → Auth: documents · Documentation includes auth guides and API references.
- Docs site → Realtime: documents · Documentation covers realtime concepts and usage.
- Build tooling → Core: governs · Build conventions and API stability apply across modules.
- Build tooling → Docs site: publishes · Docs and website are part of the release and publishing pipeline.
- Build tooling → E2E tests: orchestrates · CI runs backend validation and release checks.