Infrastructure Boundaries
Shared infrastructure belongs in lib only when more than one feature depends on it.
On this page
Auth
Session reads, guards, RBAC helpers, profile lookup, and role checks live under lib/auth and nearby server boundaries.
Supabase
Client creation, service-role access, generated database types, and storage helpers stay behind server-safe helpers.
SEO
Metadata builders, schema output, canonical URLs, and public settings are grouped so public routes stay small.
Utilities
Only broadly reused helpers such as class merging, currency, colors, dates, and serialization belong in lib utilities.
lib folder map
| Folder | Use |
|---|---|
| lib/api | Shared API helpers used by route handlers. |
| lib/audit | Audit log helpers for important admin and system actions. |
| lib/auth | Session reads, route guards, RBAC, roles, and profile lookup. |
| lib/content-blocks | Shared content block rendering and parsing helpers. |
| lib/csv.ts | Spreadsheet-safe CSV serialization and formula-injection sanitization. |
| lib/dashboard | Cross-feature admin dashboard view-model orchestration. |
| lib/datetime | Date and time formatting helpers. |
| lib/identity | Email normalization, validations, and privacy masking/redaction primitives. |
| lib/image-preview.ts | Safe image preview protocol source validation. |
| lib/localization | Locale parsing, defaults, and server-safe localization helpers. |
| lib/navigation | Dashboard navigation and search metadata. |
| lib/observe | Runtime logging and observation helpers. |
| lib/security | Rate limits, security helpers, and request safety utilities. |
| lib/seo | Metadata, JSON-LD, canonical URL, and structured data helpers. |
| lib/supabase | Supabase browser/server clients, generated types, proxy helpers, and PostgREST helpers. |
| lib/tracking | UTM and attribution helpers. |
| lib/uploads | Upload media type checks and storage-related helpers. |
| lib/utils | Small shared utilities such as currency, colors, and storage helpers. |