Documentation

    Documentation

    Documentation

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    1. /
    2. /Backend modes and databases

    Updated Jul 7, 20264 min listen

    1. /
    2. /Backend modes and databases

    Updated Jul 7, 20264 min listen

    1. /
    2. /Backend modes and databases

    Updated Jul 7, 20264 min listen

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Architecture
    Data Model
    Real Time
    Discovery Mutation Sync
    Security
    Backend Services
    k8s-postgres-fcm Mode
    Firebase Integration
    Features
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Wallet & Credit System
    Multi-Vendor Store
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payments Overview
    PaymentConductor
    SubscriptionConductor
    VideoConductor
    News Module - Digital Newspaper Experience
    Member Blogs
    Public Profile Pages
    Username Reservation System
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Branding
    Themes
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Examples
    Quick Start
    White Label
    Real World
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Architecture
    Data Model
    Real Time
    Discovery Mutation Sync
    Security
    Backend Services
    k8s-postgres-fcm Mode
    Firebase Integration
    Features
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Wallet & Credit System
    Multi-Vendor Store
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payments Overview
    PaymentConductor
    SubscriptionConductor
    VideoConductor
    News Module - Digital Newspaper Experience
    Member Blogs
    Public Profile Pages
    Username Reservation System
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Branding
    Themes
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Examples
    Quick Start
    White Label
    Real World
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Architecture
    Data Model
    Real Time
    Discovery Mutation Sync
    Security
    Backend Services
    k8s-postgres-fcm Mode
    Firebase Integration
    Features
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Wallet & Credit System
    Multi-Vendor Store
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payments Overview
    PaymentConductor
    SubscriptionConductor
    VideoConductor
    News Module - Digital Newspaper Experience
    Member Blogs
    Public Profile Pages
    Username Reservation System
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Branding
    Themes
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Examples
    Quick Start
    White Label
    Real World
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)
    Docs
    Architecture
    Docs
    Architecture
    Docs
    Architecture

    Backend modes and databases

    Use the Founder / Developer tabs to filter this page for your role. The DB_BACKEND_MODE environment variable is required — the platform will not start without it.

    Ring Platform uses a single codebase with a required runtime switch: DB_BACKEND_MODE. The value selects which database adapters are registered, whether Firestore is used for application data, and how push notifications are wired.

    ModePrimary databaseFirebase useBest for
    k8s-postgres-fcmPostgreSQL 16 + PostGISFCM push onlyProduction self-hosted, local dev
    firebase-fullFirestore (first-class)Everything: DB, FCM, Storage, AI, HostingVercel Edge, clones, rapid prototyping
    supabase-fcmSupabase PostgreSQLFCM push onlyManaged cloud PostgreSQL

    Naming: Production on your own Postgres is often described as "self‑hosted PostgreSQL + FCM." The enum value remains k8s-postgres-fcm — renaming would break every deployment and clone without a coordinated migration.

    Implementation files: lib/database/backend-mode-config.ts, lib/database/DatabaseService.ts, lib/database/BackendSelector.ts, lib/database/shared-pg-pool.ts, lib/services/firebase-service-manager.ts (SSOT helpers for firebase-full).

    Firebase integration

    k8s-postgres-fcm mode

    Push notifications (FCM)

    Database selection guide

    Environment variables

    Tunnel protocol

    Which mode should I choose?

    ScenarioRecommended modeWhy
    Self-hosted production (k3s, K8s)k8s-postgres-fcmFull data sovereignty, PostgreSQL performance, PostGIS spatial queries
    Rapid prototyping / MVPfirebase-fullZero database provisioning, free FCM push, auto-scale
    Ring clone (white-label)firebase-fullNo PostgreSQL dependency for the clone operator
    Vercel Edge deploymentfirebase-fullVercel Edge Runtime + Firestore = no cold-start DB connection
    Cloud PostgreSQL (no K8s)supabase-fcmManaged PostgreSQL with Supabase, FCM push
    Push notifications neededAny modeFCM is optional and available in all three modes

    Why connection pooling matters

    Architecture by mode

    Three-mode architecture comparison

    Database routing rules (PostgreSQL modes)

    All application CRUD goes through db() from @/lib/database:

    • readDoc, createDoc, updateDoc, deleteDoc, queryDocs — document-shaped collections
    • findById, create, update, delete, query, transaction — legacy DatabaseService surface

    Raw SQL escape hatch: getSharedPgPool() in lib/database/shared-pg-pool.ts — calls initializeDatabase() then returns the adapter pool. Use only for PostGIS / SQL the doc-model cannot express. new Pool( is allowed only under lib/database/ (enforced by validate-provider-ssot.sh).

    2026-07-07 audit: Three rogue private pools in platform-settings-service.ts, ring-token-oracle.ts, and geolocation-service.ts were eliminated. Only platform_settings had a real hybrid-table bypass; those modules now use db().*Doc or getSharedPgPool().

    Backend selection in code

    Firebase in k8s-postgres-fcm and supabase-fcm

    Backend modes and databases

    Use the Founder / Developer tabs to filter this page for your role. The DB_BACKEND_MODE environment variable is required — the platform will not start without it.

    Ring Platform uses a single codebase with a required runtime switch: DB_BACKEND_MODE. The value selects which database adapters are registered, whether Firestore is used for application data, and how push notifications are wired.

    ModePrimary databaseFirebase useBest for
    k8s-postgres-fcmPostgreSQL 16 + PostGISFCM push onlyProduction self-hosted, local dev
    firebase-fullFirestore (first-class)Everything: DB, FCM, Storage, AI, HostingVercel Edge, clones, rapid prototyping
    supabase-fcmSupabase PostgreSQLFCM push onlyManaged cloud PostgreSQL

    Naming: Production on your own Postgres is often described as "self‑hosted PostgreSQL + FCM." The enum value remains k8s-postgres-fcm — renaming would break every deployment and clone without a coordinated migration.

    Implementation files: lib/database/backend-mode-config.ts, lib/database/DatabaseService.ts, lib/database/BackendSelector.ts, lib/database/shared-pg-pool.ts, lib/services/firebase-service-manager.ts (SSOT helpers for firebase-full).

    Firebase integration

    k8s-postgres-fcm mode

    Push notifications (FCM)

    Database selection guide

    Environment variables

    Tunnel protocol

    Which mode should I choose?

    ScenarioRecommended modeWhy
    Self-hosted production (k3s, K8s)k8s-postgres-fcmFull data sovereignty, PostgreSQL performance, PostGIS spatial queries
    Rapid prototyping / MVPfirebase-fullZero database provisioning, free FCM push, auto-scale
    Ring clone (white-label)firebase-fullNo PostgreSQL dependency for the clone operator
    Vercel Edge deploymentfirebase-fullVercel Edge Runtime + Firestore = no cold-start DB connection
    Cloud PostgreSQL (no K8s)supabase-fcmManaged PostgreSQL with Supabase, FCM push
    Push notifications neededAny modeFCM is optional and available in all three modes

    Why connection pooling matters

    Architecture by mode

    Three-mode architecture comparison

    Database routing rules (PostgreSQL modes)

    All application CRUD goes through db() from @/lib/database:

    • readDoc, createDoc, updateDoc, deleteDoc, queryDocs — document-shaped collections
    • findById, create, update, delete, query, transaction — legacy DatabaseService surface

    Raw SQL escape hatch: getSharedPgPool() in lib/database/shared-pg-pool.ts — calls initializeDatabase() then returns the adapter pool. Use only for PostGIS / SQL the doc-model cannot express. new Pool( is allowed only under lib/database/ (enforced by validate-provider-ssot.sh).

    2026-07-07 audit: Three rogue private pools in platform-settings-service.ts, ring-token-oracle.ts, and geolocation-service.ts were eliminated. Only platform_settings had a real hybrid-table bypass; those modules now use db().*Doc or getSharedPgPool().

    Backend selection in code

    Firebase in k8s-postgres-fcm and supabase-fcm

    Backend modes and databases

    Use the Founder / Developer tabs to filter this page for your role. The DB_BACKEND_MODE environment variable is required — the platform will not start without it.

    Ring Platform uses a single codebase with a required runtime switch: DB_BACKEND_MODE. The value selects which database adapters are registered, whether Firestore is used for application data, and how push notifications are wired.

    ModePrimary databaseFirebase useBest for
    k8s-postgres-fcmPostgreSQL 16 + PostGISFCM push onlyProduction self-hosted, local dev
    firebase-fullFirestore (first-class)Everything: DB, FCM, Storage, AI, HostingVercel Edge, clones, rapid prototyping
    supabase-fcmSupabase PostgreSQLFCM push onlyManaged cloud PostgreSQL

    Naming: Production on your own Postgres is often described as "self‑hosted PostgreSQL + FCM." The enum value remains k8s-postgres-fcm — renaming would break every deployment and clone without a coordinated migration.

    Implementation files: lib/database/backend-mode-config.ts, lib/database/DatabaseService.ts, lib/database/BackendSelector.ts, lib/database/shared-pg-pool.ts, lib/services/firebase-service-manager.ts (SSOT helpers for firebase-full).

    Firebase integration

    k8s-postgres-fcm mode

    Push notifications (FCM)

    Database selection guide

    Environment variables

    Tunnel protocol

    Which mode should I choose?

    ScenarioRecommended modeWhy
    Self-hosted production (k3s, K8s)k8s-postgres-fcmFull data sovereignty, PostgreSQL performance, PostGIS spatial queries
    Rapid prototyping / MVPfirebase-fullZero database provisioning, free FCM push, auto-scale
    Ring clone (white-label)firebase-fullNo PostgreSQL dependency for the clone operator
    Vercel Edge deploymentfirebase-fullVercel Edge Runtime + Firestore = no cold-start DB connection
    Cloud PostgreSQL (no K8s)supabase-fcmManaged PostgreSQL with Supabase, FCM push
    Push notifications neededAny modeFCM is optional and available in all three modes

    Why connection pooling matters

    Architecture by mode

    Three-mode architecture comparison

    Database routing rules (PostgreSQL modes)

    All application CRUD goes through db() from @/lib/database:

    • readDoc, createDoc, updateDoc, deleteDoc, queryDocs — document-shaped collections
    • findById, create, update, delete, query, transaction — legacy DatabaseService surface

    Raw SQL escape hatch: getSharedPgPool() in lib/database/shared-pg-pool.ts — calls initializeDatabase() then returns the adapter pool. Use only for PostGIS / SQL the doc-model cannot express. new Pool( is allowed only under lib/database/ (enforced by validate-provider-ssot.sh).

    2026-07-07 audit: Three rogue private pools in platform-settings-service.ts, ring-token-oracle.ts, and geolocation-service.ts were eliminated. Only platform_settings had a real hybrid-table bypass; those modules now use db().*Doc or getSharedPgPool().

    Backend selection in code

    Firebase in k8s-postgres-fcm and supabase-fcm

    In k8s-postgres-fcm and supabase-fcm, every feature module shares one adapter pool. You do not get surprise connection spikes when admin settings, wallet oracle, geolocation, or email CRM load concurrently — they all route through db() or the sanctioned getSharedPgPool() escape hatch for PostGIS.

    Cost comparison

    Aspectk8s-postgres-fcmfirebase-fullsupabase-fcm
    DatabaseInfrastructure cost onlyPay-per-read/writeSupabase tier pricing
    Push (FCM)FreeFreeFree
    StorageVercel Blob / self-hostedFirebase Storage (free tier)Supabase Storage
    ComputeK8s / DockerVercel Edge / Cloud RunVercel / Cloud Run
    AILLM client via lib/ai/llm-client.tsFirebase AI Logic + GeminiLLM client via lib/ai/llm-client.ts
  1. Application data routes through db() / PostgreSQLAdapter
  2. getAdminDb() returns a mock Firestore when shouldUseFirebaseForDatabase() is false
  3. FCM uses Firebase project credentials for push delivery only
  4. build-mock.server.ts provides type-compatible mocks during SSG and Postgres-primary modes
  5. Firebase in firebase-full mode

    • All application data goes to Firestore via FirebaseAdapter
    • lib/services/firebase-service-manager.ts provides 30+ React 19 cache()-native SSOT helpers
    • 3 atomic write primitives wrap read-modify-write in a single Firestore transaction
    • 6 real-time listener factories pair with Tunnel for live UI updates

    React 19 cache() pattern

    Eliminates duplicate Firestore reads within a single SSG/SSR cycle.

    Supabase: two different roles

    1. DB_BACKEND_MODE=supabase-fcm — PostgreSQL on Supabase; same Postgres-primary + FCM pattern as k8s mode
    2. Tunnel realtime (NEXT_PUBLIC_TUNNEL_TRANSPORT=supabase) — optional Realtime channel in lib/tunnel/transports/supabase-transport.ts. Orthogonal to which SQL backend owns your tables.

    Auth.js and database mode

    Auth tables live in PostgreSQL (k8s-postgres-fcm, supabase-fcm) or Firestore (firebase-full). See lib/auth/postgres-adapter.ts / data/schema.sql for the SQL path.

    Related documentation

    k8s-postgres-fcm mode

    Data model

    Firebase integration

    Database selection guide

    Environment variables

    Tunnel protocol

    Code structure

    typescript
    
    // lib/database/backend-mode-config.ts
    export type BackendMode = 'k8s-postgres-fcm' | 'firebase-full' | 'supabase-fcm'
    
    export function shouldUseFirebaseForDatabase(): boolean {
      return detectBackendMode() === 'firebase-full'
    }
    typescript
    
    import { cache } from 'react'
    
    export const getCachedUserCreditBalance = cache(async (userId: string) => {
      // Firestore read — cached for the duration of the request
    })

    In k8s-postgres-fcm and supabase-fcm, every feature module shares one adapter pool. You do not get surprise connection spikes when admin settings, wallet oracle, geolocation, or email CRM load concurrently — they all route through db() or the sanctioned getSharedPgPool() escape hatch for PostGIS.

    Cost comparison

    Aspectk8s-postgres-fcmfirebase-fullsupabase-fcm
    DatabaseInfrastructure cost onlyPay-per-read/writeSupabase tier pricing
    Push (FCM)FreeFreeFree
    StorageVercel Blob / self-hostedFirebase Storage (free tier)Supabase Storage
    ComputeK8s / DockerVercel Edge / Cloud RunVercel / Cloud Run
    AILLM client via lib/ai/llm-client.tsFirebase AI Logic + GeminiLLM client via lib/ai/llm-client.ts
  6. Application data routes through db() / PostgreSQLAdapter
  7. getAdminDb() returns a mock Firestore when shouldUseFirebaseForDatabase() is false
  8. FCM uses Firebase project credentials for push delivery only
  9. build-mock.server.ts provides type-compatible mocks during SSG and Postgres-primary modes
  10. Firebase in firebase-full mode

    • All application data goes to Firestore via FirebaseAdapter
    • lib/services/firebase-service-manager.ts provides 30+ React 19 cache()-native SSOT helpers
    • 3 atomic write primitives wrap read-modify-write in a single Firestore transaction
    • 6 real-time listener factories pair with Tunnel for live UI updates

    React 19 cache() pattern

    Eliminates duplicate Firestore reads within a single SSG/SSR cycle.

    Supabase: two different roles

    1. DB_BACKEND_MODE=supabase-fcm — PostgreSQL on Supabase; same Postgres-primary + FCM pattern as k8s mode
    2. Tunnel realtime (NEXT_PUBLIC_TUNNEL_TRANSPORT=supabase) — optional Realtime channel in lib/tunnel/transports/supabase-transport.ts. Orthogonal to which SQL backend owns your tables.

    Auth.js and database mode

    Auth tables live in PostgreSQL (k8s-postgres-fcm, supabase-fcm) or Firestore (firebase-full). See lib/auth/postgres-adapter.ts / data/schema.sql for the SQL path.

    Related documentation

    k8s-postgres-fcm mode

    Data model

    Firebase integration

    Database selection guide

    Environment variables

    Tunnel protocol

    Code structure

    typescript
    
    // lib/database/backend-mode-config.ts
    export type BackendMode = 'k8s-postgres-fcm' | 'firebase-full' | 'supabase-fcm'
    
    export function shouldUseFirebaseForDatabase(): boolean {
      return detectBackendMode() === 'firebase-full'
    }
    typescript
    
    import { cache } from 'react'
    
    export const getCachedUserCreditBalance = cache(async (userId: string) => {
      // Firestore read — cached for the duration of the request
    })

    In k8s-postgres-fcm and supabase-fcm, every feature module shares one adapter pool. You do not get surprise connection spikes when admin settings, wallet oracle, geolocation, or email CRM load concurrently — they all route through db() or the sanctioned getSharedPgPool() escape hatch for PostGIS.

    Cost comparison

    Aspectk8s-postgres-fcmfirebase-fullsupabase-fcm
    DatabaseInfrastructure cost onlyPay-per-read/writeSupabase tier pricing
    Push (FCM)FreeFreeFree
    StorageVercel Blob / self-hostedFirebase Storage (free tier)Supabase Storage
    ComputeK8s / DockerVercel Edge / Cloud RunVercel / Cloud Run
    AILLM client via lib/ai/llm-client.tsFirebase AI Logic + GeminiLLM client via lib/ai/llm-client.ts
  11. Application data routes through db() / PostgreSQLAdapter
  12. getAdminDb() returns a mock Firestore when shouldUseFirebaseForDatabase() is false
  13. FCM uses Firebase project credentials for push delivery only
  14. build-mock.server.ts provides type-compatible mocks during SSG and Postgres-primary modes
  15. Firebase in firebase-full mode

    • All application data goes to Firestore via FirebaseAdapter
    • lib/services/firebase-service-manager.ts provides 30+ React 19 cache()-native SSOT helpers
    • 3 atomic write primitives wrap read-modify-write in a single Firestore transaction
    • 6 real-time listener factories pair with Tunnel for live UI updates

    React 19 cache() pattern

    Eliminates duplicate Firestore reads within a single SSG/SSR cycle.

    Supabase: two different roles

    1. DB_BACKEND_MODE=supabase-fcm — PostgreSQL on Supabase; same Postgres-primary + FCM pattern as k8s mode
    2. Tunnel realtime (NEXT_PUBLIC_TUNNEL_TRANSPORT=supabase) — optional Realtime channel in lib/tunnel/transports/supabase-transport.ts. Orthogonal to which SQL backend owns your tables.

    Auth.js and database mode

    Auth tables live in PostgreSQL (k8s-postgres-fcm, supabase-fcm) or Firestore (firebase-full). See lib/auth/postgres-adapter.ts / data/schema.sql for the SQL path.

    Related documentation

    k8s-postgres-fcm mode

    Data model

    Firebase integration

    Database selection guide

    Environment variables

    Tunnel protocol

    Code structure

    typescript
    
    // lib/database/backend-mode-config.ts
    export type BackendMode = 'k8s-postgres-fcm' | 'firebase-full' | 'supabase-fcm'
    
    export function shouldUseFirebaseForDatabase(): boolean {
      return detectBackendMode() === 'firebase-full'
    }
    typescript
    
    import { cache } from 'react'
    
    export const getCachedUserCreditBalance = cache(async (userId: string) => {
      // Firestore read — cached for the duration of the request
    })