Documentation

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

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Features
    Multi-Vendor Store
    Inventory & Stock
    Vendor Management
    Commissions & Settlements
    SubscriptionConductor
    PaymentConductor
    Payments Overview
    Public Pools & DAO Jars
    WayForPay Payment Integration
    Wallet & Credit System
    WalletConductor
    Affiliate & Referral Enablement
    Referral Codes (Refcodes)
    NFT Exhibition Marketplace
    Solana NFT Gates
    Token Staking System
    Owner Project Lab
    Entities
    Opportunities
    Real-Time Messaging
    Ring Tasks
    WebRTC Calls & STUNner TURN
    Peer Games
    News Module
    Member Blogs
    Public Profile Pages
    Ring File Cabinet
    Username Reservation System
    Scientific Editor
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Email AI-CRM
    Ring Mailer & RingdomX Mail
    Tunnel Protocol
    VideoConductor
    MediaConductor
    Generative Gallery
    Authentication
    Security & Compliance
    Admin console
    Admin Wiki
    Manage via Telegram
    Locale System
    Mobile Experience
    Performance Optimization Patterns
    Examples
    Quick Start
    Basic Setup
    White Label
    Custom Branding
    Web3 Integration
    Real World
    Advanced Features
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Branding
    Themes
    Features
    Localization
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Web3
    Token launch jurisdictions
    Wallet
    Wallet Security Tips
    Integrations
    Ethereum wallets (Wagmi v3)
    RingFileBase (object storage API)
    Ring CDN (RingFileBase edge)
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Environment Configuration
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Architecture
    Data Model
    Security
    Real Time
    Discovery Mutation Sync
    PaymentConductor architecture
    WalletConductor architecture
    Development
    Ring MCP Server

    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)

    Documentation

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

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Features
    Multi-Vendor Store
    Inventory & Stock
    Vendor Management
    Commissions & Settlements
    SubscriptionConductor
    PaymentConductor
    Payments Overview
    Public Pools & DAO Jars
    WayForPay Payment Integration
    Wallet & Credit System
    WalletConductor
    Affiliate & Referral Enablement
    Referral Codes (Refcodes)
    NFT Exhibition Marketplace
    Solana NFT Gates
    Token Staking System
    Owner Project Lab
    Entities
    Opportunities
    Real-Time Messaging
    Ring Tasks
    WebRTC Calls & STUNner TURN
    Peer Games
    News Module
    Member Blogs
    Public Profile Pages
    Ring File Cabinet
    Username Reservation System
    Scientific Editor
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Email AI-CRM
    Ring Mailer & RingdomX Mail
    Tunnel Protocol
    VideoConductor
    MediaConductor
    Generative Gallery
    Authentication
    Security & Compliance
    Admin console
    Admin Wiki
    Manage via Telegram
    Locale System
    Mobile Experience
    Performance Optimization Patterns
    Examples
    Quick Start
    Basic Setup
    White Label
    Custom Branding
    Web3 Integration
    Real World
    Advanced Features
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Branding
    Themes
    Features
    Localization
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Web3
    Token launch jurisdictions
    Wallet
    Wallet Security Tips
    Integrations
    Ethereum wallets (Wagmi v3)
    RingFileBase (object storage API)
    Ring CDN (RingFileBase edge)
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Environment Configuration
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Architecture
    Data Model
    Security
    Real Time
    Discovery Mutation Sync
    PaymentConductor architecture
    WalletConductor architecture
    Development
    Ring MCP Server

    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)

    Documentation

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

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Features
    Multi-Vendor Store
    Inventory & Stock
    Vendor Management
    Commissions & Settlements
    SubscriptionConductor
    PaymentConductor
    Payments Overview
    Public Pools & DAO Jars
    WayForPay Payment Integration
    Wallet & Credit System
    WalletConductor
    Affiliate & Referral Enablement
    Referral Codes (Refcodes)
    NFT Exhibition Marketplace
    Solana NFT Gates
    Token Staking System
    Owner Project Lab
    Entities
    Opportunities
    Real-Time Messaging
    Ring Tasks
    WebRTC Calls & STUNner TURN
    Peer Games
    News Module
    Member Blogs
    Public Profile Pages
    Ring File Cabinet
    Username Reservation System
    Scientific Editor
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Email AI-CRM
    Ring Mailer & RingdomX Mail
    Tunnel Protocol
    VideoConductor
    MediaConductor
    Generative Gallery
    Authentication
    Security & Compliance
    Admin console
    Admin Wiki
    Manage via Telegram
    Locale System
    Mobile Experience
    Performance Optimization Patterns
    Examples
    Quick Start
    Basic Setup
    White Label
    Custom Branding
    Web3 Integration
    Real World
    Advanced Features
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Branding
    Themes
    Features
    Localization
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Web3
    Token launch jurisdictions
    Wallet
    Wallet Security Tips
    Integrations
    Ethereum wallets (Wagmi v3)
    RingFileBase (object storage API)
    Ring CDN (RingFileBase edge)
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Environment Configuration
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Architecture
    Data Model
    Security
    Real Time
    Discovery Mutation Sync
    PaymentConductor architecture
    WalletConductor architecture
    Development
    Ring MCP Server

    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)
    1. Docs
    2. /Features
    3. /Performance Optimization Patterns

    Updated Jul 7, 20264 min listen

    Ring Platform Logo

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

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

    1. Docs
    2. /Features
    3. /Performance Optimization Patterns

    Updated Jul 7, 20264 min listen

    Ring Platform Logo

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

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

    1. Docs
    2. /Features
    3. /Performance Optimization Patterns

    Updated Jul 7, 20264 min listen

    Ring Platform Logo

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

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

    Performance Optimization Patterns

    Ring Platform optimizes at four layers: Server Component request dedup, Next 16 'use cache' catalog reads, client bootstrap single-flight, and DatabaseService EntityCache. All patterns below trace to real files — no fabricated KPIs or invented utilities.

    Use Founder / Developer tabs in the docs sidebar to filter this page.

    What keeps your clone fast

    Most Ring pages are React Server Components — HTML arrives pre-rendered with minimal client JavaScript. Performance wins come from architecture, not bolt-on CDN tricks:

    LayerBenefit for operators
    Server-first renderingMarketing and catalog pages ship without heavy JS bundles
    Request-level dedupOne database read per page render, not one per component
    Batched analyticsWeb Vitals sent as one POST per page load, not five
    Provider SSOTNo duplicate credit-balance or notification polls draining API quota
    Build-time Firebase mockStatic generation does not require live Firebase credentials

    Development performance

    Integrator-focused patterns, pool rules, and SSOT script.

    Deployment performance

    Production hardening and infrastructure tuning.

    Caching strategy (verified)

    LayerScopeMechanismSSOT location
    React cache()Per-request (server)Request dedup within one RSC render passlib/services/firebase-service-manager.ts (firebase-full mode)
    Next 16 'use cache'Cross-request (server)cacheTag + cacheLifefeatures/store/config.ts → getCachedProductCatalog()
    EntityCache30s TTL (server)In-memory Map on entities collectionlib/database/DatabaseService.ts
    Bootstrap single-flightPer-tab (client)Module-scope promise + TTL keyed by

    Related documentation

    Development performance

    Best practices

    Backend modes

    Code structure

    Performance Optimization Patterns

    Ring Platform optimizes at four layers: Server Component request dedup, Next 16 'use cache' catalog reads, client bootstrap single-flight, and DatabaseService EntityCache. All patterns below trace to real files — no fabricated KPIs or invented utilities.

    Use Founder / Developer tabs in the docs sidebar to filter this page.

    What keeps your clone fast

    Most Ring pages are React Server Components — HTML arrives pre-rendered with minimal client JavaScript. Performance wins come from architecture, not bolt-on CDN tricks:

    LayerBenefit for operators
    Server-first renderingMarketing and catalog pages ship without heavy JS bundles
    Request-level dedupOne database read per page render, not one per component
    Batched analyticsWeb Vitals sent as one POST per page load, not five
    Provider SSOTNo duplicate credit-balance or notification polls draining API quota
    Build-time Firebase mockStatic generation does not require live Firebase credentials

    Development performance

    Integrator-focused patterns, pool rules, and SSOT script.

    Deployment performance

    Production hardening and infrastructure tuning.

    Caching strategy (verified)

    LayerScopeMechanismSSOT location
    React cache()Per-request (server)Request dedup within one RSC render passlib/services/firebase-service-manager.ts (firebase-full mode)
    Next 16 'use cache'Cross-request (server)cacheTag + cacheLifefeatures/store/config.ts → getCachedProductCatalog()
    EntityCache30s TTL (server)In-memory Map on entities collectionlib/database/DatabaseService.ts
    Bootstrap single-flightPer-tab (client)Module-scope promise + TTL keyed by

    Related documentation

    Development performance

    Best practices

    Backend modes

    Code structure

    Performance Optimization Patterns

    Ring Platform optimizes at four layers: Server Component request dedup, Next 16 'use cache' catalog reads, client bootstrap single-flight, and DatabaseService EntityCache. All patterns below trace to real files — no fabricated KPIs or invented utilities.

    Use Founder / Developer tabs in the docs sidebar to filter this page.

    What keeps your clone fast

    Most Ring pages are React Server Components — HTML arrives pre-rendered with minimal client JavaScript. Performance wins come from architecture, not bolt-on CDN tricks:

    LayerBenefit for operators
    Server-first renderingMarketing and catalog pages ship without heavy JS bundles
    Request-level dedupOne database read per page render, not one per component
    Batched analyticsWeb Vitals sent as one POST per page load, not five
    Provider SSOTNo duplicate credit-balance or notification polls draining API quota
    Build-time Firebase mockStatic generation does not require live Firebase credentials

    Development performance

    Integrator-focused patterns, pool rules, and SSOT script.

    Deployment performance

    Production hardening and infrastructure tuning.

    Caching strategy (verified)

    LayerScopeMechanismSSOT location
    React cache()Per-request (server)Request dedup within one RSC render passlib/services/firebase-service-manager.ts (firebase-full mode)
    Next 16 'use cache'Cross-request (server)cacheTag + cacheLifefeatures/store/config.ts → getCachedProductCatalog()
    EntityCache30s TTL (server)In-memory Map on entities collectionlib/database/DatabaseService.ts
    Bootstrap single-flightPer-tab (client)Module-scope promise + TTL keyed by

    Related documentation

    Development performance

    Best practices

    Backend modes

    Code structure

    userId
    hooks/use-vendor-status.ts (30s), hooks/use-credit-balance.ts (5s bootstrap)
    Session refetch tuningPer-tab (client)15min interval, no focus/offline refetchfeatures/auth/components/session-provider.tsx
    Web Vitals batchingPer-tab (client)Buffer + 1.5s debounce → single POSTcomponents/providers/web-vitals-provider.tsx

    Not used: sessionStorage server caches, custom RingApiClient, per-metric Web Vitals POST loops, or performance budget enforcement in next.config.mjs.

    Server-side patterns

    React 19 cache() — request dedup

    Multiple imports of the same document during one Server Component render resolve to one Firestore read.

    Store catalog — 'use cache' SSOT

    Shared by app/api/store/products/route.ts and getStoreProducts server action. Invalidate with updateTag('store:products') after product mutations.

    DatabaseService EntityCache

    30-second TTL on entities collection for read-after-write consistency. Writes invalidate affected keys automatically.

    DatabaseService contract

    Use findDocById for single-document lookups — not queryDocs filtered by id.

    Client-side SSOT patterns

    Web Vitals — batched POST (not per-metric)

    WebVitalsProvider buffers useReportWebVitals callbacks and flushes one POST /api/analytics/web-vitals per debounce window (1.5s), shaped to webVitalsPayloadSchema in features/analytics/lib/analytics-db.ts. Metrics also flush on visibilitychange / pagehide.

    useReportWebVitals fires once per Core Web Vital (CLS, FCP, LCP, TTFB, INP). Without batching that would be up to five POSTs per page load. The provider collapses them into one request.

    Bootstrap single-flight hooks

    Documented in hooks/HOOKS-README.md § P4:

    • useVendorStatus — dedupes GET /api/vendor/status across sidebar layout remounts.
    • useCreditBalance — bootstrap fetch dedupes across Strict Mode / Suspense remounts; live updates still flow through CreditBalanceProvider + tunnel.

    Enforce with ./scripts/validate-provider-ssot.sh (seven gates — see Best practices).

    Build optimization

    During next build, lib/firebase/build-mock.server.ts returns mock Firestore/Auth instances so static generation does not require live Firebase credentials. SWC minification and CSS optimization are handled by Next.js 16 automatically — there is no swcMinify or experimental.optimizeCss flag.

    Firebase debug metrics (dev only)

    getCacheMetrics() in firebase-service-manager.ts logs hit rate when FIREBASE_DEBUG_LOGS=true. This is a dev console tool, not production monitoring.

    PostgreSQL pool

    All connection pooling lives in lib/database/. Domain code uses db(); PostGIS-only raw SQL uses getSharedPgPool(). Never instantiate new Pool( outside lib/database/ — gate 7 of the SSOT script.

    userId
    hooks/use-vendor-status.ts (30s), hooks/use-credit-balance.ts (5s bootstrap)
    Session refetch tuningPer-tab (client)15min interval, no focus/offline refetchfeatures/auth/components/session-provider.tsx
    Web Vitals batchingPer-tab (client)Buffer + 1.5s debounce → single POSTcomponents/providers/web-vitals-provider.tsx

    Not used: sessionStorage server caches, custom RingApiClient, per-metric Web Vitals POST loops, or performance budget enforcement in next.config.mjs.

    Server-side patterns

    React 19 cache() — request dedup

    Multiple imports of the same document during one Server Component render resolve to one Firestore read.

    Store catalog — 'use cache' SSOT

    Shared by app/api/store/products/route.ts and getStoreProducts server action. Invalidate with updateTag('store:products') after product mutations.

    DatabaseService EntityCache

    30-second TTL on entities collection for read-after-write consistency. Writes invalidate affected keys automatically.

    DatabaseService contract

    Use findDocById for single-document lookups — not queryDocs filtered by id.

    Client-side SSOT patterns

    Web Vitals — batched POST (not per-metric)

    WebVitalsProvider buffers useReportWebVitals callbacks and flushes one POST /api/analytics/web-vitals per debounce window (1.5s), shaped to webVitalsPayloadSchema in features/analytics/lib/analytics-db.ts. Metrics also flush on visibilitychange / pagehide.

    useReportWebVitals fires once per Core Web Vital (CLS, FCP, LCP, TTFB, INP). Without batching that would be up to five POSTs per page load. The provider collapses them into one request.

    Bootstrap single-flight hooks

    Documented in hooks/HOOKS-README.md § P4:

    • useVendorStatus — dedupes GET /api/vendor/status across sidebar layout remounts.
    • useCreditBalance — bootstrap fetch dedupes across Strict Mode / Suspense remounts; live updates still flow through CreditBalanceProvider + tunnel.

    Enforce with ./scripts/validate-provider-ssot.sh (seven gates — see Best practices).

    Build optimization

    During next build, lib/firebase/build-mock.server.ts returns mock Firestore/Auth instances so static generation does not require live Firebase credentials. SWC minification and CSS optimization are handled by Next.js 16 automatically — there is no swcMinify or experimental.optimizeCss flag.

    Firebase debug metrics (dev only)

    getCacheMetrics() in firebase-service-manager.ts logs hit rate when FIREBASE_DEBUG_LOGS=true. This is a dev console tool, not production monitoring.

    PostgreSQL pool

    All connection pooling lives in lib/database/. Domain code uses db(); PostGIS-only raw SQL uses getSharedPgPool(). Never instantiate new Pool( outside lib/database/ — gate 7 of the SSOT script.

    userId
    hooks/use-vendor-status.ts (30s), hooks/use-credit-balance.ts (5s bootstrap)
    Session refetch tuningPer-tab (client)15min interval, no focus/offline refetchfeatures/auth/components/session-provider.tsx
    Web Vitals batchingPer-tab (client)Buffer + 1.5s debounce → single POSTcomponents/providers/web-vitals-provider.tsx

    Not used: sessionStorage server caches, custom RingApiClient, per-metric Web Vitals POST loops, or performance budget enforcement in next.config.mjs.

    Server-side patterns

    React 19 cache() — request dedup

    Multiple imports of the same document during one Server Component render resolve to one Firestore read.

    Store catalog — 'use cache' SSOT

    Shared by app/api/store/products/route.ts and getStoreProducts server action. Invalidate with updateTag('store:products') after product mutations.

    DatabaseService EntityCache

    30-second TTL on entities collection for read-after-write consistency. Writes invalidate affected keys automatically.

    DatabaseService contract

    Use findDocById for single-document lookups — not queryDocs filtered by id.

    Client-side SSOT patterns

    Web Vitals — batched POST (not per-metric)

    WebVitalsProvider buffers useReportWebVitals callbacks and flushes one POST /api/analytics/web-vitals per debounce window (1.5s), shaped to webVitalsPayloadSchema in features/analytics/lib/analytics-db.ts. Metrics also flush on visibilitychange / pagehide.

    useReportWebVitals fires once per Core Web Vital (CLS, FCP, LCP, TTFB, INP). Without batching that would be up to five POSTs per page load. The provider collapses them into one request.

    Bootstrap single-flight hooks

    Documented in hooks/HOOKS-README.md § P4:

    • useVendorStatus — dedupes GET /api/vendor/status across sidebar layout remounts.
    • useCreditBalance — bootstrap fetch dedupes across Strict Mode / Suspense remounts; live updates still flow through CreditBalanceProvider + tunnel.

    Enforce with ./scripts/validate-provider-ssot.sh (seven gates — see Best practices).

    Build optimization

    During next build, lib/firebase/build-mock.server.ts returns mock Firestore/Auth instances so static generation does not require live Firebase credentials. SWC minification and CSS optimization are handled by Next.js 16 automatically — there is no swcMinify or experimental.optimizeCss flag.

    Firebase debug metrics (dev only)

    getCacheMetrics() in firebase-service-manager.ts logs hit rate when FIREBASE_DEBUG_LOGS=true. This is a dev console tool, not production monitoring.

    PostgreSQL pool

    All connection pooling lives in lib/database/. Domain code uses db(); PostGIS-only raw SQL uses getSharedPgPool(). Never instantiate new Pool( outside lib/database/ — gate 7 of the SSOT script.

    typescript
    
    // lib/services/firebase-service-manager.ts (firebase-full mode)
    import { cache } from 'react'
    
    export const getCachedDocument = cache(async (collection: string, docId: string) => {
      const db = getAdminDb()
      const doc = await db.collection(collection).doc(docId).get()
      return doc.exists ? doc : null
    })
    typescript
    
    // features/store/config.ts
    export async function getCachedProductCatalog(): Promise<StoreProduct[]> {
      'use cache'
      cacheTag('store:products')
      cacheLife('minutes')
    
      const adapter = await getStoreAdapter()
      return adapter.listProducts()
    }
    typescript
    
    const result = await db().queryDocs({
      collection: 'entities',
      filters: [{ field: 'status', operator: 'eq', value: 'active' }],
      orderBy: [{ field: 'createdAt', direction: 'desc' }],
      pagination: { limit: 20, offset: 0 },
    })
    if (!result.success) throw result.error
    typescript
    
    // next.config.mjs (excerpt)
    const nextConfig = {
      reactStrictMode: true,
      cacheComponents: true,
    }
    typescript
    
    // lib/services/firebase-service-manager.ts (firebase-full mode)
    import { cache } from 'react'
    
    export const getCachedDocument = cache(async (collection: string, docId: string) => {
      const db = getAdminDb()
      const doc = await db.collection(collection).doc(docId).get()
      return doc.exists ? doc : null
    })
    typescript
    
    // features/store/config.ts
    export async function getCachedProductCatalog(): Promise<StoreProduct[]> {
      'use cache'
      cacheTag('store:products')
      cacheLife('minutes')
    
      const adapter = await getStoreAdapter()
      return adapter.listProducts()
    }
    typescript
    
    const result = await db().queryDocs({
      collection: 'entities',
      filters: [{ field: 'status', operator: 'eq', value: 'active' }],
      orderBy: [{ field: 'createdAt', direction: 'desc' }],
      pagination: { limit: 20, offset: 0 },
    })
    if (!result.success) throw result.error
    typescript
    
    // next.config.mjs (excerpt)
    const nextConfig = {
      reactStrictMode: true,
      cacheComponents: true,
    }
    typescript
    
    // lib/services/firebase-service-manager.ts (firebase-full mode)
    import { cache } from 'react'
    
    export const getCachedDocument = cache(async (collection: string, docId: string) => {
      const db = getAdminDb()
      const doc = await db.collection(collection).doc(docId).get()
      return doc.exists ? doc : null
    })
    typescript
    
    // features/store/config.ts
    export async function getCachedProductCatalog(): Promise<StoreProduct[]> {
      'use cache'
      cacheTag('store:products')
      cacheLife('minutes')
    
      const adapter = await getStoreAdapter()
      return adapter.listProducts()
    }
    typescript
    
    const result = await db().queryDocs({
      collection: 'entities',
      filters: [{ field: 'status', operator: 'eq', value: 'active' }],
      orderBy: [{ field: 'createdAt', direction: 'desc' }],
      pagination: { limit: 20, offset: 0 },
    })
    if (!result.success) throw result.error
    typescript
    
    // next.config.mjs (excerpt)
    const nextConfig = {
      reactStrictMode: true,
      cacheComponents: true,
    }