Concepts, value, and typical clone scenarios — less code.
Concepts, value, and typical clone scenarios — less code.
Підготовка контенту платформи Ring
Підготовка контенту платформи Ring
Підготовка контенту платформи Ring
Development patterns and conventions specific to Ring Platform v1.6.4.
Use Founder / Developer tabs in the docs sidebar to filter this page.
Ring Platform is a multi-tenant white-label platform powering production clones. Every pattern must work across PostgreSQL-primary (k8s-postgres-fcm) and Firebase-backed deployments. The DatabaseService abstraction ensures this — write to db() once, run anywhere.
userId is always derived from await auth() in server code, never from client-supplied parameters.file() abstraction (@/lib/file) — access controls are enforced at the upload layer.All user-facing strings live in locales/{locale}/ JSON bundles loaded by next-intl. See Proxy and i18n.
DB_BACKEND_MODE selects the database adapter at runtime. Do not import firebase-admin or postgres directly in domain code. See Backend modes and databases.
Development patterns and conventions specific to Ring Platform v1.6.4.
Use Founder / Developer tabs in the docs sidebar to filter this page.
Ring Platform is a multi-tenant white-label platform powering production clones. Every pattern must work across PostgreSQL-primary (k8s-postgres-fcm) and Firebase-backed deployments. The DatabaseService abstraction ensures this — write to db() once, run anywhere.
userId is always derived from await auth() in server code, never from client-supplied parameters.file() abstraction (@/lib/file) — access controls are enforced at the upload layer.All user-facing strings live in locales/{locale}/ JSON bundles loaded by next-intl. See Proxy and i18n.
DB_BACKEND_MODE selects the database adapter at runtime. Do not import firebase-admin or postgres directly in domain code. See Backend modes and databases.
Development patterns and conventions specific to Ring Platform v1.6.4.
Use Founder / Developer tabs in the docs sidebar to filter this page.
Ring Platform is a multi-tenant white-label platform powering production clones. Every pattern must work across PostgreSQL-primary (k8s-postgres-fcm) and Firebase-backed deployments. The DatabaseService abstraction ensures this — write to db() once, run anywhere.
userId is always derived from await auth() in server code, never from client-supplied parameters.file() abstraction (@/lib/file) — access controls are enforced at the upload layer.All user-facing strings live in locales/{locale}/ JSON bundles loaded by next-intl. See Proxy and i18n.
DB_BACKEND_MODE selects the database adapter at runtime. Do not import firebase-admin or postgres directly in domain code. See Backend modes and databases.
SessionProviderExactly one export function SessionProvider — SSOT: features/auth/components/session-provider.tsx |
| 7 | new Pool( | Allowed only under lib/database/ |
import { db } from '@/lib/database'
const result = await db().createDoc('entities', { name: 'Acme', type: 'technology' })
if (!result.success) throw result.error
const entity = await db().findDocById<Entity>('entities', id)
if (!entity.success) throw entity.error
const results = await db().queryDocs<Entity>({
collection: 'entities',
filters: [{ field: 'status', operator: '==', value: 'active' }],
orderBy: [{ field: 'name', direction: 'asc' }],
pagination: { limit: 20, offset: 0 },
})
const settings = await db().findDocById<PlatformSettingsDoc>('platform_settings', 'ai')
if (!settings.success) throw settings.error
import { getSharedPgPool } from '@/lib/database'
const pool = await getSharedPgPool()
const { rows } = await pool.query(
`SELECT id FROM entities WHERE ST_DWithin(location, ST_MakePoint($1, $2)::geography, $3)`,
[lng, lat, radiusM]
)
await db().transaction(async (txn) => {
const existing = await txn.read('usernames', usernameKey)
if (existing) throw new Error('Username is taken')
await txn.create('usernames', { userId, reservedAt: new Date() }, { id: usernameKey })
await txn.update('users', userId, { username })
})
./scripts/validate-provider-ssot.sh
import { auth } from '@/auth'
export async function getServerSession() {
return auth()
}
'use client'
import { useSession } from '@/auth/client'
// Or useAuth() from hooks/use-auth.ts for signOut + FCM cleanup
import { file } from '@/lib/file'
const result = await file().upload(`entities/${entityId}/logo.webp`, fileObject, {
access: 'public',
addRandomSuffix: false,
})
if (!result.success) throw new Error(result.error?.message ?? 'Upload failed')SessionProviderExactly one export function SessionProvider — SSOT: features/auth/components/session-provider.tsx |
| 7 | new Pool( | Allowed only under lib/database/ |
import { db } from '@/lib/database'
const result = await db().createDoc('entities', { name: 'Acme', type: 'technology' })
if (!result.success) throw result.error
const entity = await db().findDocById<Entity>('entities', id)
if (!entity.success) throw entity.error
const results = await db().queryDocs<Entity>({
collection: 'entities',
filters: [{ field: 'status', operator: '==', value: 'active' }],
orderBy: [{ field: 'name', direction: 'asc' }],
pagination: { limit: 20, offset: 0 },
})
const settings = await db().findDocById<PlatformSettingsDoc>('platform_settings', 'ai')
if (!settings.success) throw settings.error
import { getSharedPgPool } from '@/lib/database'
const pool = await getSharedPgPool()
const { rows } = await pool.query(
`SELECT id FROM entities WHERE ST_DWithin(location, ST_MakePoint($1, $2)::geography, $3)`,
[lng, lat, radiusM]
)
await db().transaction(async (txn) => {
const existing = await txn.read('usernames', usernameKey)
if (existing) throw new Error('Username is taken')
await txn.create('usernames', { userId, reservedAt: new Date() }, { id: usernameKey })
await txn.update('users', userId, { username })
})
./scripts/validate-provider-ssot.sh
import { auth } from '@/auth'
export async function getServerSession() {
return auth()
}
'use client'
import { useSession } from '@/auth/client'
// Or useAuth() from hooks/use-auth.ts for signOut + FCM cleanup
import { file } from '@/lib/file'
const result = await file().upload(`entities/${entityId}/logo.webp`, fileObject, {
access: 'public',
addRandomSuffix: false,
})
if (!result.success) throw new Error(result.error?.message ?? 'Upload failed')SessionProviderExactly one export function SessionProvider — SSOT: features/auth/components/session-provider.tsx |
| 7 | new Pool( | Allowed only under lib/database/ |
import { db } from '@/lib/database'
const result = await db().createDoc('entities', { name: 'Acme', type: 'technology' })
if (!result.success) throw result.error
const entity = await db().findDocById<Entity>('entities', id)
if (!entity.success) throw entity.error
const results = await db().queryDocs<Entity>({
collection: 'entities',
filters: [{ field: 'status', operator: '==', value: 'active' }],
orderBy: [{ field: 'name', direction: 'asc' }],
pagination: { limit: 20, offset: 0 },
})
const settings = await db().findDocById<PlatformSettingsDoc>('platform_settings', 'ai')
if (!settings.success) throw settings.error
import { getSharedPgPool } from '@/lib/database'
const pool = await getSharedPgPool()
const { rows } = await pool.query(
`SELECT id FROM entities WHERE ST_DWithin(location, ST_MakePoint($1, $2)::geography, $3)`,
[lng, lat, radiusM]
)
await db().transaction(async (txn) => {
const existing = await txn.read('usernames', usernameKey)
if (existing) throw new Error('Username is taken')
await txn.create('usernames', { userId, reservedAt: new Date() }, { id: usernameKey })
await txn.update('users', userId, { username })
})
./scripts/validate-provider-ssot.sh
import { auth } from '@/auth'
export async function getServerSession() {
return auth()
}
'use client'
import { useSession } from '@/auth/client'
// Or useAuth() from hooks/use-auth.ts for signOut + FCM cleanup
import { file } from '@/lib/file'
const result = await file().upload(`entities/${entityId}/logo.webp`, fileObject, {
access: 'public',
addRandomSuffix: false,
})
if (!result.success) throw new Error(result.error?.message ?? 'Upload failed')